From 7473278dab734ec6d75d8bce9079abdcf42cc72b Mon Sep 17 00:00:00 2001 From: FOlkvangrField Date: Sat, 30 Dec 2023 16:14:10 +0800 Subject: [PATCH] More custom machine options Add more custom machine options. Now custom machines can receive neutron flux and heat through the "Neutron Flux Receiver" and "Heat receiver" blocks within the structure. The recipe has also added corresponding configurable neutron flux and heat requirements, and can also be configured to generate/absorb contamination --- src/main/java/com/hbm/blocks/ModBlocks.java | 6 + .../com/hbm/blocks/machine/BlockCMFlux.java | 9 + .../com/hbm/blocks/machine/BlockCMHeat.java | 9 + .../hbm/config/CustomMachineConfigJSON.java | 77 ++-- .../hbm/handler/nei/CustomMachineHandler.java | 91 +++-- .../hbm/inventory/gui/GUIMachineCustom.java | 51 +-- .../recipes/CustomMachineRecipes.java | 62 +++- .../java/com/hbm/main/CraftingManager.java | 2 + .../machine/TileEntityCustomMachine.java | 340 ++++++++++++------ src/main/resources/assets/hbm/lang/en_US.lang | 2 + .../hbm/textures/blocks/cm_flux_side.png | Bin 0 -> 410 bytes .../hbm/textures/blocks/cm_flux_top.png | Bin 0 -> 541 bytes .../hbm/textures/blocks/cm_heat_side.png | Bin 0 -> 218 bytes .../hbm/textures/blocks/cm_heat_top.png | Bin 0 -> 742 bytes .../textures/gui/processing/gui_custom.png | Bin 3223 -> 3745 bytes 15 files changed, 432 insertions(+), 217 deletions(-) create mode 100644 src/main/java/com/hbm/blocks/machine/BlockCMFlux.java create mode 100644 src/main/java/com/hbm/blocks/machine/BlockCMHeat.java create mode 100644 src/main/resources/assets/hbm/textures/blocks/cm_flux_side.png create mode 100644 src/main/resources/assets/hbm/textures/blocks/cm_flux_top.png create mode 100644 src/main/resources/assets/hbm/textures/blocks/cm_heat_side.png create mode 100644 src/main/resources/assets/hbm/textures/blocks/cm_heat_top.png diff --git a/src/main/java/com/hbm/blocks/ModBlocks.java b/src/main/java/com/hbm/blocks/ModBlocks.java index 1b69835f3..89ccc4b2c 100644 --- a/src/main/java/com/hbm/blocks/ModBlocks.java +++ b/src/main/java/com/hbm/blocks/ModBlocks.java @@ -896,6 +896,8 @@ public class ModBlocks { public static Block cm_tank; public static Block cm_circuit; public static Block cm_port; + public static Block cm_flux; + public static Block cm_heat; public static Block custom_machine; public static Block cm_anchor; @@ -2074,6 +2076,8 @@ public class ModBlocks { cm_tank = new BlockCMGlass(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_tank").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_tank"); cm_circuit = new BlockCM(Material.iron, EnumCMCircuit.class, true, true).setBlockName("cm_circuit").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_circuit"); cm_port = new BlockCMPort(Material.iron, EnumCMMaterials.class, true, true).setBlockName("cm_port").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_port"); + cm_flux = new BlockCMFlux(Material.iron, RefStrings.MODID + ":cm_flux_top").setBlockName("cm_flux").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_flux_side"); + cm_heat = new BlockCMHeat(Material.iron, RefStrings.MODID +":cm_heat_top").setBlockName("cm_heat").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F).setBlockTextureName(RefStrings.MODID + ":cm_heat_side"); custom_machine = new BlockCustomMachine().setBlockName("custom_machine").setCreativeTab(MainRegistry.machineTab).setLightLevel(1F).setHardness(5.0F).setResistance(10.0F); cm_anchor = new BlockCMAnchor().setBlockName("custom_machine_anchor").setCreativeTab(MainRegistry.machineTab).setHardness(5.0F).setResistance(10.0F); @@ -3450,6 +3454,8 @@ public class ModBlocks { register(cm_tank); register(cm_circuit); register(cm_port); + register(cm_flux); + register(cm_heat); register(cm_anchor); //PWR diff --git a/src/main/java/com/hbm/blocks/machine/BlockCMFlux.java b/src/main/java/com/hbm/blocks/machine/BlockCMFlux.java new file mode 100644 index 000000000..85f0d4725 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/BlockCMFlux.java @@ -0,0 +1,9 @@ +package com.hbm.blocks.machine; + +import net.minecraft.block.material.Material; + +public class BlockCMFlux extends BlockPillar{ + public BlockCMFlux(Material mat, String top) { + super(mat, top); + } +} diff --git a/src/main/java/com/hbm/blocks/machine/BlockCMHeat.java b/src/main/java/com/hbm/blocks/machine/BlockCMHeat.java new file mode 100644 index 000000000..f339fbb48 --- /dev/null +++ b/src/main/java/com/hbm/blocks/machine/BlockCMHeat.java @@ -0,0 +1,9 @@ +package com.hbm.blocks.machine; + +import net.minecraft.block.material.Material; + +public class BlockCMHeat extends BlockPillar{ + public BlockCMHeat(Material mat, String top) { + super(mat, top); + } +} diff --git a/src/main/java/com/hbm/config/CustomMachineConfigJSON.java b/src/main/java/com/hbm/config/CustomMachineConfigJSON.java index 359eb3db5..83fda4ef5 100644 --- a/src/main/java/com/hbm/config/CustomMachineConfigJSON.java +++ b/src/main/java/com/hbm/config/CustomMachineConfigJSON.java @@ -34,19 +34,19 @@ public class CustomMachineConfigJSON { public static final Gson gson = new Gson(); public static HashMap customMachines = new HashMap(); public static List niceList = new ArrayList(); - + public static void initialize() { File folder = MainRegistry.configHbmDir; File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmCustomMachines.json"); - + if(!config.exists()) { writeDefault(config); } - + readConfig(config); } - + public static void writeDefault(File config) { try { @@ -54,7 +54,7 @@ public class CustomMachineConfigJSON { writer.setIndent(" "); writer.beginObject(); writer.name("machines").beginArray(); - + writer.beginObject(); writer.name("recipeKey").value("paperPress"); writer.name("unlocalizedName").value("paperPress"); @@ -66,14 +66,17 @@ public class CustomMachineConfigJSON { writer.name("fluidOutCap").value(0); writer.name("itemOutCount").value(1); writer.name("generatorMode").value(false); + writer.name("maxPollutionCap").value(100); + writer.name("fluxMode").value(false); writer.name("recipeSpeedMult").value(1.0D); writer.name("recipeConsumptionMult").value(1.0D); writer.name("maxPower").value(10_000L); - + writer.name("maxHeat").value(0); + writer.name("recipeShape").beginArray(); writer.value("IPI").value("PCP").value("IPI"); writer.endArray(); - + writer.name("recipeParts").beginArray().setIndent(""); writer.value("I"); SerializableRecipe.writeAStack(new OreDictStack(OreDictManager.STEEL.ingot()), writer); @@ -84,9 +87,9 @@ public class CustomMachineConfigJSON { writer.value("C"); SerializableRecipe.writeAStack(new ComparableStack(ModItems.circuit_aluminium), writer); writer.endArray().setIndent(" "); - + writer.name("components").beginArray(); - + for(int x = -1; x <= 1; x++) { for(int y = -1; y <= 1; y++) { for(int z = 0; z <= 2; z++) { @@ -104,7 +107,7 @@ public class CustomMachineConfigJSON { } } } - + writer.beginObject().setIndent(""); writer.name("block").value("hbm:tile.cm_port"); writer.name("x").value(0); @@ -114,7 +117,7 @@ public class CustomMachineConfigJSON { writer.value(0); writer.endArray(); writer.endObject().setIndent(" "); - + writer.beginObject().setIndent(""); writer.name("block").value("hbm:tile.cm_port"); writer.name("x").value(0); @@ -124,10 +127,10 @@ public class CustomMachineConfigJSON { writer.value(0); writer.endArray(); writer.endObject().setIndent(" "); - + writer.endArray(); writer.endObject(); - + writer.endArray(); writer.endObject(); writer.close(); @@ -135,16 +138,16 @@ public class CustomMachineConfigJSON { e.printStackTrace(); } } - + public static void readConfig(File config) { - + try { JsonObject json = gson.fromJson(new FileReader(config), JsonObject.class); JsonArray machines = json.get("machines").getAsJsonArray(); - + for(int i = 0; i < machines.size(); i++) { JsonObject machineObject = machines.get(i).getAsJsonObject(); - + MachineConfiguration configuration = new MachineConfiguration(); configuration.recipeKey = machineObject.get("recipeKey").getAsString(); configuration.unlocalizedName = machineObject.get("unlocalizedName").getAsString(); @@ -156,45 +159,48 @@ public class CustomMachineConfigJSON { configuration.fluidOutCap = machineObject.get("fluidOutCap").getAsInt(); configuration.itemOutCount = machineObject.get("itemOutCount").getAsInt(); configuration.generatorMode = machineObject.get("generatorMode").getAsBoolean(); + configuration.maxPollutionCap = machineObject.get("maxPollutionCap").getAsInt(); + configuration.fluxMode = machineObject.get("fluxMode").getAsBoolean(); configuration.recipeSpeedMult = machineObject.get("recipeSpeedMult").getAsDouble(); configuration.recipeConsumptionMult = machineObject.get("recipeConsumptionMult").getAsDouble(); configuration.maxPower = machineObject.get("maxPower").getAsLong(); - + configuration.maxHeat = machineObject.get("maxHeat").getAsInt(); + if(machineObject.has("recipeShape") && machineObject.has("recipeParts")) { JsonArray recipeShape = machineObject.get("recipeShape").getAsJsonArray(); JsonArray recipeParts = machineObject.get("recipeParts").getAsJsonArray(); - + Object[] parts = new Object[recipeShape.size() + recipeParts.size()]; - + for(int j = 0; j < recipeShape.size(); j++) { parts[j] = recipeShape.get(j).getAsString(); } - + for(int j = 0; j < recipeParts.size(); j++) { Object o = null; - + if(j % 2 == 0) { o = recipeParts.get(j).getAsString().charAt(0); //god is dead and we killed him } else { AStack a = SerializableRecipe.readAStack(recipeParts.get(j).getAsJsonArray()); - + if(a instanceof ComparableStack) o = ((ComparableStack) a).toStack(); if(a instanceof OreDictStack) o = ((OreDictStack) a).name; } - + parts[j + recipeShape.size()] = o; } - + ItemStack stack = new ItemStack(ModBlocks.custom_machine, 1, i + 100); stack.stackTagCompound = new NBTTagCompound(); stack.stackTagCompound.setString("machineType", configuration.unlocalizedName); CraftingManager.addRecipeAuto(stack, parts); } - + JsonArray components = machineObject.get("components").getAsJsonArray(); configuration.components = new ArrayList(); - + for(int j = 0; j < components.size(); j++) { JsonObject compObject = components.get(j).getAsJsonObject(); ComponentDefinition compDef = new ComponentDefinition(); @@ -207,21 +213,21 @@ public class CustomMachineConfigJSON { for(int k = 0; k < compDef.metas.size(); k++) { compDef.allowedMetas.add(compDef.metas.get(k).getAsInt()); } - + configuration.components.add(compDef); } - + customMachines.put(configuration.unlocalizedName, configuration); niceList.add(configuration); } - + } catch(Exception ex) { ex.printStackTrace(); } } public static class MachineConfiguration { - + /** The name of the recipe set that this machine can handle */ public String recipeKey; /** The internal name of this machine */ @@ -237,14 +243,17 @@ public class CustomMachineConfigJSON { public int itemOutCount; /** Whether inputs should be used up when the process begins */ public boolean generatorMode; - + public int maxPollutionCap; + public boolean fluxMode; public double recipeSpeedMult = 1D; public double recipeConsumptionMult = 1D; public long maxPower; - + public int maxHeat; + + /** Definitions of blocks that this machine is composed of */ public List components; - + public static class ComponentDefinition { public Block block; public Set allowedMetas; diff --git a/src/main/java/com/hbm/handler/nei/CustomMachineHandler.java b/src/main/java/com/hbm/handler/nei/CustomMachineHandler.java index 844af6e60..d691bf27a 100644 --- a/src/main/java/com/hbm/handler/nei/CustomMachineHandler.java +++ b/src/main/java/com/hbm/handler/nei/CustomMachineHandler.java @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import codechicken.lib.gui.GuiDraw; import com.hbm.blocks.ModBlocks; import com.hbm.config.CustomMachineConfigJSON; import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration; @@ -25,10 +26,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; public class CustomMachineHandler extends TemplateRecipeHandler { - + public LinkedList transferRectsRec = new LinkedList(); public LinkedList> guiRec = new LinkedList>(); - + public MachineConfiguration conf; @Override @@ -39,20 +40,25 @@ public class CustomMachineHandler extends TemplateRecipeHandler { throw new RuntimeException(e); } } - + public CustomMachineHandler(MachineConfiguration conf) { super(); this.conf = conf; loadTransferRects(); RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects); } - + public class RecipeSet extends TemplateRecipeHandler.CachedRecipe { List inputs = new ArrayList(); PositionedStack machine; List outputs = new ArrayList(); - + public int flux = 0; + public int heat = 0; + public float radiationAmount = 0; + public String pollutionType; + public float pollutionAmount = 0; + public RecipeSet(CustomMachineRecipe recipe) { for(int i = 0; i < 3; i++) if(recipe.inputFluids.length > i) inputs.add(new PositionedStack(ItemFluidIcon.make(recipe.inputFluids[i]), 12 + i * 18, 6)); @@ -60,7 +66,7 @@ public class CustomMachineHandler extends TemplateRecipeHandler { for(int i = 3; i < 6; i++) if(recipe.inputItems.length > i) inputs.add(new PositionedStack(recipe.inputItems[i].extractForNEI(), 12 + (i - 3) * 18, 42)); for(int i = 0; i < 3; i++) if(recipe.outputFluids.length > i) outputs.add(new PositionedStack(ItemFluidIcon.make(recipe.outputFluids[i]), 102 + i * 18, 6)); - + for(int i = 0; i < 3; i++) if(recipe.outputItems.length > i) { Pair pair = recipe.outputItems[i]; ItemStack out = pair.getKey().copy(); @@ -69,7 +75,7 @@ public class CustomMachineHandler extends TemplateRecipeHandler { } outputs.add(new PositionedStack(out, 102 + i * 18, 24)); } - + for(int i = 3; i < 6; i++) if(recipe.outputItems.length > i) { Pair pair = recipe.outputItems[i]; ItemStack out = pair.getKey().copy(); @@ -78,7 +84,13 @@ public class CustomMachineHandler extends TemplateRecipeHandler { } outputs.add(new PositionedStack(out, 102 + (i - 3) * 18, 42)); } - + if(recipe.pollutionMode) { + this.pollutionType = recipe.pollutionType; + this.pollutionAmount = recipe.pollutionAmount; + } + if(recipe.radiationMode) this.radiationAmount = recipe.radiationAmount; + if(conf.fluxMode) this.flux = recipe.flux; + if(conf.maxHeat>0 && recipe.heat>0) this.heat = recipe.heat; this.machine = new PositionedStack(new ItemStack(ModBlocks.custom_machine, 1, 100 + CustomMachineConfigJSON.niceList.indexOf(conf)), 75, 42); } @@ -111,14 +123,14 @@ public class CustomMachineHandler extends TemplateRecipeHandler { public String getGuiTexture() { return RefStrings.MODID + ":textures/gui/nei/gui_nei_custom.png"; } - + @Override public void loadCraftingRecipes(String outputId, Object... results) { - + if(outputId.equals("ntm_" + conf.unlocalizedName)) { - + List recipes = CustomMachineRecipes.recipes.get(conf.recipeKey); - + if(recipes != null) for(CustomMachineRecipe recipe : recipes) { this.arecipes.add(new RecipeSet(recipe)); } @@ -126,25 +138,25 @@ public class CustomMachineHandler extends TemplateRecipeHandler { super.loadCraftingRecipes(outputId, results); } } - + @Override public void loadCraftingRecipes(ItemStack result) { - + List recipes = CustomMachineRecipes.recipes.get(conf.recipeKey); - + if(recipes != null) outer:for(CustomMachineRecipe recipe : recipes) { - + for(Pair stack : recipe.outputItems) { - + if(NEIServerUtils.areStacksSameTypeCrafting(stack.getKey(), result)) { this.arecipes.add(new RecipeSet(recipe)); continue outer; } } - + for(FluidStack fluid : recipe.outputFluids) { ItemStack drop = ItemFluidIcon.make(fluid); - + if(compareFluidStacks(result, drop)) { this.arecipes.add(new RecipeSet(recipe)); continue outer; @@ -152,28 +164,28 @@ public class CustomMachineHandler extends TemplateRecipeHandler { } } } - + @Override public void loadUsageRecipes(String inputId, Object... ingredients) { - + if(inputId.equals("ntm_" + conf.unlocalizedName)) { loadCraftingRecipes("ntm_" + conf.unlocalizedName, new Object[0]); } else { super.loadUsageRecipes(inputId, ingredients); } } - + @Override public void loadUsageRecipes(ItemStack ingredient) { - + List recipes = CustomMachineRecipes.recipes.get(conf.recipeKey); if(recipes != null) outer:for(CustomMachineRecipe recipe : recipes) { - + for(AStack stack : recipe.inputItems) { - + List stacks = stack.extractForNEI(); - + for(ItemStack sta : stacks) { if(NEIServerUtils.areStacksSameTypeCrafting(ingredient, sta)) { this.arecipes.add(new RecipeSet(recipe)); @@ -181,10 +193,10 @@ public class CustomMachineHandler extends TemplateRecipeHandler { } } } - + for(FluidStack fluid : recipe.inputFluids) { ItemStack drop = ItemFluidIcon.make(fluid); - + if(compareFluidStacks(ingredient, drop)) { this.arecipes.add(new RecipeSet(recipe)); continue outer; @@ -196,11 +208,32 @@ public class CustomMachineHandler extends TemplateRecipeHandler { public static boolean compareFluidStacks(ItemStack sta1, ItemStack sta2) { return sta1.getItem() == sta2.getItem() && sta1.getItemDamage() == sta2.getItemDamage(); } - + @Override public void loadTransferRects() { if(this.conf == null) return; transferRects.add(new RecipeTransferRect(new Rectangle(65, 23, 36, 18), "ntm_" + conf.unlocalizedName)); RecipeTransferRectHandler.registerRectsToGuis(getRecipeTransferRectGuis(), transferRects); } + @Override + public void drawExtras(int recipe) { + RecipeSet Recipe = (RecipeSet) this.arecipes.get(recipe); + int side = 83; + if(Recipe.radiationAmount != 0){ + String radiation = "Radiation:" + Recipe.radiationAmount + ""; + GuiDraw.drawString(radiation, 160 - GuiDraw.fontRenderer.getStringWidth(radiation), 63, 0x08FF00); + } + if (Recipe.pollutionAmount != 0){ + String pollution = Recipe.pollutionType + ":" + Recipe.pollutionAmount + ""; + GuiDraw.drawString(pollution, 160 - GuiDraw.fontRenderer.getStringWidth(pollution), 75, 0x404040); + } + if(conf.fluxMode) { + String flux = "Flux:" + Recipe.flux + ""; + GuiDraw.drawString(flux, side - GuiDraw.fontRenderer.getStringWidth(flux) / 2, 16, 0x08FF00); + } + if(conf.maxHeat>0 && Recipe.heat>0){ + String heat = "Heat:" + Recipe.heat + ""; + GuiDraw.drawString(heat, side - GuiDraw.fontRenderer.getStringWidth(heat) / 2, 8, 0xFF0000); + } + } } diff --git a/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java b/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java index 7b658c150..dcfb6effd 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java +++ b/src/main/java/com/hbm/inventory/gui/GUIMachineCustom.java @@ -1,7 +1,9 @@ package com.hbm.inventory.gui; import java.util.Arrays; +import java.util.Locale; +import com.hbm.render.util.GaugeUtil; import org.lwjgl.opengl.GL11; import com.hbm.inventory.SlotPattern; @@ -17,58 +19,59 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; public class GUIMachineCustom extends GuiInfoContainer { - + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/processing/gui_custom.png"); private TileEntityCustomMachine custom; public GUIMachineCustom(InventoryPlayer invPlayer, TileEntityCustomMachine tedf) { super(new ContainerMachineCustom(invPlayer, tedf)); custom = tedf; - + this.xSize = 176; this.ySize = 256; } - + @Override public void drawScreen(int x, int y, float interp) { super.drawScreen(x, y, interp); - - this.drawElectricityInfo(this, x, y, guiLeft + 150, guiTop + 18, 16, 52, custom.power, custom.config.maxPower); + this.drawElectricityInfo(this, x, y, guiLeft + 150, guiTop + 18, 16, 52, custom.power, custom.config.maxPower); + if(custom.config.maxHeat>0) this.drawCustomInfoStat(x, y, guiLeft + 61, guiTop + 53, 18, 18, x, y, new String[] { "Heat:" + String.format(Locale.US, "%,d", custom.heat) + " / " + String.format(Locale.US, "%,d", custom.config.maxHeat)}); if(this.mc.thePlayer.inventory.getItemStack() == null) { for(int i = 0; i < this.inventorySlots.inventorySlots.size(); ++i) { Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i); int tileIndex = slot.getSlotIndex(); - + if(this.isMouseOverSlot(slot, x, y) && slot instanceof SlotPattern && custom.matcher.modes[tileIndex - 10] != null) { - + String label = EnumChatFormatting.YELLOW + ""; - + switch(custom.matcher.modes[tileIndex - 10]) { - case "exact": label += "Item and meta match"; break; - case "wildcard": label += "Item matches"; break; - default: label += "Ore dict key matches: " + custom.matcher.modes[tileIndex - 10]; break; + case "exact": label += "Item and meta match"; break; + case "wildcard": label += "Item matches"; break; + default: label += "Ore dict key matches: " + custom.matcher.modes[tileIndex - 10]; break; } - + this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30); } } } - + for(int i = 0; i < custom.inputTanks.length; i++) { custom.inputTanks[i].renderTankInfo(this, x, y, guiLeft + 8 + 18 * i, guiTop + 18, 16, 34); } - + for(int i = 0; i < custom.outputTanks.length; i++) { custom.outputTanks[i].renderTankInfo(this, x, y, guiLeft + 78 + 18 * i, guiTop + 18, 16, 34); } } - + @Override protected void drawGuiContainerForegroundLayer(int i, int j) { String name = this.custom.getInventoryName(); this.fontRendererObj.drawString(name, 68 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752); this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + if(custom.config.fluxMode) this.fontRendererObj.drawString("Flux:" + custom.flux,83, 57,0x08FF00); } @Override @@ -76,17 +79,23 @@ public class GUIMachineCustom extends GuiInfoContainer { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - + if(custom.config.fluxMode){ + drawTexturedModalRect(guiLeft + 78, guiTop + 54, 192, 122,51 , 15); + } + if(custom.maxHeat>0) { + drawTexturedModalRect(guiLeft + 61, guiTop + 53, 236,0 , 18, 18); + GaugeUtil.drawSmoothGauge(guiLeft + 70, guiTop + 62, this.zLevel, (double) custom.heat / (double) custom.config.maxHeat, 5, 2, 1, 0x7F0000); + } int p = custom.progress * 90 / custom.maxProgress; drawTexturedModalRect(guiLeft + 78, guiTop + 119, 192, 0, Math.min(p, 44), 16); if(p > 44) { p-= 44; drawTexturedModalRect(guiLeft + 78 + 44, guiTop + 119, 192, 16, p, 16); } - + int e = (int) (custom.power * 52 / custom.config.maxPower); drawTexturedModalRect(guiLeft + 150, guiTop + 70 - e, 176, 52 - e, 16, e); - + for(int i = 0; i < 2; i++) { for(int j = 0; j < 3; j++) { int index = i * 3 + j; @@ -99,7 +108,7 @@ public class GUIMachineCustom extends GuiInfoContainer { } } } - + for(int i = 0; i < 3; i++) { if(custom.config.fluidInCount <= i) { drawTexturedModalRect(guiLeft + 7 + i * 18, guiTop + 17, 192 + i * 18, 32, 18, 54); @@ -108,11 +117,11 @@ public class GUIMachineCustom extends GuiInfoContainer { drawTexturedModalRect(guiLeft + 77 + i * 18, guiTop + 17, 192 + i * 18, 32, 18, 36); } } - + for(int i = 0; i < custom.inputTanks.length; i++) { custom.inputTanks[i].renderTank(guiLeft + 8 + 18 * i, guiTop + 52, this.zLevel, 16, 34); } - + for(int i = 0; i < custom.outputTanks.length; i++) { custom.outputTanks[i].renderTank(guiLeft + 78 + 18 * i, guiTop + 52, this.zLevel, 16, 34); } diff --git a/src/main/java/com/hbm/inventory/recipes/CustomMachineRecipes.java b/src/main/java/com/hbm/inventory/recipes/CustomMachineRecipes.java index e3fe13cef..965593025 100644 --- a/src/main/java/com/hbm/inventory/recipes/CustomMachineRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/CustomMachineRecipes.java @@ -22,12 +22,12 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; public class CustomMachineRecipes extends SerializableRecipe { - + public static HashMap> recipes = new HashMap(); @Override public void registerDefaults() { - + recipes.put("paperPress", new ArrayList() {{ CustomMachineRecipe recipe = new CustomMachineRecipe(); recipe.inputFluids = new FluidStack[] {new FluidStack(Fluids.WATER, 250)}; @@ -36,6 +36,13 @@ public class CustomMachineRecipes extends SerializableRecipe { recipe.outputItems = new Pair[] {new Pair(new ItemStack(Items.paper, 3), 1F)}; recipe.duration = 60; recipe.consumptionPerTick = 10; + recipe.pollutionMode = true; + recipe.pollutionType = "SOOT"; + recipe.pollutionAmount = 0.03f; + recipe.radiationMode = false; + recipe.radiationAmount = 0; + recipe.flux = 0; + recipe.heat = 0; add(recipe); }}); } @@ -58,11 +65,11 @@ public class CustomMachineRecipes extends SerializableRecipe { @Override public void readRecipe(JsonElement recipe) { JsonObject obj = recipe.getAsJsonObject(); - + String name = obj.get("recipeKey").getAsString(); List list = new ArrayList(); JsonArray array = obj.get("recipes").getAsJsonArray(); - + for(int i = 0; i < array.size(); i++) { JsonObject rec = array.get(i).getAsJsonObject(); CustomMachineRecipe recipeInstance = new CustomMachineRecipe(); @@ -72,56 +79,79 @@ public class CustomMachineRecipes extends SerializableRecipe { recipeInstance.outputItems = this.readItemStackArrayChance(rec.get("outputItems").getAsJsonArray()); recipeInstance.duration = rec.get("duration").getAsInt(); recipeInstance.consumptionPerTick = rec.get("consumptionPerTick").getAsInt(); + recipeInstance.pollutionMode = rec.get("pollutionMode").getAsBoolean(); + recipeInstance.pollutionType = rec.get("pollutionType").getAsString(); + recipeInstance.pollutionAmount = rec.get("pollutionAmount").getAsFloat(); + recipeInstance.radiationMode = rec.get("radiationMode").getAsBoolean(); + recipeInstance.radiationAmount = rec.get("radiationAmount").getAsFloat(); + recipeInstance.flux = rec.get("flux").getAsInt(); + recipeInstance.heat = rec.get("heat").getAsInt(); + list.add(recipeInstance); } - + recipes.put(name, list); } @Override public void writeRecipe(Object recipe, JsonWriter writer) throws IOException { Entry> entry = (Entry) recipe; - + writer.name("recipeKey").value(entry.getKey()); writer.name("recipes").beginArray(); - + for(CustomMachineRecipe recipeInstance : entry.getValue()) { writer.beginObject(); - + writer.name("inputFluids").beginArray(); for(FluidStack stack : recipeInstance.inputFluids) this.writeFluidStack(stack, writer); writer.endArray(); - + writer.name("inputItems").beginArray(); for(AStack stack : recipeInstance.inputItems) this.writeAStack(stack, writer); writer.endArray(); - + writer.name("outputFluids").beginArray(); for(FluidStack stack : recipeInstance.outputFluids) this.writeFluidStack(stack, writer); writer.endArray(); - + writer.name("outputItems").beginArray(); for(Pair stack : recipeInstance.outputItems) this.writeItemStackChance(stack, writer); writer.endArray(); writer.name("duration").value(recipeInstance.duration); writer.name("consumptionPerTick").value(recipeInstance.consumptionPerTick); - + writer.name("pollutionMode").value(recipeInstance.pollutionMode); + writer.name("pollutionType").value(recipeInstance.pollutionType); + writer.name("pollutionAmount").value(recipeInstance.pollutionAmount); + writer.name("radiationMode").value(recipeInstance.radiationMode); + writer.name("radiationnAmount").value(recipeInstance.radiationAmount); + writer.name("flux").value(recipeInstance.flux); + writer.name("heat").value(recipeInstance.heat); + writer.endObject(); } - + writer.endArray(); } - + public static class CustomMachineRecipe { - + public FluidStack[] inputFluids; public AStack[] inputItems; public FluidStack[] outputFluids; public Pair[] outputItems; - + public int duration; public int consumptionPerTick; + public boolean pollutionMode; + + public String pollutionType; + public float pollutionAmount; + public boolean radiationMode; + public float radiationAmount; + public int flux; + public int heat; } } diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index 9203ee542..a7b6638f9 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -1166,6 +1166,8 @@ public class CraftingManager { addRecipeAuto(new ItemStack(ModBlocks.cm_circuit, 1, 2), " I ", "IMI", " I ", 'I', STEEL.ingot(), 'M', ModItems.circuit_red_copper); addRecipeAuto(new ItemStack(ModBlocks.cm_circuit, 1, 3), " I ", "IMI", " I ", 'I', STEEL.ingot(), 'M', ModItems.circuit_gold); addRecipeAuto(new ItemStack(ModBlocks.cm_circuit, 1, 4), " I ", "IMI", " I ", 'I', STEEL.ingot(), 'M', ModItems.circuit_schrabidium); + addRecipeAuto(new ItemStack(ModBlocks.cm_flux, 1, 0), "NZN", "ZCZ", "NZN", 'Z', ZR.plateCast(), 'N', ModItems.neutron_reflector, 'C', ModItems.reactor_core); + addRecipeAuto(new ItemStack(ModBlocks.cm_heat, 1, 0), "PCP", "PSP", "PCP", 'P', ANY_PLASTIC.ingot(), 'C', ModItems.board_copper, 'S', ModItems.pipes_steel); } public static void crumple() { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java b/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java index 9c906623d..32c47c893 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityCustomMachine.java @@ -3,9 +3,14 @@ package com.hbm.tileentity.machine; import java.util.ArrayList; import java.util.List; +import api.hbm.tile.IHeatSource; +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.machine.ReactorResearch; import com.hbm.config.CustomMachineConfigJSON; import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration; import com.hbm.config.CustomMachineConfigJSON.MachineConfiguration.ComponentDefinition; +import com.hbm.handler.pollution.PollutionHandler; +import com.hbm.handler.radiation.ChunkRadiationManager; import com.hbm.inventory.container.ContainerMachineCustom; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; @@ -15,7 +20,7 @@ import com.hbm.inventory.recipes.CustomMachineRecipes.CustomMachineRecipe; import com.hbm.lib.Library; import com.hbm.module.ModulePatternMatcher; import com.hbm.tileentity.IGUIProvider; -import com.hbm.tileentity.TileEntityMachineBase; +import com.hbm.tileentity.TileEntityMachinePolluting; import com.hbm.tileentity.TileEntityProxyBase; import com.hbm.util.Compat; import com.hbm.util.fauxpointtwelve.BlockPos; @@ -35,12 +40,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityCustomMachine extends TileEntityMachineBase implements IFluidStandardTransceiver, IEnergyUser, IGUIProvider { - +public class TileEntityCustomMachine extends TileEntityMachinePolluting implements IFluidStandardTransceiver, IEnergyUser, IGUIProvider { + public String machineType; public MachineConfiguration config; - + public long power; + public int flux; + public int heat; + public int maxHeat; public int progress; public int maxProgress = 1; public FluidTank[] inputTanks; @@ -49,8 +57,10 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF public int structureCheckDelay; public boolean structureOK = false; public CustomMachineRecipe cachedRecipe; - + public List connectionPos = new ArrayList(); + public List fluxPos = new ArrayList(); + public List heatPos = new ArrayList(); public TileEntityCustomMachine() { /* @@ -60,22 +70,26 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF * 10-15: Template * 16-21: Output */ - super(22); + super(22, 100); } - + public void init() { MachineConfiguration config = CustomMachineConfigJSON.customMachines.get(this.machineType); - - if(config != null) { + + if (config != null) { this.config = config; inputTanks = new FluidTank[config.fluidInCount]; - for(int i = 0; i < inputTanks.length; i++) inputTanks[i] = new FluidTank(Fluids.NONE, config.fluidInCap); + for (int i = 0; i < inputTanks.length; i++) inputTanks[i] = new FluidTank(Fluids.NONE, config.fluidInCap); outputTanks = new FluidTank[config.fluidOutCount]; - for(int i = 0; i < outputTanks.length; i++) outputTanks[i] = new FluidTank(Fluids.NONE, config.fluidOutCap); - + for (int i = 0; i < outputTanks.length; i++) + outputTanks[i] = new FluidTank(Fluids.NONE, config.fluidOutCap); + maxHeat = config.maxHeat; matcher = new ModulePatternMatcher(config.itemInCount); - + smoke.changeTankSize(config.maxPollutionCap); + smoke_leaded.changeTankSize(config.maxPollutionCap); + smoke_poison.changeTankSize(config.maxPollutionCap); + } else { worldObj.func_147480_a(xCoord, yCoord, zCoord, false); } @@ -88,75 +102,112 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF @Override public void updateEntity() { - - if(!worldObj.isRemote) { - - if(config == null) { + + if (!worldObj.isRemote) { + + if (config == null) { worldObj.func_147480_a(xCoord, yCoord, zCoord, false); return; } this.power = Library.chargeTEFromItems(slots, 0, power, this.config.maxPower); - - if(this.inputTanks.length > 0) this.inputTanks[0].setType(1, slots); - if(this.inputTanks.length > 1) this.inputTanks[1].setType(2, slots); - if(this.inputTanks.length > 2) this.inputTanks[2].setType(3, slots); - + + if (this.inputTanks.length > 0) this.inputTanks[0].setType(1, slots); + if (this.inputTanks.length > 1) this.inputTanks[1].setType(2, slots); + if (this.inputTanks.length > 2) this.inputTanks[2].setType(3, slots); + this.structureCheckDelay--; - if(this.structureCheckDelay <= 0) this.checkStructure(); - - if(this.worldObj.getTotalWorldTime() % 20 == 0) { - for(DirPos pos : this.connectionPos) { - for(FluidTank tank : this.inputTanks) { + if (this.structureCheckDelay <= 0) this.checkStructure(); + + if (this.worldObj.getTotalWorldTime() % 20 == 0) { + for (DirPos pos : this.connectionPos) { + for (FluidTank tank : this.inputTanks) { this.trySubscribe(tank.getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); } - if(!config.generatorMode) this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + if (!config.generatorMode) + this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + } + for (byte d = 2; d < 6; d++) { + ForgeDirection dir = ForgeDirection.getOrientation(d); + for (DirPos pos : this.fluxPos) { + Block b = worldObj.getBlock(pos.getX() + dir.offsetX, pos.getY(), pos.getZ() + dir.offsetZ); + if (b == ModBlocks.reactor_research) { + int[] source = ((ReactorResearch) ModBlocks.reactor_research).findCore(worldObj, pos.getX() + dir.offsetX, pos.getY(), pos.getZ() + dir.offsetZ); + if (source != null) { + + TileEntity tile = worldObj.getTileEntity(source[0], source[1], source[2]); + + if (tile instanceof TileEntityReactorResearch) { + + TileEntityReactorResearch reactor = (TileEntityReactorResearch) tile; + this.flux = reactor.totalFlux; + } + } + } + } + if(config.maxHeat>0){ + for (DirPos pos : this.heatPos){ + this.tryPullHeat(pos.getX() + dir.offsetX, pos.getY()-1, pos.getZ() + dir.offsetZ); + } + } } } - - for(DirPos pos : this.connectionPos) { - if(config.generatorMode && power > 0) this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); - for(FluidTank tank : this.outputTanks) if(tank.getFill() > 0) this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + + for (DirPos pos : this.connectionPos) { + if (config.generatorMode && power > 0) + this.sendPower(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + for (FluidTank tank : this.outputTanks) + if (tank.getFill() > 0) + this.sendFluid(tank, worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); + this.sendSmoke(pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); } - - if(this.structureOK) { - - if(config.generatorMode) { - if(this.cachedRecipe == null) { + + if (this.structureOK) { + + if (config.generatorMode) { + if (this.cachedRecipe == null) { CustomMachineRecipe recipe = this.getMatchingRecipe(); - if(recipe != null && this.hasRequiredQuantities(recipe) && this.hasSpace(recipe)) { + if (recipe != null && this.hasRequiredQuantities(recipe) && this.hasSpace(recipe)) { this.cachedRecipe = recipe; this.useUpInput(recipe); } } - - if(this.cachedRecipe != null) { + + if (this.cachedRecipe != null) { this.maxProgress = (int) Math.max(cachedRecipe.duration / this.config.recipeSpeedMult, 1); int powerReq = (int) Math.max(cachedRecipe.consumptionPerTick * this.config.recipeConsumptionMult, 1); - + this.progress++; this.power += powerReq; - if(power > config.maxPower) power = config.maxPower; - - if(progress >= this.maxProgress) { + this.heat -= cachedRecipe.heat; + if (power > config.maxPower) power = config.maxPower; + if (worldObj.getTotalWorldTime() % 20 == 0) { + pollution(cachedRecipe); + radiation(cachedRecipe); + } + if (progress >= this.maxProgress) { this.progress = 0; this.processRecipe(cachedRecipe); this.cachedRecipe = null; } } - + } else { CustomMachineRecipe recipe = this.getMatchingRecipe(); - - if(recipe != null) { + + if (recipe != null) { this.maxProgress = (int) Math.max(recipe.duration / this.config.recipeSpeedMult, 1); int powerReq = (int) Math.max(recipe.consumptionPerTick * this.config.recipeConsumptionMult, 1); - - if(this.power >= powerReq && this.hasRequiredQuantities(recipe) && this.hasSpace(recipe)) { + + if (this.power >= powerReq && this.hasRequiredQuantities(recipe) && this.hasSpace(recipe)) { this.progress++; this.power -= powerReq; - - if(progress >= this.maxProgress) { + this.heat -= recipe.heat; + if (worldObj.getTotalWorldTime() % 20 == 0) { + pollution(recipe); + radiation(recipe); + } + if (progress >= this.maxProgress) { this.progress = 0; this.useUpInput(recipe); this.processRecipe(recipe); @@ -169,89 +220,129 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF } else { this.progress = 0; } - + NBTTagCompound data = new NBTTagCompound(); data.setString("type", this.machineType); data.setLong("power", power); data.setBoolean("structureOK", structureOK); + data.setInteger("flux", flux); + data.setInteger("heat", heat); data.setInteger("progress", progress); data.setInteger("maxProgress", maxProgress); - for(int i = 0; i < inputTanks.length; i++) inputTanks[i].writeToNBT(data, "i" + i); - for(int i = 0; i < outputTanks.length; i++) outputTanks[i].writeToNBT(data, "o" + i); + for (int i = 0; i < inputTanks.length; i++) inputTanks[i].writeToNBT(data, "i" + i); + for (int i = 0; i < outputTanks.length; i++) outputTanks[i].writeToNBT(data, "o" + i); this.matcher.writeToNBT(data); this.networkPack(data, 50); } + } - + /** Only accepts inputs in a fixed order, saves a ton of performance because there's no permutations to check for */ public CustomMachineRecipe getMatchingRecipe() { List recipes = CustomMachineRecipes.recipes.get(this.config.recipeKey); if(recipes == null || recipes.isEmpty()) return null; - + outer: for(CustomMachineRecipe recipe : recipes) { for(int i = 0; i < recipe.inputFluids.length; i++) { if(this.inputTanks[i].getTankType() != recipe.inputFluids[i].type || this.inputTanks[i].getPressure() != recipe.inputFluids[i].pressure) continue outer; } - + for(int i = 0; i < recipe.inputItems.length; i++) { if(recipe.inputItems[i] != null && slots[i + 4] == null) continue outer; if(!recipe.inputItems[i].matchesRecipe(slots[i + 4], true)) continue outer; } - + return recipe; } - + return null; } - + public void pollution(CustomMachineRecipe recipe) { + if (recipe.pollutionMode) { + if (recipe.pollutionAmount > 0) { + this.pollute(PollutionHandler.PollutionType.valueOf(recipe.pollutionType), recipe.pollutionAmount); + } else if (recipe.pollutionAmount < 0 && PollutionHandler.getPollution(worldObj, xCoord, yCoord, zCoord, PollutionHandler.PollutionType.valueOf(recipe.pollutionType)) >= -recipe.pollutionAmount) { + PollutionHandler.decrementPollution(worldObj, xCoord, yCoord, zCoord, PollutionHandler.PollutionType.valueOf(recipe.pollutionType), -recipe.pollutionAmount); + } + } + } + public void radiation(CustomMachineRecipe recipe){ + if (recipe.radiationMode) { + if (recipe.radiationAmount > 0) { + ChunkRadiationManager.proxy.incrementRad(worldObj, xCoord, yCoord, zCoord, recipe.radiationAmount); + } else if (recipe.radiationAmount < 0) { + ChunkRadiationManager.proxy.decrementRad(worldObj, xCoord, yCoord, zCoord, -recipe.radiationAmount); + } + } + } + protected void tryPullHeat(int x, int y, int z) { + TileEntity con = worldObj.getTileEntity(x, y, z); + + if(con instanceof IHeatSource) { + IHeatSource source = (IHeatSource) con; + int diff = source.getHeatStored() - this.heat; + + if(diff == 0) { + return; + } + + if(diff > 0) { + source.useUpHeat(diff); + this.heat += diff; + if(this.heat > this.maxHeat) + this.heat = this.maxHeat; + } + } + } public boolean hasRequiredQuantities(CustomMachineRecipe recipe) { - + for(int i = 0; i < recipe.inputFluids.length; i++) { if(this.inputTanks[i].getFill() < recipe.inputFluids[i].fill) return false; } - + for(int i = 0; i < recipe.inputItems.length; i++) { if(slots[i + 4] != null && slots[i + 4].stackSize < recipe.inputItems[i].stacksize) return false; } - + if(config.fluxMode ? this.flux < recipe.flux : false) return false; + if(config.maxHeat>0 && recipe.heat>0 ? this.heat < recipe.heat : false) return false; return true; } - + public boolean hasSpace(CustomMachineRecipe recipe) { - + for(int i = 0; i < recipe.outputFluids.length; i++) { if(this.outputTanks[i].getTankType() == recipe.outputFluids[i].type && this.outputTanks[i].getFill() + recipe.outputFluids[i].fill > this.outputTanks[i].getMaxFill()) return false; } - + for(int i = 0; i < recipe.outputItems.length; i++) { if(slots[i + 16] != null && (slots[i + 16].getItem() != recipe.outputItems[i].key.getItem() || slots[i + 16].getItemDamage() != recipe.outputItems[i].key.getItemDamage())) return false; if(slots[i + 16] != null && slots[16 + i].stackSize + recipe.outputItems[i].key.stackSize > slots[i + 16].getMaxStackSize()) return false; } - + return true; } - + public void useUpInput(CustomMachineRecipe recipe) { - + for(int i = 0; i < recipe.inputFluids.length; i++) { this.inputTanks[i].setFill(this.inputTanks[i].getFill() - recipe.inputFluids[i].fill); } - + for(int i = 0; i < recipe.inputItems.length; i++) { this.decrStackSize(i + 4, recipe.inputItems[i].stacksize); } } - + public void processRecipe(CustomMachineRecipe recipe) { - + for(int i = 0; i < recipe.outputFluids.length; i++) { if(this.outputTanks[i].getTankType() != recipe.outputFluids[i].type) this.outputTanks[i].setTankType(recipe.outputFluids[i].type); this.outputTanks[i].setFill(this.outputTanks[i].getFill() + recipe.outputFluids[i].fill); } - + for(int i = 0; i < recipe.outputItems.length; i++) { - + if(worldObj.rand.nextFloat() < recipe.outputItems[i].value) { if(slots[i + 16] == null) { slots[i + 16] = recipe.outputItems[i].key.copy(); @@ -261,19 +352,18 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF } } } - + public boolean checkStructure() { - + this.connectionPos.clear(); this.structureCheckDelay = 300; this.structureOK = false; if(this.config == null) return false; - + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); ForgeDirection rot = dir.getRotation(ForgeDirection.UP); - for(ComponentDefinition comp : config.components) { - + /* vvv precisely the same method used for defining ports vvv */ int x = xCoord - dir.offsetX * comp.x + rot.offsetX * comp.x; int y = yCoord + comp.y; @@ -285,42 +375,52 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF z = zCoord + dir.offsetX * comp.x - rot.offsetX * comp.x; } /* i wholeheartedly believe it is the computer who is wrong here */ - + Block b = worldObj.getBlock(x, y, z); if(b != comp.block) return false; - + int meta = worldObj.getBlockMetadata(x, y, z); if(!comp.allowedMetas.contains(meta)) return false; - + TileEntity tile = Compat.getTileStandard(worldObj, x, y, z); if(tile instanceof TileEntityProxyBase) { TileEntityProxyBase proxy = (TileEntityProxyBase) tile; proxy.cachedPosition = new BlockPos(xCoord, yCoord, zCoord); proxy.markDirty(); - + for(ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) { this.connectionPos.add(new DirPos(x + facing.offsetX, y + facing.offsetY, z + facing.offsetZ, facing)); } } + if(worldObj.getBlock(x,y,z) == ModBlocks.cm_flux){ + for(ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) { + this.fluxPos.add(new DirPos(x + facing.offsetX, y + facing.offsetY, z + facing.offsetZ, facing)); + } + } + else if(worldObj.getBlock(x,y,z) == ModBlocks.cm_heat){ + for(ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) { + this.heatPos.add(new DirPos(x + facing.offsetX, y + facing.offsetY, z + facing.offsetZ, facing)); + } + } + } - for(ForgeDirection facing : ForgeDirection.VALID_DIRECTIONS) { this.connectionPos.add(new DirPos(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ, facing)); } - + this.structureOK = true; return true; } - + public void buildStructure() { - + if(this.config == null) return; - + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()); ForgeDirection rot = dir.getRotation(ForgeDirection.UP); - + for(ComponentDefinition comp : config.components) { - + int x = xCoord - dir.offsetX * comp.x + rot.offsetX * comp.x; int y = yCoord + comp.y; int z = zCoord - dir.offsetZ * comp.z + rot.offsetZ * comp.z; @@ -328,7 +428,7 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF x = xCoord + dir.offsetZ * comp.z - rot.offsetZ * comp.z; z = zCoord + dir.offsetX * comp.x - rot.offsetX * comp.x; } - + worldObj.setBlock(x, y, z, comp.block, (int) comp.allowedMetas.toArray()[0], 3); } } @@ -353,12 +453,12 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if(slot < 4 || slot > 9) return false; - + int index = slot - 4; int filterSlot = slot + 6; - + if(slots[filterSlot] == null) return true; - + return matcher.isValidForFilter(slots[filterSlot], index, stack); } @@ -366,56 +466,58 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF public void networkUnpack(NBTTagCompound nbt) { this.machineType = nbt.getString("type"); if(this.config == null) this.init(); - + this.power = nbt.getLong("power"); this.progress = nbt.getInteger("progress"); + this.flux = nbt.getInteger("flux"); + this.heat = nbt.getInteger("heat"); this.structureOK = nbt.getBoolean("structureOK"); this.maxProgress = nbt.getInteger("maxProgress"); for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i); for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i); - + this.matcher.readFromNBT(nbt); } - + @Override public void readFromNBT(NBTTagCompound nbt) { - + this.machineType = nbt.getString("machineType"); this.init(); - + super.readFromNBT(nbt); - + if(this.config != null) { - + for(int i = 0; i < inputTanks.length; i++) inputTanks[i].readFromNBT(nbt, "i" + i); for(int i = 0; i < outputTanks.length; i++) outputTanks[i].readFromNBT(nbt, "o" + i); - + this.matcher.readFromNBT(nbt); - + int index = nbt.getInteger("cachedIndex"); if(index != -1) { this.cachedRecipe = CustomMachineRecipes.recipes.get(this.config.recipeKey).get(index); } } } - + @Override public void writeToNBT(NBTTagCompound nbt) { - + if(machineType == null || this.config == null) { super.writeToNBT(nbt); return; } - + nbt.setString("machineType", machineType); - + super.writeToNBT(nbt); for(int i = 0; i < inputTanks.length; i++) inputTanks[i].writeToNBT(nbt, "i" + i); for(int i = 0; i < outputTanks.length; i++) outputTanks[i].writeToNBT(nbt, "o" + i); - + this.matcher.writeToNBT(nbt); - + if(this.cachedRecipe != null) { int index = CustomMachineRecipes.recipes.get(this.config.recipeKey).indexOf(this.cachedRecipe); nbt.setInteger("cachedIndex", index); @@ -426,18 +528,22 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF @Override public FluidTank[] getAllTanks() { - + FluidTank[] all = new FluidTank[inputTanks.length + outputTanks.length]; for(int i = 0; i < inputTanks.length; i++) all[i] = inputTanks[i]; for(int i = 0; i < outputTanks.length; i++) all[inputTanks.length + i] = outputTanks[i]; - + return all; } @Override public FluidTank[] getSendingTanks() { - return outputTanks != null ? outputTanks : new FluidTank[0]; + FluidTank[] all = new FluidTank[outputTanks.length + this.getSmokeTanks().length]; + for(int i = 0; i < outputTanks.length; i++) all[i] = outputTanks[i]; + for(int i = 0; i < this.getSmokeTanks().length; i++) all[outputTanks.length + i] = this.getSmokeTanks()[i]; + //return outputTanks != null ? outputTanks : new FluidTank[0]; + return all; } @Override @@ -472,20 +578,20 @@ public class TileEntityCustomMachine extends TileEntityMachineBase implements IF public void setPower(long power) { this.power = power; } - + @Override public long transferPower(long power) { if(this.config != null && this.config.generatorMode) return power; - + this.setPower(this.getPower() + power); - + if(this.getPower() > this.getMaxPower()) { - + long overshoot = this.getPower() - this.getMaxPower(); this.setPower(this.getMaxPower()); return overshoot; } - + return 0; } diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index f9681a2c0..ee8c16690 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -4724,6 +4724,8 @@ tile.cm_circuit.schrabidium.name=Tier 5 Circuit Block tile.cm_engine.bismuth.name=Bismuth Motor Block tile.cm_engine.desh.name=Desh Motor Block tile.cm_engine.standard.name=Motor Block +tile.cm_flux.name=Neutron Flux Receiver +tile.cm_heat.name=Heat receiver tile.cm_port.alloy.name=Advanced Alloy Port tile.cm_port.desh.name=Desh Port tile.cm_port.steel.name=Steel Port diff --git a/src/main/resources/assets/hbm/textures/blocks/cm_flux_side.png b/src/main/resources/assets/hbm/textures/blocks/cm_flux_side.png new file mode 100644 index 0000000000000000000000000000000000000000..626be40ad236eb0eb5b226a0000bbdf81f3b515c GIT binary patch literal 410 zcmV;L0cHM)P)Px$R7pfZR5*>Llg~=SKoG`%X(QNDU!kS+6-0ca-nxSfX47Vq zG;K2DA%EP)9+U<`GT+X8^X=@n!D_WqPIy9N40j(-M6Mu83L>}X_4<+9&*vI*1vcID zcJ;u`*9+Da*mQ?=d)_ba8K^3%APNE~psEOdTx0dOd7HdJo7^r)vmxmdt9Jj=XFqXzm4QM%#VLawNrZNgCh=WyY#o!pH;A2E>F77-<;>deo!aV1ONa407*qoM6N<$ Ef?Q;_7ytkO literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/blocks/cm_flux_top.png b/src/main/resources/assets/hbm/textures/blocks/cm_flux_top.png new file mode 100644 index 0000000000000000000000000000000000000000..f7df862cf362205daf966868eb5a9a38111b39ee GIT binary patch literal 541 zcmV+&0^1#o6otR}fn^bhjua~jM3;uANRdbsY4Qef<=Q1t+H^st zaX~}x2p4HwBX|%-2nh;H2n@43lL7`7WJ@{CYVX`R=iaktMX%TM)>@o%#Bq$)n*YIO zvtc|Qqj$R;G$ddq=yDwDY z2!PtpKWCyJUs-Q=hnJ7v@ZO`f);Q z%6VVHT7f9UU017B>h=10x8nt443$s|G5-Di)Ke;zP)Z@X-L9WZCbZja>h(IWudi5Z z@!k{1F;NterYZaV9w7w9Vv#6{SS%I{heJfC)A6&}jQM-+IpnN!d)M42;`m0^c9!+|q- z^EtD1wiX&>T&j~4DxX&#op!L$S@q}}tCX!g>snq<&|RJ6>;H*M zG9uXe`GGTae91lR5*OW)E_z3VJ@u&yTJ`(7h4#vcN9KIaf6vor?eU1YH{qZ_{rag} Qf$n4QboFyt=akR{04{t{rT_o{ literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/blocks/cm_heat_top.png b/src/main/resources/assets/hbm/textures/blocks/cm_heat_top.png new file mode 100644 index 0000000000000000000000000000000000000000..443aa3f7ee1340a9b7b454c81b5f7caa9afa422c GIT binary patch literal 742 zcmVPx%ph-kQR5*=oluvIXMG(b*uX73!Rlh3T+}t=oRaHpB%m8qABms1LaX)^Gqi+eo zWHRXh`v>|!eRFq!?rfa5+ie2~@cma2$T5l9ox~ggl{b3;wL9x|MvI9A^LfgTf7pRx zUDw>+W=QbyC#QIe{WzFrZ4&McPz3F>>=*`XSPf5xj86xcL-Xzho&?>`?6c##g-&6+#pR66`#b7ZM(@@clgSBh*I9e( z?7&bGi3!O_f^`yDtuj8m%{gC8+255^?gXiOIQ0r3_JJhUrJ1NIZ(mL9vXWP?J|mbI zr$Z`lVm!Z`QU1H<*gDxnHg&I#R<|31WthZbF{RuUczedA|CM9}Y$9!SXc8{xF5mO= z`huj@RyrF!aUJHDGq#)J(VnD3Eem+J&hd3lRX1H`v7GWylurU4TO^kBn`#73+D2h| zD!9kCSWFw|uOo&({5e4S6lmI6RaLNUzQyJtsVzh6)^UW;1I+WBV}VEDr`o)kb>PSL Y9~=G%*a=h^#{d8T07*qoM6N<$f|yrRQvd(} literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/hbm/textures/gui/processing/gui_custom.png b/src/main/resources/assets/hbm/textures/gui/processing/gui_custom.png index 7b47cbfac8943eba2e9d5d918b9623931455096a..412b6625a46c8df891948dfc8ac3bdd1ef783fd8 100644 GIT binary patch literal 3745 zcmbVPXH-+^);=i$krG6u83;`&f`|$P9Uv$zB7wo66r~%Q0-+cr2tgbvA_9t3K`A3h z?@9|&RYHrjp@uRPAq44CZ^XIZ-1V)yzV+REew_Eb@7`YdYjMd{lD0~nA z0B(%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