diff --git a/build.gradle b/build.gradle index 7e2d8b839..efab6f5d1 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ archivesBaseName = "HBM-NTM" sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' minecraft { - version = "1.7.10-10.13.4.1558-1.7.10" + version = "1.7.10-10.13.4.1614-1.7.10" runDir = "eclipse" } diff --git a/src/main/java/api/hbm/energy/IEnergyConductor.java b/src/main/java/api/hbm/energy/IEnergyConductor.java index 9df6f81f4..154ccced3 100644 --- a/src/main/java/api/hbm/energy/IEnergyConductor.java +++ b/src/main/java/api/hbm/energy/IEnergyConductor.java @@ -1,5 +1,7 @@ package api.hbm.energy; +import net.minecraft.tileentity.TileEntity; + /** * For compatible cables with no buffer, using the IPowertNet. You can make your own cables with IEnergyConnector as well, but they won't join their power network. * @author hbm @@ -9,4 +11,20 @@ public interface IEnergyConductor extends IEnergyConnector { public IPowerNet getPowerNet(); public void setPowerNet(IPowerNet network); + + /** + * A unique identifier for every conductor tile. Used to prevent duplicates when loading previously persistent unloaded tiles. + * @return + */ + public default int getIdentity() { + + TileEntity te = (TileEntity) this; + + final int prime = 31; + int result = 1; + result = prime * result + te.xCoord; + result = prime * result + te.yCoord; + result = prime * result + te.zCoord; + return result; + } } diff --git a/src/main/java/api/hbm/energy/IEnergyConnector.java b/src/main/java/api/hbm/energy/IEnergyConnector.java index 6c05e377d..87a0f0a88 100644 --- a/src/main/java/api/hbm/energy/IEnergyConnector.java +++ b/src/main/java/api/hbm/energy/IEnergyConnector.java @@ -17,7 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection; public interface IEnergyConnector { /** - * Returns the amount of power that was added + * Returns the amount of power that remains in the source after transfer * @param power * @return */ diff --git a/src/main/java/api/hbm/energy/IPowerNet.java b/src/main/java/api/hbm/energy/IPowerNet.java index 3c47b232d..2c9fc6781 100644 --- a/src/main/java/api/hbm/energy/IPowerNet.java +++ b/src/main/java/api/hbm/energy/IPowerNet.java @@ -20,6 +20,14 @@ public interface IPowerNet { public void destroy(); + /** + * When a link is removed, instead of destroying the network, causing it to be recreated from currently loaded conductors, + * we re-evaluate it, creating new nets based on the previous links. + * + * NYI + */ + public void reevaluate(); + public boolean isValid(); public List getLinks(); diff --git a/src/main/java/api/hbm/energy/PowerNet.java b/src/main/java/api/hbm/energy/PowerNet.java index c08a228c2..dcf0f843a 100644 --- a/src/main/java/api/hbm/energy/PowerNet.java +++ b/src/main/java/api/hbm/energy/PowerNet.java @@ -128,4 +128,7 @@ public class PowerNet implements IPowerNet { return power - totalGiven; } + + @Override + public void reevaluate() { } } diff --git a/src/main/java/api/hbm/fluid/IFluidConductor.java b/src/main/java/api/hbm/fluid/IFluidConductor.java new file mode 100644 index 000000000..152e9524e --- /dev/null +++ b/src/main/java/api/hbm/fluid/IFluidConductor.java @@ -0,0 +1,10 @@ +package api.hbm.fluid; + +import com.hbm.inventory.fluid.FluidType; + +public interface IFluidConductor { + + public IPipeNet getPipeNet(FluidType type); + + public void setPipeNet(FluidType type, FluidType network); +} diff --git a/src/main/java/api/hbm/fluid/IFluidConnector.java b/src/main/java/api/hbm/fluid/IFluidConnector.java new file mode 100644 index 000000000..0b58d46ad --- /dev/null +++ b/src/main/java/api/hbm/fluid/IFluidConnector.java @@ -0,0 +1,31 @@ +package api.hbm.fluid; + +import com.hbm.inventory.fluid.FluidType; + +import net.minecraftforge.common.util.ForgeDirection; + +public interface IFluidConnector { + + /** + * Returns the amount of fluid that remains + * @param power + * @return + */ + public int transferFluid(FluidType type, int fluid); + + /** + * Whether the given side can be connected to + * @param dir + * @return + */ + public default boolean canConnect(ForgeDirection dir) { + return dir != ForgeDirection.UNKNOWN; + } + + /** + * Returns the amount of fluid that this machine is able to receive + * @param type + * @return + */ + public int getDemand(FluidType type); +} diff --git a/src/main/java/api/hbm/fluid/IPipeNet.java b/src/main/java/api/hbm/fluid/IPipeNet.java new file mode 100644 index 000000000..c0f20eae9 --- /dev/null +++ b/src/main/java/api/hbm/fluid/IPipeNet.java @@ -0,0 +1,8 @@ +package api.hbm.fluid; + +import api.hbm.energy.IPowerNet; + +public interface IPipeNet { + + public void joinNetworks(IPowerNet network); +} diff --git a/src/main/java/com/hbm/items/weapon/ItemGunBase.java b/src/main/java/com/hbm/items/weapon/ItemGunBase.java index d5c9edf84..c7e59441e 100644 --- a/src/main/java/com/hbm/items/weapon/ItemGunBase.java +++ b/src/main/java/com/hbm/items/weapon/ItemGunBase.java @@ -2,7 +2,6 @@ package com.hbm.items.weapon; import java.util.List; -import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import com.hbm.config.GeneralConfig; @@ -26,6 +25,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; +import net.minecraft.client.settings.GameSettings; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; @@ -107,7 +107,7 @@ public class ItemGunBase extends Item implements IHoldableWeapon, IItemHUD { if(mainConfig.reloadType != mainConfig.RELOAD_NONE || (altConfig != null && altConfig.reloadType != 0)) { - if(Keyboard.isKeyDown(HbmKeybinds.reloadKey.getKeyCode()) && (getMag(stack) < mainConfig.ammoCap || hasInfinity(stack, mainConfig))) { + if(GameSettings.isKeyDown(HbmKeybinds.reloadKey) && (getMag(stack) < mainConfig.ammoCap || hasInfinity(stack, mainConfig))) { PacketDispatcher.wrapper.sendToServer(new GunButtonPacket(true, (byte) 2)); setIsReloading(stack, true); resetReloadCycle(stack); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java index abee64b9c..0df7de4a3 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemfac.java @@ -43,6 +43,10 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { if(!worldObj.isRemote) { + if(worldObj.getTotalWorldTime() % 20 == 0) { + this.updateConnections(); + } + this.speed = 100; this.consumption = 100; @@ -150,6 +154,22 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase { public long getMaxPower() { return 10_000_000; } + + private void updateConnections() { + + ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); + ForgeDirection rot = dir.getRotation(ForgeDirection.DOWN); + + for(int i = 0; i < 6; i++) { + this.trySubscribe(worldObj, xCoord + dir.offsetX * (2 - i) + rot.offsetX * 3, yCoord + 4, zCoord + dir.offsetZ * (2 - i) + rot.offsetZ * 3, rot); + this.trySubscribe(worldObj, xCoord + dir.offsetX * (2 - i) - rot.offsetX * 2, yCoord + 4, zCoord + dir.offsetZ * (2 - i) - rot.offsetZ * 2, rot.getOpposite()); + + for(int j = 0; j < 2; j++) { + this.trySubscribe(worldObj, xCoord + dir.offsetX * (2 - i) + rot.offsetX * 5, yCoord + 1 + j, zCoord + dir.offsetZ * (2 - i) + rot.offsetZ * 5, rot); + this.trySubscribe(worldObj, xCoord + dir.offsetX * (2 - i) - rot.offsetX * 4, yCoord + 1 + j, zCoord + dir.offsetZ * (2 - i) - rot.offsetZ * 4, rot.getOpposite()); + } + } + } @Override public void fillFluidInit(FluidType type) { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java index a78e4c83a..a55b976e8 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineChemplant.java @@ -18,8 +18,6 @@ import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType; import com.hbm.lib.Library; import com.hbm.main.MainRegistry; import com.hbm.sound.AudioWrapper; -import com.hbm.sound.nt.ISoundSourceTE; -import com.hbm.sound.nt.SoundWrapper; import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.util.InventoryUtil;