diff --git a/changelog b/changelog index b6193771d..3c93a2fc6 100644 --- a/changelog +++ b/changelog @@ -64,3 +64,4 @@ * Fixed light blue and light gray dyes not working when dyeing cables * Fixed bismuth armor not having a valid repair material * Fixed compressors needing at least one mB of fluid more to process a recipe than necessary +* Fixed many NTM structure spawn conditions being hardcoded (again) preventing them from spawning in modded biomes that would otherwise be a fit diff --git a/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionBreeder.java b/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionBreeder.java index af9421e30..ede4e3fe1 100644 --- a/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionBreeder.java +++ b/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionBreeder.java @@ -5,6 +5,7 @@ import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.fusion.TileEntityFusionBreeder; import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -18,7 +19,7 @@ public class MachineFusionBreeder extends BlockDummyable { @Override public TileEntity createNewTileEntity(World world, int meta) { if(meta >= 12) return new TileEntityFusionBreeder(); - if(meta >= 6) return new TileEntityProxyCombo().power().fluid(); + if(meta >= 6) return new TileEntityProxyCombo().inventory().fluid(); return null; } @@ -31,6 +32,11 @@ public class MachineFusionBreeder extends BlockDummyable { public int getOffset() { return 2; } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return super.standardOpenBehavior(world, x, y, z, player, 0); + } @Override public boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) { @@ -40,5 +46,16 @@ public class MachineFusionBreeder extends BlockDummyable { @Override public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { super.fillSpace(world, x, y, z, dir, o); + + x += dir.offsetX * o; + z += dir.offsetZ * o; + + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + this.makeExtra(world, x + rot.offsetX, y, z + rot.offsetZ); + this.makeExtra(world, x - rot.offsetX, y, z - rot.offsetZ); + this.makeExtra(world, x + dir.offsetX + rot.offsetX, y, z + dir.offsetZ + rot.offsetZ); + this.makeExtra(world, x + dir.offsetX - rot.offsetX, y, z + dir.offsetZ - rot.offsetZ); + this.makeExtra(world, x + dir.offsetX * 2, y + 2, z + dir.offsetZ * 2); } } diff --git a/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionCollector.java b/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionCollector.java index 8a78f43b5..39383ceb4 100644 --- a/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionCollector.java +++ b/src/main/java/com/hbm/blocks/machine/fusion/MachineFusionCollector.java @@ -1,7 +1,6 @@ package com.hbm.blocks.machine.fusion; import com.hbm.blocks.BlockDummyable; -import com.hbm.tileentity.TileEntityProxyCombo; import com.hbm.tileentity.machine.fusion.TileEntityFusionCollector; import net.minecraft.block.material.Material; @@ -18,7 +17,6 @@ public class MachineFusionCollector extends BlockDummyable { @Override public TileEntity createNewTileEntity(World world, int meta) { if(meta >= 12) return new TileEntityFusionCollector(); - if(meta >= 6) return new TileEntityProxyCombo().power().fluid(); return null; } diff --git a/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java b/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java index 162167848..88915f579 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java +++ b/src/main/java/com/hbm/inventory/gui/GUIFusionKlystron.java @@ -17,6 +17,7 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; public class GUIFusionKlystron extends GuiInfoContainer { @@ -51,9 +52,9 @@ public class GUIFusionKlystron extends GuiInfoContainer { this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 18, 16, 52, klystron.power, klystron.getMaxPower()); - drawCustomInfoStat(mouseX, mouseY, guiLeft + 43, guiTop + 71, 18, 18, mouseX, mouseY, BobMathUtil.getShortNumber(klystron.output) + "KyU / " + BobMathUtil.getShortNumber(klystron.outputTarget) + "KyU"); + drawCustomInfoStat(mouseX, mouseY, guiLeft + 43, guiTop + 71, 18, 18, mouseX, mouseY, EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + BobMathUtil.getShortNumber(klystron.output) + "KyU / " + BobMathUtil.getShortNumber(klystron.outputTarget) + "KyU"); klystron.compair.renderTankInfo(this, mouseX, mouseY, guiLeft + 76, guiTop + 71, 18, 18); - drawCustomInfoStat(mouseX, mouseY, guiLeft + 115, guiTop + 71, 18, 18, mouseX, mouseY, BobMathUtil.getShortNumber(klystron.output) + "HE / " + BobMathUtil.getShortNumber(klystron.outputTarget) + "HE"); + drawCustomInfoStat(mouseX, mouseY, guiLeft + 115, guiTop + 71, 18, 18, mouseX, mouseY, EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + BobMathUtil.getShortNumber(klystron.output) + "HE / " + BobMathUtil.getShortNumber(klystron.outputTarget) + "HE"); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java b/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java index 53334a99d..f682eb767 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java +++ b/src/main/java/com/hbm/inventory/gui/GUIFusionTorus.java @@ -44,12 +44,12 @@ public class GUIFusionTorus extends GuiInfoContainer { FusionRecipe recipe = (FusionRecipe) FusionRecipes.INSTANCE.recipeNameMap.get(this.torus.fusionModule.recipe); if(recipe != null) { - drawCustomInfoStat(mouseX, mouseY, guiLeft + 43, guiTop + 115, 18, 18, mouseX, mouseY, BobMathUtil.getShortNumber(torus.klystronEnergy) + "KyU / " + BobMathUtil.getShortNumber(recipe.ignitionTemp) + "KyU"); - drawCustomInfoStat(mouseX, mouseY, guiLeft + 79, guiTop + 115, 18, 18, mouseX, mouseY, BobMathUtil.getShortNumber(torus.plasmaEnergy) + "TU / " + BobMathUtil.getShortNumber(recipe.outputTemp) + "TU"); + drawCustomInfoStat(mouseX, mouseY, guiLeft + 43, guiTop + 115, 18, 18, mouseX, mouseY, EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + BobMathUtil.getShortNumber(torus.klystronEnergy) + "KyU / " + BobMathUtil.getShortNumber(recipe.ignitionTemp) + "KyU"); + drawCustomInfoStat(mouseX, mouseY, guiLeft + 79, guiTop + 115, 18, 18, mouseX, mouseY, EnumChatFormatting.RED + "<- " + EnumChatFormatting.RESET + BobMathUtil.getShortNumber(torus.plasmaEnergy) + "TU / " + BobMathUtil.getShortNumber(recipe.outputTemp) + "TU"); String[] lines = new String[recipe.inputFluid.length]; for(int i = 0; i < lines.length; i++) { int consumption = (int) Math.ceil(recipe.inputFluid[i].fill * torus.fuelConsumption); - lines[i] = consumption + "mB/t " + recipe.inputFluid[i].type.getLocalizedName(); + lines[i] = EnumChatFormatting.GREEN + "-> " + EnumChatFormatting.RESET + consumption + "mB/t " + recipe.inputFluid[i].type.getLocalizedName(); } drawCustomInfoStat(mouseX, mouseY, guiLeft + 115, guiTop + 115, 18, 18, mouseX, mouseY, lines); } else { diff --git a/src/main/java/com/hbm/inventory/recipes/FusionRecipe.java b/src/main/java/com/hbm/inventory/recipes/FusionRecipe.java index 5e6bb67ad..c85e07637 100644 --- a/src/main/java/com/hbm/inventory/recipes/FusionRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/FusionRecipe.java @@ -15,11 +15,14 @@ public class FusionRecipe extends GenericRecipe { public long ignitionTemp; // plasma output energy at full blast public long outputTemp; + // neutron output energy at full blast + public double neutronFlux; public FusionRecipe(String name) { super(name); } public FusionRecipe setInputEnergy(long ignitionTemp) { this.ignitionTemp = ignitionTemp; return this; } public FusionRecipe setOutputEnergy(long outputTemp) { this.outputTemp = outputTemp; return this; } + public FusionRecipe setOutputFlux(double neutronFlux) { this.neutronFlux = neutronFlux; return this; } public List print() { List list = new ArrayList(); @@ -29,6 +32,7 @@ public class FusionRecipe extends GenericRecipe { power(list); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.fusionIn") + ": " + BobMathUtil.getShortNumber(ignitionTemp) + "KyU/t"); list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.fusionOut") + ": " + BobMathUtil.getShortNumber(outputTemp) + "TU/t"); + list.add(EnumChatFormatting.RED + I18nUtil.resolveKey("gui.recipe.fusionFlux") + ": " + ((int)(neutronFlux * 10)) / 10D + " flux/t"); input(list); output(list); diff --git a/src/main/java/com/hbm/inventory/recipes/FusionRecipes.java b/src/main/java/com/hbm/inventory/recipes/FusionRecipes.java index d91d3e431..2852d17b2 100644 --- a/src/main/java/com/hbm/inventory/recipes/FusionRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/FusionRecipes.java @@ -1,8 +1,17 @@ package com.hbm.inventory.recipes; +import java.io.IOException; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.stream.JsonWriter; import com.hbm.inventory.FluidStack; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.recipes.loader.GenericRecipes; +import com.hbm.items.ModItems; +import com.hbm.tileentity.machine.fusion.TileEntityFusionBreeder; + +import net.minecraft.item.ItemStack; public class FusionRecipes extends GenericRecipes { @@ -19,11 +28,87 @@ public class FusionRecipes extends GenericRecipes { @Override public void registerDefaults() { - long solenoid = 100_000; + long solenoid = 25_000; + double breederCapacity = TileEntityFusionBreeder.capacity; - this.register((FusionRecipe) new FusionRecipe("fus.d-t").setInputEnergy(1_000_000).setOutputEnergy(20_000_000) + /// DEMO /// + + // mostly for breeding helium and tritium, energy gains are enough to ignite TH4 + // 15MHE/s to 20MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.dd").setInputEnergy(750_000).setOutputEnergy(1_000_000).setOutputFlux(breederCapacity / 200) + .setPower(solenoid).setDuration(100) + .inputFluids(new FluidStack(Fluids.DEUTERIUM, 20)) + .outputFluids(new FluidStack(Fluids.HELIUM4, 1_000))); // akshuyally it should be helium-3 muh realisme + + // early fuel + // 5MHE/s to 20MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.do").setInputEnergy(250_000).setOutputEnergy(1_250_000).setOutputFlux(breederCapacity / 200) + .setPower(solenoid).setDuration(100) + .inputFluids(new FluidStack(Fluids.DEUTERIUM, 10), new FluidStack(Fluids.OXYGEN, 10)) + .outputItems(new ItemStack(ModItems.pellet_charged))); + + // medium fuel + // 15MHE/s to 75MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.dt").setInputEnergy(750_000).setOutputEnergy(3_750_000).setOutputFlux(breederCapacity / 100) .setPower(solenoid).setDuration(100) .inputFluids(new FluidStack(Fluids.DEUTERIUM, 10), new FluidStack(Fluids.TRITIUM, 10)) .outputFluids(new FluidStack(Fluids.HELIUM4, 1_000))); + + // medium fuel, three klystrons or in tandem + // 50MHE/s to 125MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.tcl").setInputEnergy(2_500_000).setOutputEnergy(6_250_000).setOutputFlux(breederCapacity / 20) + .setPower(solenoid).setDuration(100) + .inputFluids(new FluidStack(Fluids.TRITIUM, 10), new FluidStack(Fluids.CHLORINE, 10)) + .outputItems(new ItemStack(ModItems.pellet_charged))); + + // medium fuel, aneutronic + // 10MHE/s to 75MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.h3").setInputEnergy(500_000).setOutputEnergy(3_750_000).setOutputFlux(0) + .setPower(solenoid).setDuration(100) + .inputFluids(new FluidStack(Fluids.HELIUM3, 20)) + .outputFluids(new FluidStack(Fluids.HELIUM4, 1_000))); + + // medium fuel, in tandem with DD + // 17.5MHE/s to 80MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.th4").setInputEnergy(875_000).setOutputEnergy(4_000_000).setOutputFlux(breederCapacity / 20) + .setPower(solenoid).setDuration(100) + .inputFluids(new FluidStack(Fluids.TRITIUM, 10), new FluidStack(Fluids.HELIUM4, 10)) + .outputItems(new ItemStack(ModItems.pellet_charged))); + + // high fuel, ignition exceeds klystron power, requires TH4 or H3 + // 75MHE/s to 200MHE/s + this.register((FusionRecipe) new FusionRecipe("fus.cl").setInputEnergy(3_750_000).setOutputEnergy(10_000_000).setOutputFlux(breederCapacity / 10) + .setPower(solenoid).setDuration(100) + .inputFluids(new FluidStack(Fluids.CHLORINE, 20)) + .outputItems(new ItemStack(ModItems.pellet_charged))); + + /// DEMO /// + + + /* + * TODO: + * chlorophyte and more liquid byproduct types + * stellar flux plasma (post ICF, erisite?) + * balefire plasma (raw balefire instead of rocket fuel?) + * scrap ionized particle liquefaction recipe + * deuterated carbon (deut + refgas + syngas in a chemplant) + */ + } + + // foresight! yeah! + @Override + public void readExtraData(JsonElement element, FusionRecipe recipe) { + JsonObject obj = (JsonObject) element; + + recipe.ignitionTemp = obj.get("ignitionTemp").getAsLong(); + recipe.outputTemp = obj.get("outputTemp").getAsLong(); + recipe.neutronFlux = obj.get("outputFlux").getAsDouble(); + } + + @Override + public void writeExtraData(FusionRecipe recipe, JsonWriter writer) throws IOException { + writer.name("ignitionTemp").value(recipe.ignitionTemp); + writer.name("outputTemp").value(recipe.outputTemp); + writer.name("outputFlux").value(recipe.neutronFlux); } } diff --git a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java index 0bee0728a..27eb9c69f 100644 --- a/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java +++ b/src/main/java/com/hbm/inventory/recipes/loader/GenericRecipes.java @@ -173,7 +173,7 @@ public abstract class GenericRecipes extends Serializab writeExtraData(recipe, writer); } - public void writeExtraData(T recipe, JsonWriter writer) { } + public void writeExtraData(T recipe, JsonWriter writer) throws IOException { } public IOutput[] readOutputArray(JsonArray array) { IOutput[] output = new IOutput[array.size()]; diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java index 0ffaffefe..2dec72155 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityFoundryChannel.java @@ -179,7 +179,7 @@ public class TileEntityFoundryChannel extends TileEntityFoundryBase { @Override public boolean canAcceptPartialPour(World world, int x, int y, int z, double dX, double dY, double dZ, ForgeDirection side, MaterialStack stack) { - if(this.node == null) return false; + if(this.node == null || !this.node.hasValidNet()) return false; for(Object o : this.node.net.links) { FoundryNode node = (FoundryNode) o; if(node.type != null && node.type != stack.material) { diff --git a/src/main/java/com/hbm/tileentity/machine/fusion/IFusionPowerReceiver.java b/src/main/java/com/hbm/tileentity/machine/fusion/IFusionPowerReceiver.java new file mode 100644 index 000000000..f139a8bcb --- /dev/null +++ b/src/main/java/com/hbm/tileentity/machine/fusion/IFusionPowerReceiver.java @@ -0,0 +1,10 @@ +package com.hbm.tileentity.machine.fusion; + +public interface IFusionPowerReceiver { + + /** + * fusionPower is the per-port output adjusted for the amount of connected receivers (i.e. when boilers share output energy) + * neutronPower is a fixed value provided by the recipe + */ + public void receiveFusionPower(long fusionPower, double neutronPower); +} diff --git a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionBreeder.java b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionBreeder.java index 24d58bf62..96abb0088 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionBreeder.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionBreeder.java @@ -1,26 +1,56 @@ package com.hbm.tileentity.machine.fusion; +import com.hbm.inventory.fluid.Fluids; +import com.hbm.inventory.fluid.tank.FluidTank; +import com.hbm.tileentity.IGUIProvider; +import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.uninos.GenNode; import com.hbm.uninos.UniNodespace; import com.hbm.uninos.networkproviders.PlasmaNetworkProvider; import com.hbm.util.fauxpointtwelve.BlockPos; import com.hbm.util.fauxpointtwelve.DirPos; +import api.hbm.fluidmk2.IFluidStandardTransceiverMK2; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.tileentity.TileEntity; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityFusionBreeder extends TileEntity { +public class TileEntityFusionBreeder extends TileEntityMachineBase implements IFluidStandardTransceiverMK2, IGUIProvider { protected GenNode plasmaNode; + public FluidTank[] tanks; + + public static final double capacity = 10_000D; + + public TileEntityFusionBreeder() { + super(2); + + tanks = new FluidTank[2]; + tanks[0] = new FluidTank(Fluids.NONE, 16_000); + tanks[1] = new FluidTank(Fluids.NONE, 16_000); + } + + @Override + public String getName() { + return "container.fusionBreeder"; + } + @Override public void updateEntity() { if(!worldObj.isRemote) { + for(DirPos pos : getConPos()) { + if(tanks[0].getTankType() != Fluids.NONE) this.trySubscribe(tanks[0].getTankType(), worldObj, pos); + if(tanks[1].getFill() > 0) this.tryProvide(tanks[1], worldObj, pos); + } + if(plasmaNode == null || plasmaNode.expired) { ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10).getOpposite(); plasmaNode = UniNodespace.getNode(worldObj, xCoord + dir.offsetX * 2, yCoord + 2, zCoord + dir.offsetZ * 2, PlasmaNetworkProvider.THE_PROVIDER); @@ -37,6 +67,19 @@ public class TileEntityFusionBreeder extends TileEntity { if(plasmaNode != null && plasmaNode.hasValidNet()) plasmaNode.net.addReceiver(this); } } + + public DirPos[] getConPos() { + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); + ForgeDirection rot = dir.getRotation(ForgeDirection.UP); + + return new DirPos[] { + new DirPos(xCoord + dir.offsetX * 3, yCoord + 2, zCoord + dir.offsetZ * 3, dir), + new DirPos(xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3, rot), + new DirPos(xCoord - rot.offsetX * 3, yCoord, zCoord - rot.offsetZ * 3, rot.getOpposite()), + new DirPos(xCoord + dir.offsetX + rot.offsetX * 3, yCoord, zCoord + dir.offsetX + rot.offsetZ * 3, rot), + new DirPos(xCoord - dir.offsetX - rot.offsetX * 3, yCoord, zCoord - dir.offsetX - rot.offsetZ * 3, rot.getOpposite()) + }; + } @Override public void invalidate() { @@ -47,6 +90,34 @@ public class TileEntityFusionBreeder extends TileEntity { } } + @Override + public void serialize(ByteBuf buf) { + super.serialize(buf); + this.tanks[0].serialize(buf); + this.tanks[1].serialize(buf); + } + + @Override + public void deserialize(ByteBuf buf) { + super.deserialize(buf); + this.tanks[0].deserialize(buf); + this.tanks[1].deserialize(buf); + } + + @Override public FluidTank[] getReceivingTanks() { return new FluidTank[] {tanks[0]}; } + @Override public FluidTank[] getSendingTanks() { return new FluidTank[] {tanks[1]}; } + @Override public FluidTank[] getAllTanks() { return tanks; } + + @Override + public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + AxisAlignedBB bb = null; @Override diff --git a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionKlystron.java b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionKlystron.java index 48ab63193..e1853bb2d 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionKlystron.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionKlystron.java @@ -34,7 +34,7 @@ import net.minecraftforge.common.util.ForgeDirection; public class TileEntityFusionKlystron extends TileEntityMachineBase implements IEnergyReceiverMK2, IFluidStandardReceiverMK2, IControlReceiver, IGUIProvider { protected GenNode klystronNode; - public static final long MAX_OUTPUT = 100_000_000; + public static final long MAX_OUTPUT = 1_000_000; public static final int AIR_CONSUMPTION = 2_500; public long outputTarget; public long output; diff --git a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java index 95b4ab17c..f49edf19a 100644 --- a/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java +++ b/src/main/java/com/hbm/tileentity/machine/fusion/TileEntityFusionTorus.java @@ -122,6 +122,7 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP this.power = Library.chargeTEFromItems(slots, 0, power, this.getMaxPower()); + int receiverCount = 0; int collectors = 0; for(int i = 0; i < 4; i++) { @@ -133,9 +134,8 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP for(Object o : plasmaNodes[i].net.receiverEntries.entrySet()) { Entry entry = (Entry) o; - if(entry.getKey() instanceof TileEntityFusionCollector) { - collectors++; - } + if(entry.getKey() instanceof IFusionPowerReceiver) receiverCount++; + if(entry.getKey() instanceof TileEntityFusionCollector) collectors++; break; } } @@ -163,6 +163,24 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP this.fuelConsumption = factor; } + double outputIntensity = this.getOuputIntensity(receiverCount); + double outputFlux = recipe != null ? recipe.neutronFlux * factor : 0D; + + if(this.plasmaEnergy > 0) for(int i = 0; i < 4; i++) { + + if(plasmaNodes[i] != null && plasmaNodes[i].hasValidNet() && !plasmaNodes[i].net.receiverEntries.isEmpty()) { + + for(Object o : plasmaNodes[i].net.receiverEntries.entrySet()) { + Entry entry = (Entry) o; + + if(entry.getKey() instanceof IFusionPowerReceiver) { + long powerReceived = (long) Math.ceil(this.plasmaEnergy * outputIntensity); + ((IFusionPowerReceiver) entry.getKey()).receiveFusionPower(powerReceived, outputFlux); + } + } + } + } + this.networkPackNT(150); this.klystronEnergy = 0; @@ -185,6 +203,13 @@ public class TileEntityFusionTorus extends TileEntityCooledBase implements IGUIP } } + public static double getOuputIntensity(int receiverCount) { + if(receiverCount == 1) return 1D; // 100% + if(receiverCount == 2) return 0.625D; // 125% + if(receiverCount == 3) return 0.5D; // 150% + return 0.4375D; // 175% + } + public GenNode createNode(INetworkProvider provider, ForgeDirection dir) { GenNode node = UniNodespace.getNode(worldObj, xCoord + dir.offsetX * 7, yCoord + 2, zCoord + dir.offsetZ * 7, provider); if(node != null) return node; diff --git a/src/main/java/com/hbm/uninos/GenNode.java b/src/main/java/com/hbm/uninos/GenNode.java index 3e4b0925b..2d3ee43ab 100644 --- a/src/main/java/com/hbm/uninos/GenNode.java +++ b/src/main/java/com/hbm/uninos/GenNode.java @@ -7,6 +7,8 @@ public class GenNode { public BlockPos[] positions; public DirPos[] connections; + /** Quick reminder that this CAN and WILL be null for the first tick between the node being created + * and the nodepsace update loop establishing a network. always check hasValidNet beforehand! */ public N net; public boolean expired = false; public boolean recentlyChanged = true; diff --git a/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java b/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java index c6abdbc8b..dbf6922fa 100644 --- a/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java +++ b/src/main/java/com/hbm/world/gen/NTMWorldGenerator.java @@ -1,8 +1,6 @@ package com.hbm.world.gen; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Random; @@ -26,6 +24,8 @@ import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.structure.StructureComponent.BlockSelector; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.event.terraingen.InitMapGenEvent.EventType; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; @@ -34,48 +34,50 @@ import net.minecraftforge.event.world.WorldEvent; public class NTMWorldGenerator implements IWorldGenerator { boolean regTest = false; + + public static boolean isInvalidBiome(BiomeGenBase biome) { + return BiomeDictionary.isBiomeOfType(biome, Type.OCEAN) || BiomeDictionary.isBiomeOfType(biome, Type.RIVER); + } + + public static boolean isFlatBiome(BiomeGenBase biome) { + return biome.heightVariation <= 0.2F && !isInvalidBiome(biome) && BiomeDictionary.isBiomeOfType(biome, Type.SPARSE); + } public NTMWorldGenerator() { - final List invalidBiomes = Arrays.asList(new BiomeGenBase[] {BiomeGenBase.ocean, BiomeGenBase.river, BiomeGenBase.frozenOcean, BiomeGenBase.frozenRiver, BiomeGenBase.deepOcean}); - final List oceanBiomes = Arrays.asList(new BiomeGenBase[] { BiomeGenBase.ocean, BiomeGenBase.deepOcean }); - final List beachBiomes = Arrays.asList(new BiomeGenBase[] { BiomeGenBase.beach, BiomeGenBase.stoneBeach, BiomeGenBase.coldBeach }); - final List lighthouseBiomes = Arrays.asList(new BiomeGenBase[] { BiomeGenBase.ocean, BiomeGenBase.deepOcean, BiomeGenBase.beach, BiomeGenBase.stoneBeach, BiomeGenBase.coldBeach }); - final List flatbiomes = Arrays.asList(BiomeGenBase.plains,BiomeGenBase.icePlains,BiomeGenBase.desert, BiomeGenBase.forest, BiomeGenBase.taiga, BiomeGenBase.coldTaiga, BiomeGenBase.savanna, BiomeGenBase.savannaPlateau, BiomeGenBase.birchForest); - /// SPIRE /// NBTStructure.registerStructure(0, new SpawnCondition("spire") {{ - canSpawn = biome -> biome.heightVariation <= 0.05F && !invalidBiomes.contains(biome); + canSpawn = biome -> biome.heightVariation <= 0.05F && !isInvalidBiome(biome); structure = new JigsawPiece("spire", StructureManager.spire, -1); spawnWeight = StructureConfig.spireSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("features") {{ - canSpawn = biome -> !invalidBiomes.contains(biome); + canSpawn = biome -> !isInvalidBiome(biome); start = d -> new MapGenNTMFeatures.Start(d.getW(), d.getX(), d.getY(), d.getZ()); spawnWeight = StructureConfig.featuresSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("bunker") {{ - canSpawn = biome -> !invalidBiomes.contains(biome); + canSpawn = biome -> !isInvalidBiome(biome); start = d -> new BunkerStart(d.getW(), d.getX(), d.getY(), d.getZ()); spawnWeight = StructureConfig.bunkerSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("vertibird") {{ - canSpawn = biome -> !biome.canSpawnLightningBolt() && biome.temperature >= 2F; + canSpawn = biome -> !isInvalidBiome(biome) && BiomeDictionary.isBiomeOfType(biome, Type.SANDY); structure = new JigsawPiece("vertibird", StructureManager.vertibird, -3); spawnWeight = StructureConfig.vertibirdSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("crashed_vertibird") {{ - canSpawn = biome -> !biome.canSpawnLightningBolt() && biome.temperature >= 2F; + canSpawn = biome -> !isInvalidBiome(biome) && BiomeDictionary.isBiomeOfType(biome, Type.SANDY); structure = new JigsawPiece("crashed_vertibird", StructureManager.crashed_vertibird, -10); spawnWeight = StructureConfig.vertibirdCrashedSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("beached_patrol") {{ - canSpawn = beachBiomes::contains; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.BEACH); structure = new JigsawPiece("beached_patrol", StructureManager.beached_patrol, -5); minHeight = 58; maxHeight = 67; @@ -83,14 +85,14 @@ public class NTMWorldGenerator implements IWorldGenerator { }}); NBTStructure.registerStructure(0, new SpawnCondition("aircraft_carrier") {{ - canSpawn = oceanBiomes::contains; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.OCEAN); structure = new JigsawPiece("aircraft_carrier", StructureManager.aircraft_carrier, -6); maxHeight = 42; spawnWeight = StructureConfig.enableOceanStructures ? StructureConfig.aircraftCarrierSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("oil_rig") {{ - canSpawn = biome -> biome == BiomeGenBase.deepOcean; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.OCEAN) && biome.rootHeight >= -1.5F; structure = new JigsawPiece("oil_rig", StructureManager.oil_rig, -20); maxHeight = 12; minHeight = 11; @@ -98,7 +100,7 @@ public class NTMWorldGenerator implements IWorldGenerator { }}); NBTStructure.registerStructure(0, new SpawnCondition("lighthouse") {{ - canSpawn = lighthouseBiomes::contains; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.OCEAN) || BiomeDictionary.isBiomeOfType(biome, Type.BEACH); structure = new JigsawPiece("lighthouse", StructureManager.lighthouse, -40); maxHeight = 29; minHeight = 28; @@ -106,7 +108,7 @@ public class NTMWorldGenerator implements IWorldGenerator { }}); NBTStructure.registerStructure(0, new SpawnCondition("dish") {{ - canSpawn = biome -> biome == BiomeGenBase.plains; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.PLAINS); structure = new JigsawPiece("dish", StructureManager.dish, -10); minHeight = 53; maxHeight = 65; @@ -114,13 +116,13 @@ public class NTMWorldGenerator implements IWorldGenerator { }}); NBTStructure.registerStructure(0, new SpawnCondition("forestchem") {{ - canSpawn = biome -> biome.heightVariation <= 0.3F; + canSpawn = biome -> biome.heightVariation <= 0.3F && !isInvalidBiome(biome); structure = new JigsawPiece("forest_chem", StructureManager.forest_chem, -9); spawnWeight = StructureConfig.forestChemSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("labolatory") {{ - canSpawn = flatbiomes::contains; + canSpawn = biome -> isFlatBiome(biome); structure = new JigsawPiece("laboratory", StructureManager.laboratory, -10); minHeight = 53; maxHeight = 65; @@ -128,118 +130,118 @@ public class NTMWorldGenerator implements IWorldGenerator { }}); NBTStructure.registerStructure(0, new SpawnCondition("forest_post") {{ - canSpawn = biome -> biome.heightVariation <= 0.3F; + canSpawn = biome -> biome.heightVariation <= 0.3F && !isInvalidBiome(biome); structure = new JigsawPiece("forest_post", StructureManager.forest_post, -10); spawnWeight = StructureConfig.forestPostSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("radio") {{ - canSpawn = flatbiomes::contains; + canSpawn = biome -> isFlatBiome(biome); structure = new JigsawPiece("radio_house", StructureManager.radio_house, -6); spawnWeight = StructureConfig.radioSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("factory") {{ - canSpawn = flatbiomes::contains; + canSpawn = biome -> isFlatBiome(biome); structure = new JigsawPiece("factory", StructureManager.factory, -10); spawnWeight = StructureConfig.factorySpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("crane") {{ - canSpawn = flatbiomes::contains; + canSpawn = biome -> isFlatBiome(biome); structure = new JigsawPiece("crane", StructureManager.crane, -9); spawnWeight = StructureConfig.craneSpawnWeight; }}); - + NBTStructure.registerStructure(0, new SpawnCondition("broadcaster_tower") {{ - canSpawn = flatbiomes::contains; + canSpawn = biome -> isFlatBiome(biome); structure = new JigsawPiece("broadcaster_tower", StructureManager.broadcasting_tower, -9); spawnWeight = StructureConfig.broadcastingTowerSpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("plane1") {{ - canSpawn = biome -> biome.heightVariation <= 0.3F; + canSpawn = biome -> biome.heightVariation <= 0.3F && !isInvalidBiome(biome); structure = new JigsawPiece("crashed_plane_1", StructureManager.plane1, -5); spawnWeight = StructureConfig.plane1SpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("plane2") {{ - canSpawn = biome -> biome.heightVariation <= 0.3F; + canSpawn = biome -> biome.heightVariation <= 0.3F && !isInvalidBiome(biome); structure = new JigsawPiece("crashed_plane_2", StructureManager.plane2, -8); spawnWeight = StructureConfig.plane2SpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("desert_shack_1") {{ - canSpawn = biome -> biome == BiomeGenBase.desert; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.SANDY); structure = new JigsawPiece("desert_shack_1", StructureManager.desert_shack_1, -7); spawnWeight = StructureConfig.desertShack1SpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("desert_shack_2") {{ - canSpawn = biome -> biome == BiomeGenBase.desert; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.SANDY); structure = new JigsawPiece("desert_shack_2", StructureManager.desert_shack_2, -7); spawnWeight = StructureConfig.desertShack2SpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("desert_shack_3") {{ - canSpawn = biome -> biome == BiomeGenBase.desert; + canSpawn = biome -> BiomeDictionary.isBiomeOfType(biome, Type.SANDY); structure = new JigsawPiece("desert_shack_3", StructureManager.desert_shack_3, -5); spawnWeight = StructureConfig.desertShack3SpawnWeight; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinA") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsA", StructureManager.ntmruinsA, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsASpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinB") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsB", StructureManager.ntmruinsB, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsBSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinC") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsC", StructureManager.ntmruinsC, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsCSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinD") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsD", StructureManager.ntmruinsD, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsDSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinE") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsE", StructureManager.ntmruinsE, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsESpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinF") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsF", StructureManager.ntmruinsF, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsFSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinG") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsG", StructureManager.ntmruinsG, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsGSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinH") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsH", StructureManager.ntmruinsH, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsHSpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinI") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsI", StructureManager.ntmruinsI, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsISpawnWeight : 0; }}); NBTStructure.registerStructure(0, new SpawnCondition("ruinJ") {{ - canSpawn = biome -> !invalidBiomes.contains(biome) && biome.canSpawnLightningBolt(); + canSpawn = biome -> !isInvalidBiome(biome) && biome.canSpawnLightningBolt(); structure = new JigsawPiece("NTMRuinsJ", StructureManager.ntmruinsJ, -1) {{conformToTerrain = true;}}; spawnWeight = StructureConfig.enableRuins ? StructureConfig.ruinsJSpawnWeight : 0; }}); NBTStructure.registerNullWeight(0, StructureConfig.plainsNullWeight, biome -> biome == BiomeGenBase.plains); - NBTStructure.registerNullWeight(0, StructureConfig.oceanNullWeight, oceanBiomes::contains); + NBTStructure.registerNullWeight(0, StructureConfig.oceanNullWeight, biome -> BiomeDictionary.isBiomeOfType(biome, Type.OCEAN)); Map bricks = new HashMap() {{ put(ModBlocks.meteor_brick, new MeteorBricks()); diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index f82a81730..ffbb75370 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -1273,6 +1273,7 @@ general.na=N/A gui.recipe.duration=Duration gui.recipe.consumption=Consumption +gui.recipe.fusionFlux=Output Neutron Flux gui.recipe.fusionIn=Klystron Input Energy gui.recipe.fusionOut=Plasma Output Energy gui.recipe.input=Input diff --git a/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_breeder.png b/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_breeder.png new file mode 100644 index 000000000..f50d801d8 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_breeder.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_klystron.png b/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_klystron.png index ec4935828..7ec53139f 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_klystron.png and b/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_klystron.png differ diff --git a/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_torus.png b/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_torus.png index b0f8722d2..48b84ef87 100644 Binary files a/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_torus.png and b/src/main/resources/assets/hbm/textures/gui/reactors/gui_fusion_torus.png differ