Wire code cleanup!
This commit is contained in:
parent
6781af7447
commit
054cba30e3
9 changed files with 313 additions and 266 deletions
|
@ -9,23 +9,26 @@ import codechicken.multipart.TMultiPart;
|
|||
|
||||
public class MultipartMI implements IPartFactory
|
||||
{
|
||||
|
||||
public MultipartMI()
|
||||
{
|
||||
this.init();
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart createPart(String name, boolean client)
|
||||
{
|
||||
if (name == "resonant_induction_wire")
|
||||
if(name == "resonant_induction_wire")
|
||||
{
|
||||
return new PartWire(EnumWireMaterial.COPPER.ordinal());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
MultiPartRegistry.registerParts(this, new String[] { "resonant_induction_wire" });
|
||||
MultiPartRegistry.registerParts(this, new String[] {"resonant_induction_wire"});
|
||||
|
||||
MultipartGenerator.registerPassThroughInterface("universalelectricity.core.block.IConductor");
|
||||
MultipartGenerator.registerPassThroughInterface("buildcraft.api.power.IPowerReceptor");
|
||||
MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler");
|
||||
|
@ -33,5 +36,4 @@ public class MultipartMI implements IPartFactory
|
|||
MultipartGenerator.registerPassThroughInterface("mekanism.induction.common.wire.IBlockableConnection");
|
||||
MultipartGenerator.registerTrait("ic2.api.energy.tile.IEnergySink", "mekanism.induction.common.wire.TEnergySink");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,42 +28,43 @@ public enum EnumWireMaterial
|
|||
public final Vector3 color;
|
||||
private ItemStack wire;
|
||||
|
||||
EnumWireMaterial(float resistance, float electrocutionDamage, float maxAmps, Vector3 color)
|
||||
EnumWireMaterial(float resist, float electrocution, float max, Vector3 vec)
|
||||
{
|
||||
this.resistance = resistance;
|
||||
this.damage = electrocutionDamage;
|
||||
this.maxAmps = maxAmps;
|
||||
this.color = color.scale(1D / 255D);
|
||||
resistance = resist;
|
||||
damage = electrocution;
|
||||
maxAmps = max;
|
||||
color = vec.scale(1D / 255D);
|
||||
}
|
||||
|
||||
public ItemStack getWire()
|
||||
{
|
||||
return this.getWire(1);
|
||||
return getWire(1);
|
||||
}
|
||||
|
||||
public ItemStack getWire(int amount)
|
||||
{
|
||||
ItemStack returnStack = this.wire.copy();
|
||||
ItemStack returnStack = wire.copy();
|
||||
returnStack.stackSize = amount;
|
||||
|
||||
return returnStack;
|
||||
}
|
||||
|
||||
public void setWire(ItemStack item)
|
||||
{
|
||||
if (this.wire == null)
|
||||
if(wire == null)
|
||||
{
|
||||
this.wire = item;
|
||||
OreDictionary.registerOre(this.name().toLowerCase() + "Wire", this.wire);
|
||||
wire = item;
|
||||
OreDictionary.registerOre(name().toLowerCase() + "Wire", wire);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWire(Item item)
|
||||
{
|
||||
this.setWire(new ItemStack(item, 1, this.ordinal()));
|
||||
setWire(new ItemStack(item, 1, ordinal()));
|
||||
}
|
||||
|
||||
public void setWire(Block block)
|
||||
{
|
||||
this.setWire(new ItemStack(block, 1, this.ordinal()));
|
||||
setWire(new ItemStack(block, 1, ordinal()));
|
||||
}
|
||||
}
|
|
@ -8,5 +8,5 @@ public interface IInsulation
|
|||
|
||||
public int getInsulationColor();
|
||||
|
||||
public void setInsulationColor(int dyeID);
|
||||
public void setInsulationColor(int dye);
|
||||
}
|
||||
|
|
|
@ -28,16 +28,16 @@ public class ItemPartWire extends JItemMultiPart
|
|||
public ItemPartWire(int id)
|
||||
{
|
||||
super(Mekanism.configuration.get(Configuration.CATEGORY_ITEM, "wireMultipart", id).getInt(id));
|
||||
this.setUnlocalizedName(MekanismInduction.PREFIX + "wire");
|
||||
this.setCreativeTab(Mekanism.tabMekanism);
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
setUnlocalizedName(MekanismInduction.PREFIX + "wire");
|
||||
setCreativeTab(Mekanism.tabMekanism);
|
||||
setHasSubtypes(true);
|
||||
setMaxDamage(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMultiPart newPart(ItemStack arg0, EntityPlayer arg1, World arg2, BlockCoord arg3, int arg4, Vector3 arg5)
|
||||
{
|
||||
return new PartWire(this.getDamage(arg0));
|
||||
return new PartWire(getDamage(arg0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +55,7 @@ public class ItemPartWire extends JItemMultiPart
|
|||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemStack)
|
||||
{
|
||||
return this.getUnlocalizedName() + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].name().toLowerCase();
|
||||
return getUnlocalizedName() + "." + EnumWireMaterial.values()[itemStack.getItemDamage()].name().toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,9 +69,9 @@ public class ItemPartWire extends JItemMultiPart
|
|||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconRegister)
|
||||
{
|
||||
for (int i = 0; i < EnumWireMaterial.values().length; i++)
|
||||
for(int i = 0; i < EnumWireMaterial.values().length; i++)
|
||||
{
|
||||
this.icons[i] = iconRegister.registerIcon(this.getUnlocalizedName(new ItemStack(this.itemID, 1, i)).replaceAll("tile.", ""));
|
||||
icons[i] = iconRegister.registerIcon(getUnlocalizedName(new ItemStack(itemID, 1, i)).replaceAll("tile.", ""));
|
||||
}
|
||||
|
||||
RenderPartWire.registerIcons(iconRegister);
|
||||
|
@ -81,13 +81,13 @@ public class ItemPartWire extends JItemMultiPart
|
|||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIconFromDamage(int meta)
|
||||
{
|
||||
return this.icons[meta];
|
||||
return icons[meta];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
|
||||
{
|
||||
for (EnumWireMaterial mat : EnumWireMaterial.values())
|
||||
for(EnumWireMaterial mat : EnumWireMaterial.values())
|
||||
{
|
||||
listToAddTo.add(new ItemStack(itemID, 1, mat.ordinal()));
|
||||
}
|
||||
|
@ -99,5 +99,4 @@ public class ItemPartWire extends JItemMultiPart
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,29 +11,27 @@ public abstract class PartAdvanced extends TMultiPart
|
|||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (this.ticks == 0)
|
||||
if(ticks == 0)
|
||||
{
|
||||
this.initiate();
|
||||
initiate();
|
||||
}
|
||||
|
||||
if (this.ticks >= Long.MAX_VALUE)
|
||||
if(ticks >= Long.MAX_VALUE)
|
||||
{
|
||||
this.ticks = 1;
|
||||
ticks = 1;
|
||||
}
|
||||
|
||||
this.ticks++;
|
||||
ticks++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdded()
|
||||
{
|
||||
world().notifyBlocksOfNeighborChange(x(), y(), z(), ((Block) MultipartProxy.block()).blockID);
|
||||
world().notifyBlocksOfNeighborChange(x(), y(), z(), ((Block)MultipartProxy.block()).blockID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on the TileEntity's first tick.
|
||||
*/
|
||||
public void initiate()
|
||||
{
|
||||
}
|
||||
public void initiate() {}
|
||||
}
|
||||
|
|
|
@ -33,14 +33,13 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
@Override
|
||||
public void bind(TileMultipart t)
|
||||
{
|
||||
if (tile() != null && network != null)
|
||||
if(tile() != null && network != null)
|
||||
{
|
||||
this.getNetwork().getConductors().remove(tile());
|
||||
getNetwork().getConductors().remove(tile());
|
||||
super.bind(t);
|
||||
this.getNetwork().getConductors().add((IConductor) tile());
|
||||
getNetwork().getConductors().add((IConductor) tile());
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
super.bind(t);
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +47,9 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
@Override
|
||||
public void preRemove()
|
||||
{
|
||||
if (!this.world().isRemote && this.tile() instanceof IConductor)
|
||||
if(!world().isRemote && tile() instanceof IConductor)
|
||||
{
|
||||
this.getNetwork().split((IConductor) this.tile());
|
||||
getNetwork().split((IConductor) tile());
|
||||
}
|
||||
|
||||
super.preRemove();
|
||||
|
@ -65,29 +64,30 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
@Override
|
||||
public IElectricityNetwork getNetwork()
|
||||
{
|
||||
if (this.network == null && this.tile() instanceof IConductor)
|
||||
if(network == null && tile() instanceof IConductor)
|
||||
{
|
||||
this.setNetwork(NetworkLoader.getNewNetwork((IConductor) this.tile()));
|
||||
setNetwork(NetworkLoader.getNewNetwork((IConductor)tile()));
|
||||
}
|
||||
|
||||
return this.network;
|
||||
return network;
|
||||
}
|
||||
|
||||
public boolean canConnectBothSides(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
boolean notPrevented = !this.isConnectionPrevented(tile, side);
|
||||
boolean notPrevented = !isConnectionPrevented(tile, side);
|
||||
|
||||
if (tile instanceof IConnector)
|
||||
if(tile instanceof IConnector)
|
||||
{
|
||||
notPrevented &= ((IConnector) tile).canConnect(side.getOpposite());
|
||||
notPrevented &= ((IConnector)tile).canConnect(side.getOpposite());
|
||||
}
|
||||
|
||||
return notPrevented;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNetwork(IElectricityNetwork network)
|
||||
public void setNetwork(IElectricityNetwork net)
|
||||
{
|
||||
this.network = network;
|
||||
network = net;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,12 +106,16 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), side);
|
||||
if (tileEntity instanceof INetworkProvider && this.canConnectBothSides(tileEntity, side))
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if(tileEntity instanceof INetworkProvider && canConnectBothSides(tileEntity, side))
|
||||
{
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
|
@ -119,12 +123,16 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
{
|
||||
byte connections = 0x00;
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), side);
|
||||
if (this.isValidAcceptor(tileEntity) && this.canConnectBothSides(tileEntity, side))
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if(isValidAcceptor(tileEntity) && canConnectBothSides(tileEntity, side))
|
||||
{
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
return connections;
|
||||
}
|
||||
|
||||
|
@ -139,44 +147,46 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
@Override
|
||||
public void refresh()
|
||||
{
|
||||
if (!this.world().isRemote)
|
||||
if(!world().isRemote)
|
||||
{
|
||||
this.adjacentConnections = null;
|
||||
adjacentConnections = null;
|
||||
|
||||
byte possibleWireConnections = getPossibleWireConnections();
|
||||
byte possibleAcceptorConnections = getPossibleAcceptorConnections();
|
||||
|
||||
if (possibleWireConnections != currentWireConnections)
|
||||
if(possibleWireConnections != currentWireConnections)
|
||||
{
|
||||
byte or = (byte) (possibleWireConnections | currentWireConnections);
|
||||
if (or != possibleWireConnections) // Connections have been removed
|
||||
|
||||
if(or != possibleWireConnections) // Connections have been removed
|
||||
{
|
||||
this.getNetwork().split((IConductor) tile());
|
||||
this.setNetwork(null);
|
||||
getNetwork().split((IConductor) tile());
|
||||
setNetwork(null);
|
||||
}
|
||||
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (connectionMapContainsSide(possibleWireConnections, side))
|
||||
if(connectionMapContainsSide(possibleWireConnections, side))
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(this.world(), new Vector3(tile()), side);
|
||||
TileEntity tileEntity = VectorHelper.getConnectorFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if (tileEntity instanceof INetworkProvider)
|
||||
if(tileEntity instanceof INetworkProvider)
|
||||
{
|
||||
this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork());
|
||||
getNetwork().merge(((INetworkProvider) tileEntity).getNetwork());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.currentWireConnections = possibleWireConnections;
|
||||
currentWireConnections = possibleWireConnections;
|
||||
}
|
||||
|
||||
this.currentAcceptorConnections = possibleAcceptorConnections;
|
||||
currentAcceptorConnections = possibleAcceptorConnections;
|
||||
|
||||
this.getNetwork().refresh();
|
||||
this.sendDescUpdate();
|
||||
getNetwork().refresh();
|
||||
sendDescUpdate();
|
||||
}
|
||||
|
||||
this.tile().markRender();
|
||||
tile().markRender();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,27 +196,27 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
{
|
||||
if (this.adjacentConnections == null)
|
||||
if(adjacentConnections == null)
|
||||
{
|
||||
this.adjacentConnections = new TileEntity[6];
|
||||
adjacentConnections = new TileEntity[6];
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), side);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), side);
|
||||
|
||||
if (isCurrentlyConnected(side))
|
||||
if(isCurrentlyConnected(side))
|
||||
{
|
||||
adjacentConnections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.adjacentConnections;
|
||||
return adjacentConnections;
|
||||
}
|
||||
|
||||
public boolean isCurrentlyConnected(ForgeDirection side)
|
||||
{
|
||||
return connectionMapContainsSide(this.getAllCurrentConnections(), side);
|
||||
return connectionMapContainsSide(getAllCurrentConnections(), side);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,7 +226,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
Vector3 connectPos = new Vector3(tile()).modifyPositionFromSide(direction);
|
||||
TileEntity connectTile = connectPos.getTileEntity(this.world());
|
||||
TileEntity connectTile = connectPos.getTileEntity(world());
|
||||
return !isConnectionPrevented(connectTile, direction);
|
||||
}
|
||||
|
||||
|
@ -224,20 +234,20 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
|||
public void onAdded()
|
||||
{
|
||||
super.onAdded();
|
||||
this.refresh();
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkLoad()
|
||||
{
|
||||
super.onChunkLoad();
|
||||
this.refresh();
|
||||
refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged()
|
||||
{
|
||||
super.onNeighborChanged();
|
||||
this.refresh();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,30 +24,29 @@ import cofh.api.energy.IEnergyHandler;
|
|||
|
||||
public abstract class PartUniversalConductor extends PartConductor implements IEnergySink, IPowerReceptor, IEnergyHandler
|
||||
{
|
||||
|
||||
protected boolean isAddedToEnergyNet;
|
||||
public PowerHandler powerHandler;
|
||||
public float buildcraftBuffer = Compatibility.BC3_RATIO * 50;
|
||||
|
||||
public PartUniversalConductor()
|
||||
{
|
||||
this.powerHandler = new PowerHandler(this, Type.PIPE);
|
||||
this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2);
|
||||
this.powerHandler.configurePowerPerdition(0, 0);
|
||||
powerHandler = new PowerHandler(this, Type.PIPE);
|
||||
powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2);
|
||||
powerHandler.configurePowerPerdition(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidAcceptor(TileEntity tile)
|
||||
{
|
||||
if (tile instanceof IEnergyTile)
|
||||
if(tile instanceof IEnergyTile)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (tile instanceof IPowerReceptor)
|
||||
else if(tile instanceof IPowerReceptor)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (tile instanceof IEnergyHandler)
|
||||
else if(tile instanceof IEnergyHandler)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
@Override
|
||||
public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
if (tile instanceof IEnergyHandler)
|
||||
if(tile instanceof IEnergyHandler)
|
||||
{
|
||||
return !((IEnergyHandler) tile).canInterface(side);
|
||||
}
|
||||
|
@ -70,11 +69,12 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
public void onWorldJoin()
|
||||
{
|
||||
super.onWorldJoin();
|
||||
if (!this.world().isRemote)
|
||||
|
||||
if(!world().isRemote)
|
||||
{
|
||||
if (!this.isAddedToEnergyNet)
|
||||
if(!isAddedToEnergyNet)
|
||||
{
|
||||
this.initIC();
|
||||
initIC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,11 +83,12 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
public void onAdded()
|
||||
{
|
||||
super.onAdded();
|
||||
if (!this.world().isRemote)
|
||||
|
||||
if(!world().isRemote)
|
||||
{
|
||||
if (!this.isAddedToEnergyNet)
|
||||
if(!isAddedToEnergyNet)
|
||||
{
|
||||
this.initIC();
|
||||
initIC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,11 +97,12 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
public void onChunkLoad()
|
||||
{
|
||||
super.onChunkLoad();
|
||||
if (!this.world().isRemote)
|
||||
|
||||
if(!world().isRemote)
|
||||
{
|
||||
if (!this.isAddedToEnergyNet)
|
||||
if(!isAddedToEnergyNet)
|
||||
{
|
||||
this.initIC();
|
||||
initIC();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,69 +110,67 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
@Override
|
||||
public void onWorldSeparate()
|
||||
{
|
||||
this.unloadTileIC2();
|
||||
unloadTileIC2();
|
||||
super.onWorldSeparate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
this.unloadTileIC2();
|
||||
unloadTileIC2();
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved()
|
||||
{
|
||||
}
|
||||
public void onRemoved() {}
|
||||
|
||||
@Override
|
||||
public void preRemove()
|
||||
{
|
||||
this.unloadTileIC2();
|
||||
unloadTileIC2();
|
||||
super.preRemove();
|
||||
}
|
||||
|
||||
protected void initIC()
|
||||
{
|
||||
if (Compatibility.isIndustrialCraft2Loaded())
|
||||
if(Compatibility.isIndustrialCraft2Loaded())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) tile()));
|
||||
}
|
||||
|
||||
this.isAddedToEnergyNet = true;
|
||||
isAddedToEnergyNet = true;
|
||||
}
|
||||
|
||||
private void unloadTileIC2()
|
||||
{
|
||||
if (this.isAddedToEnergyNet && this.world() != null)
|
||||
if(isAddedToEnergyNet && world() != null)
|
||||
{
|
||||
if (Compatibility.isIndustrialCraft2Loaded())
|
||||
if(Compatibility.isIndustrialCraft2Loaded())
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) tile()));
|
||||
}
|
||||
|
||||
this.isAddedToEnergyNet = false;
|
||||
isAddedToEnergyNet = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
if (this.getNetwork() == null)
|
||||
if(getNetwork() == null)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return this.getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_IC2_RATIO;
|
||||
return getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_IC2_RATIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
|
||||
{
|
||||
TileEntity tile = VectorHelper.getTileEntityFromSide(this.world(), new Vector3(tile()), directionFrom);
|
||||
TileEntity tile = VectorHelper.getTileEntityFromSide(world(), new Vector3(tile()), directionFrom);
|
||||
ElectricityPack pack = ElectricityPack.getFromWatts((float) (amount * Compatibility.IC2_RATIO), 120);
|
||||
return this.getNetwork().produce(pack, tile(), tile) * Compatibility.TO_IC2_RATIO;
|
||||
return getNetwork().produce(pack, tile(), tile) * Compatibility.TO_IC2_RATIO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,7 +191,7 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side)
|
||||
{
|
||||
return this.powerHandler.getPowerReceiver();
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -200,14 +200,14 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
Set<TileEntity> ignoreTiles = new HashSet<TileEntity>();
|
||||
ignoreTiles.add(tile());
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = new Vector3(tile()).modifyPositionFromSide(direction).getTileEntity(this.world());
|
||||
TileEntity tile = new Vector3(tile()).modifyPositionFromSide(direction).getTileEntity(world());
|
||||
ignoreTiles.add(tile);
|
||||
}
|
||||
|
||||
ElectricityPack pack = ElectricityPack.getFromWatts(workProvider.useEnergy(0, this.getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_BC_RATIO, true) * Compatibility.BC3_RATIO, 120);
|
||||
this.getNetwork().produce(pack, ignoreTiles.toArray(new TileEntity[0]));
|
||||
ElectricityPack pack = ElectricityPack.getFromWatts(workProvider.useEnergy(0, getNetwork().getRequest(tile()).getWatts() * Compatibility.TO_BC_RATIO, true) * Compatibility.BC3_RATIO, 120);
|
||||
getNetwork().produce(pack, ignoreTiles.toArray(new TileEntity[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -223,19 +223,19 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
|
||||
{
|
||||
ElectricityPack pack = ElectricityPack.getFromWatts(maxReceive * Compatibility.TE_RATIO, 1);
|
||||
float request = this.getMaxEnergyStored(from);
|
||||
float request = getMaxEnergyStored(from);
|
||||
|
||||
if (!simulate)
|
||||
if(!simulate)
|
||||
{
|
||||
if (request > 0)
|
||||
if(request > 0)
|
||||
{
|
||||
return (int) (maxReceive - (this.getNetwork().produce(pack, new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(this.world())) * Compatibility.TO_TE_RATIO));
|
||||
return (int) (maxReceive - (getNetwork().produce(pack, new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world())) * Compatibility.TO_TE_RATIO));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int) Math.min(maxReceive, request * Compatibility.TO_TE_RATIO);
|
||||
return (int)Math.min(maxReceive, request * Compatibility.TO_TE_RATIO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -259,6 +259,6 @@ public abstract class PartUniversalConductor extends PartConductor implements IE
|
|||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from)
|
||||
{
|
||||
return (int) (this.getNetwork().getRequest(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(this.world())).getWatts() * Compatibility.TO_TE_RATIO);
|
||||
return (int)Math.round(getNetwork().getRequest(new Vector3(tile()).modifyPositionFromSide(from).getTileEntity(world())).getWatts() * Compatibility.TO_TE_RATIO);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,14 +49,14 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
|
|||
public static final int DEFAULT_COLOR = 16;
|
||||
public int dyeID = DEFAULT_COLOR;
|
||||
public boolean isInsulated = false;
|
||||
|
||||
|
||||
public static IndexedCuboid6[] sides = new IndexedCuboid6[7];
|
||||
public static IndexedCuboid6[] insulatedSides = new IndexedCuboid6[7];
|
||||
public EnumWireMaterial material = EnumWireMaterial.COPPER;
|
||||
|
||||
|
||||
/** Client Side Connection Check */
|
||||
private ForgeDirection testingSide;
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
sides[0] = new IndexedCuboid6(0, new Cuboid6(0.36, 0.000, 0.36, 0.64, 0.36, 0.64));
|
||||
|
@ -74,382 +74,402 @@ public class PartWire extends PartUniversalConductor implements TSlottedPart, JN
|
|||
insulatedSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7));
|
||||
insulatedSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7));
|
||||
}
|
||||
|
||||
|
||||
public PartWire(int typeID)
|
||||
{
|
||||
this(EnumWireMaterial.values()[typeID]);
|
||||
}
|
||||
|
||||
|
||||
public PartWire(EnumWireMaterial type)
|
||||
{
|
||||
super();
|
||||
this.material = type;
|
||||
material = type;
|
||||
}
|
||||
|
||||
|
||||
public PartWire()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return super.canConnect(direction);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isConnectionPrevented(TileEntity tile, ForgeDirection side)
|
||||
{
|
||||
if (tile instanceof IWireMaterial)
|
||||
if(tile instanceof IWireMaterial)
|
||||
{
|
||||
IWireMaterial wireTile = (IWireMaterial) tile;
|
||||
|
||||
if (wireTile.getMaterial() != this.getMaterial())
|
||||
IWireMaterial wireTile = (IWireMaterial)tile;
|
||||
|
||||
if(wireTile.getMaterial() != getMaterial())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isInsulated() && tile instanceof IInsulation)
|
||||
|
||||
if(isInsulated() && tile instanceof IInsulation)
|
||||
{
|
||||
IInsulation insulatedTile = (IInsulation) tile;
|
||||
|
||||
if ((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != this.getInsulationColor() && this.getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR))
|
||||
IInsulation insulatedTile = (IInsulation)tile;
|
||||
|
||||
if((insulatedTile.isInsulated() && insulatedTile.getInsulationColor() != getInsulationColor() && getInsulationColor() != DEFAULT_COLOR && insulatedTile.getInsulationColor() != DEFAULT_COLOR))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return (this.isBlockedOnSide(side) || tile instanceof IBlockableConnection && ((IBlockableConnection) tile).isBlockedOnSide(side.getOpposite()));
|
||||
|
||||
return (isBlockedOnSide(side) || tile instanceof IBlockableConnection && ((IBlockableConnection)tile).isBlockedOnSide(side.getOpposite()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte getPossibleWireConnections()
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
return super.getPossibleWireConnections();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte getPossibleAcceptorConnections()
|
||||
{
|
||||
if (this.world().isBlockIndirectlyGettingPowered(this.x(), this.y(), this.z()))
|
||||
if(world().isBlockIndirectlyGettingPowered(x(), y(), z()))
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
|
||||
return super.getPossibleAcceptorConnections();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getResistance()
|
||||
{
|
||||
return getMaterial().resistance;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getCurrentCapacity()
|
||||
{
|
||||
return getMaterial().maxAmps;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumWireMaterial getMaterial()
|
||||
{
|
||||
return material;
|
||||
}
|
||||
|
||||
|
||||
public int getTypeID()
|
||||
{
|
||||
return material.ordinal();
|
||||
}
|
||||
|
||||
public void setDye(int dyeID)
|
||||
|
||||
public void setDye(int dye)
|
||||
{
|
||||
this.dyeID = dyeID;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
dyeID = dye;
|
||||
refresh();
|
||||
world().markBlockForUpdate(x(), y(), z());
|
||||
}
|
||||
|
||||
|
||||
public void setMaterialFromID(int id)
|
||||
{
|
||||
this.material = EnumWireMaterial.values()[id];
|
||||
material = EnumWireMaterial.values()[id];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider)
|
||||
{
|
||||
this.buildcraftBuffer = Compatibility.BC3_RATIO * 25 * Math.min(this.getMaterial().maxAmps, 100);
|
||||
this.powerHandler.configure(0, this.buildcraftBuffer, this.buildcraftBuffer, this.buildcraftBuffer * 2);
|
||||
buildcraftBuffer = Compatibility.BC3_RATIO * 25 * Math.min(getMaterial().maxAmps, 100);
|
||||
powerHandler.configure(0, buildcraftBuffer, buildcraftBuffer, buildcraftBuffer * 2);
|
||||
|
||||
super.doWork(workProvider);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "resonant_induction_wire";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean occlusionTest(TMultiPart other)
|
||||
{
|
||||
return NormalOcclusionTest.apply(this, other);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<IndexedCuboid6> getSubParts()
|
||||
{
|
||||
Set<IndexedCuboid6> subParts = new HashSet<IndexedCuboid6>();
|
||||
IndexedCuboid6[] currentSides = this.isInsulated() ? insulatedSides : sides;
|
||||
if (tile() != null)
|
||||
IndexedCuboid6[] currentSides = isInsulated() ? insulatedSides : sides;
|
||||
|
||||
if(tile() != null)
|
||||
{
|
||||
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
int ord = side.ordinal();
|
||||
if (connectionMapContainsSide(getAllCurrentConnections(), side) || side == this.testingSide)
|
||||
if(connectionMapContainsSide(getAllCurrentConnections(), side) || side == testingSide)
|
||||
subParts.add(currentSides[ord]);
|
||||
}
|
||||
}
|
||||
|
||||
subParts.add(currentSides[6]);
|
||||
return subParts;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getCollisionBoxes()
|
||||
{
|
||||
Set<Cuboid6> collisionBoxes = new HashSet<Cuboid6>();
|
||||
collisionBoxes.addAll((Collection<? extends Cuboid6>) getSubParts());
|
||||
collisionBoxes.addAll((Collection<? extends Cuboid6>)getSubParts());
|
||||
|
||||
return collisionBoxes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<ItemStack> getDrops()
|
||||
{
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
drops.add(pickItem(null));
|
||||
if (isInsulated)
|
||||
|
||||
if(isInsulated)
|
||||
{
|
||||
drops.add(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID)));
|
||||
}
|
||||
|
||||
return drops;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getStrength(MovingObjectPosition hit, EntityPlayer player)
|
||||
{
|
||||
return 10F;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderStatic(codechicken.lib.vec.Vector3 pos, LazyLightMatrix olm, int pass)
|
||||
{
|
||||
if (pass == 0)
|
||||
if(pass == 0)
|
||||
{
|
||||
RenderPartWire.INSTANCE.renderStatic(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderDynamic(codechicken.lib.vec.Vector3 pos, float frame, int pass)
|
||||
{
|
||||
if (MekanismInduction.SHINY_SILVER && this.getMaterial() == EnumWireMaterial.SILVER)
|
||||
if(MekanismInduction.SHINY_SILVER && getMaterial() == EnumWireMaterial.SILVER)
|
||||
{
|
||||
RenderPartWire.INSTANCE.renderShine(this, pos.x, pos.y, pos.z, frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void drawBreaking(RenderBlocks renderBlocks)
|
||||
{
|
||||
CCRenderState.reset();
|
||||
RenderUtils.renderBlock(sides[6], 0, new Translation(x(), y(), z()), new IconTransformation(renderBlocks.overrideBlockTexture), null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void readDesc(MCDataInput packet)
|
||||
{
|
||||
this.setMaterialFromID(packet.readInt());
|
||||
this.dyeID = packet.readInt();
|
||||
this.isInsulated = packet.readBoolean();
|
||||
this.currentWireConnections = packet.readByte();
|
||||
this.currentAcceptorConnections = packet.readByte();
|
||||
if (tile() != null)
|
||||
setMaterialFromID(packet.readInt());
|
||||
dyeID = packet.readInt();
|
||||
isInsulated = packet.readBoolean();
|
||||
currentWireConnections = packet.readByte();
|
||||
currentAcceptorConnections = packet.readByte();
|
||||
|
||||
if(tile() != null)
|
||||
{
|
||||
tile().markRender();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeDesc(MCDataOutput packet)
|
||||
{
|
||||
packet.writeInt(this.getTypeID());
|
||||
packet.writeInt(this.dyeID);
|
||||
packet.writeBoolean(this.isInsulated);
|
||||
packet.writeByte(this.currentWireConnections);
|
||||
packet.writeByte(this.currentAcceptorConnections);
|
||||
packet.writeInt(getTypeID());
|
||||
packet.writeInt(dyeID);
|
||||
packet.writeBoolean(isInsulated);
|
||||
packet.writeByte(currentWireConnections);
|
||||
packet.writeByte(currentAcceptorConnections);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound nbt)
|
||||
{
|
||||
super.save(nbt);
|
||||
nbt.setInteger("typeID", this.getTypeID());
|
||||
nbt.setInteger("dyeID", this.dyeID);
|
||||
nbt.setBoolean("isInsulated", this.isInsulated);
|
||||
nbt.setInteger("typeID", getTypeID());
|
||||
nbt.setInteger("dyeID", dyeID);
|
||||
nbt.setBoolean("isInsulated", isInsulated);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound nbt)
|
||||
{
|
||||
super.load(nbt);
|
||||
this.setMaterialFromID(nbt.getInteger("typeID"));
|
||||
this.dyeID = nbt.getInteger("dyeID");
|
||||
this.isInsulated = nbt.getBoolean("isInsulated");
|
||||
setMaterialFromID(nbt.getInteger("typeID"));
|
||||
dyeID = nbt.getInteger("dyeID");
|
||||
isInsulated = nbt.getBoolean("isInsulated");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack pickItem(MovingObjectPosition hit)
|
||||
{
|
||||
return EnumWireMaterial.values()[this.getTypeID()].getWire();
|
||||
return EnumWireMaterial.values()[getTypeID()].getWire();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item)
|
||||
{
|
||||
if (item != null)
|
||||
if(item != null)
|
||||
{
|
||||
if (item.itemID == Item.dyePowder.itemID && isInsulated())
|
||||
if(item.itemID == Item.dyePowder.itemID && isInsulated())
|
||||
{
|
||||
setDye(item.getItemDamage());
|
||||
return true;
|
||||
}
|
||||
else if (item.itemID == Block.cloth.blockID)
|
||||
else if(item.itemID == Block.cloth.blockID)
|
||||
{
|
||||
if (isInsulated() && !world().isRemote)
|
||||
if(isInsulated() && !world().isRemote)
|
||||
{
|
||||
this.tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))));
|
||||
tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))));
|
||||
}
|
||||
this.setInsulated(BlockColored.getDyeFromBlock(item.getItemDamage()));
|
||||
setInsulated(BlockColored.getDyeFromBlock(item.getItemDamage()));
|
||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||
return true;
|
||||
}
|
||||
else if ((item.itemID == Item.shears.itemID || item.getItem() instanceof ItemShears) && this.isInsulated())
|
||||
else if((item.itemID == Item.shears.itemID || item.getItem() instanceof ItemShears) && isInsulated())
|
||||
{
|
||||
if (!this.world().isRemote)
|
||||
if(!world().isRemote)
|
||||
{
|
||||
this.tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))));
|
||||
tile().dropItems(Collections.singletonList(new ItemStack(Block.cloth, 1, BlockColored.getBlockFromDye(dyeID))));
|
||||
}
|
||||
|
||||
this.setInsulated(false);
|
||||
|
||||
setInsulated(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<Cuboid6> getOcclusionBoxes()
|
||||
{
|
||||
return getCollisionBoxes();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSlotMask()
|
||||
{
|
||||
return PartMap.CENTER.mask;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getHollowSize()
|
||||
{
|
||||
return this.isInsulated ? 8 : 6;
|
||||
return isInsulated ? 8 : 6;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isInsulated()
|
||||
{
|
||||
return isInsulated;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getInsulationColor()
|
||||
{
|
||||
return isInsulated ? dyeID : -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setInsulationColor(int dyeID)
|
||||
public void setInsulationColor(int dye)
|
||||
{
|
||||
this.dyeID = dyeID;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
dyeID = dye;
|
||||
refresh();
|
||||
world().markBlockForUpdate(x(), y(), z());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setInsulated(boolean insulated)
|
||||
{
|
||||
this.isInsulated = insulated;
|
||||
this.dyeID = DEFAULT_COLOR;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
this.tile().notifyPartChange(this);
|
||||
isInsulated = insulated;
|
||||
dyeID = DEFAULT_COLOR;
|
||||
refresh();
|
||||
world().markBlockForUpdate(x(), y(), z());
|
||||
tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
|
||||
public void setInsulated(int dyeColour)
|
||||
{
|
||||
this.isInsulated = true;
|
||||
this.dyeID = dyeColour;
|
||||
this.refresh();
|
||||
this.world().markBlockForUpdate(this.x(), this.y(), this.z());
|
||||
this.tile().notifyPartChange(this);
|
||||
isInsulated = true;
|
||||
dyeID = dyeColour;
|
||||
refresh();
|
||||
world().markBlockForUpdate(x(), y(), z());
|
||||
tile().notifyPartChange(this);
|
||||
}
|
||||
|
||||
|
||||
public void setInsulated()
|
||||
{
|
||||
setInsulated(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Cuboid6 getBounds()
|
||||
{
|
||||
return new Cuboid6(0.375, 0.375, 0.375, 0.625, 0.625, 0.625);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getBreakingIcon(Object subPart, int side)
|
||||
{
|
||||
return RenderPartWire.breakIcon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Icon getBrokenIcon(int side)
|
||||
{
|
||||
return RenderPartWire.breakIcon;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer)
|
||||
{
|
||||
IconHitEffects.addHitEffects(this, hit, effectRenderer);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addDestroyEffects(EffectRenderer effectRenderer)
|
||||
{
|
||||
IconHitEffects.addDestroyEffects(this, effectRenderer, false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isBlockedOnSide(ForgeDirection side)
|
||||
{
|
||||
TMultiPart blocker = tile().partMap(side.ordinal());
|
||||
this.testingSide = side;
|
||||
testingSide = side;
|
||||
boolean expandable = NormalOcclusionTest.apply(this, blocker);
|
||||
this.testingSide = null;
|
||||
testingSide = null;
|
||||
return !expandable;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPartChanged(TMultiPart part)
|
||||
{
|
||||
this.refresh();
|
||||
refresh();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -18,41 +18,54 @@ public class TEnergySink extends TileMultipart implements IEnergySink
|
|||
public void copyFrom(TileMultipart that)
|
||||
{
|
||||
super.copyFrom(that);
|
||||
if (that instanceof TEnergySink)
|
||||
ic2Sinks = ((TEnergySink) that).ic2Sinks;
|
||||
|
||||
if(that instanceof TEnergySink)
|
||||
{
|
||||
ic2Sinks = ((TEnergySink)that).ic2Sinks;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindPart(TMultiPart part)
|
||||
{
|
||||
super.bindPart(part);
|
||||
if (part instanceof IEnergySink)
|
||||
|
||||
if(part instanceof IEnergySink)
|
||||
{
|
||||
ic2Sinks.add((IEnergySink) part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void partRemoved(TMultiPart part, int p)
|
||||
{
|
||||
super.partRemoved(part, p);
|
||||
if (part instanceof IEnergySink)
|
||||
|
||||
if(part instanceof IEnergySink)
|
||||
{
|
||||
ic2Sinks.remove(part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearParts()
|
||||
{
|
||||
super.clearParts();
|
||||
|
||||
ic2Sinks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
for(IEnergySink sink : ic2Sinks)
|
||||
{
|
||||
if (sink.acceptsEnergyFrom(emitter, direction))
|
||||
if(sink.acceptsEnergyFrom(emitter, direction))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -61,20 +74,22 @@ public class TEnergySink extends TileMultipart implements IEnergySink
|
|||
{
|
||||
double demanded = 0;
|
||||
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
for(IEnergySink sink : ic2Sinks)
|
||||
{
|
||||
demanded += sink.demandedEnergyUnits();
|
||||
}
|
||||
|
||||
return demanded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
|
||||
{
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
for(IEnergySink sink : ic2Sinks)
|
||||
{
|
||||
amount = sink.injectEnergyUnits(directionFrom, Math.min(amount, sink.demandedEnergyUnits()));
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
|
@ -82,10 +97,12 @@ public class TEnergySink extends TileMultipart implements IEnergySink
|
|||
public int getMaxSafeInput()
|
||||
{
|
||||
int safe = 0;
|
||||
for (IEnergySink sink : this.ic2Sinks)
|
||||
|
||||
for(IEnergySink sink : ic2Sinks)
|
||||
{
|
||||
safe += sink.getMaxSafeInput();
|
||||
}
|
||||
|
||||
return safe;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue