some fixes, a bit of the new fluid transfer code, updated forge to 1614

This commit is contained in:
Boblet 2022-03-14 16:34:52 +01:00
parent 6782663205
commit 9368b68280
11 changed files with 102 additions and 6 deletions

View File

@ -20,7 +20,7 @@ archivesBaseName = "HBM-NTM"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft { 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" runDir = "eclipse"
} }

View File

@ -1,5 +1,7 @@
package api.hbm.energy; 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. * 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 * @author hbm
@ -9,4 +11,20 @@ public interface IEnergyConductor extends IEnergyConnector {
public IPowerNet getPowerNet(); public IPowerNet getPowerNet();
public void setPowerNet(IPowerNet network); 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;
}
} }

View File

@ -17,7 +17,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public interface IEnergyConnector { 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 * @param power
* @return * @return
*/ */

View File

@ -20,6 +20,14 @@ public interface IPowerNet {
public void destroy(); 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 boolean isValid();
public List<IEnergyConductor> getLinks(); public List<IEnergyConductor> getLinks();

View File

@ -128,4 +128,7 @@ public class PowerNet implements IPowerNet {
return power - totalGiven; return power - totalGiven;
} }
@Override
public void reevaluate() { }
} }

View File

@ -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);
}

View File

@ -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);
}

View File

@ -0,0 +1,8 @@
package api.hbm.fluid;
import api.hbm.energy.IPowerNet;
public interface IPipeNet {
public void joinNetworks(IPowerNet network);
}

View File

@ -2,7 +2,6 @@ package com.hbm.items.weapon;
import java.util.List; import java.util.List;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
import com.hbm.config.GeneralConfig; import com.hbm.config.GeneralConfig;
@ -26,6 +25,7 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.GameSettings;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity; 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(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)); PacketDispatcher.wrapper.sendToServer(new GunButtonPacket(true, (byte) 2));
setIsReloading(stack, true); setIsReloading(stack, true);
resetReloadCycle(stack); resetReloadCycle(stack);

View File

@ -43,6 +43,10 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
if(worldObj.getTotalWorldTime() % 20 == 0) {
this.updateConnections();
}
this.speed = 100; this.speed = 100;
this.consumption = 100; this.consumption = 100;
@ -150,6 +154,22 @@ public class TileEntityMachineChemfac extends TileEntityMachineChemplantBase {
public long getMaxPower() { public long getMaxPower() {
return 10_000_000; 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 @Override
public void fillFluidInit(FluidType type) { public void fillFluidInit(FluidType type) {

View File

@ -18,8 +18,6 @@ import com.hbm.items.machine.ItemMachineUpgrade.UpgradeType;
import com.hbm.lib.Library; import com.hbm.lib.Library;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import com.hbm.sound.AudioWrapper; 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.tileentity.TileEntityMachineBase;
import com.hbm.util.InventoryUtil; import com.hbm.util.InventoryUtil;