Fixed #24 - Wires not working with furnace
This commit is contained in:
parent
7c07ab9436
commit
a7b94b483f
4 changed files with 42 additions and 34 deletions
|
@ -1 +1 @@
|
|||
Subproject commit c884042bf6f135ebbd00c5aac5de7783f5328520
|
||||
Subproject commit 15f4a80499d11ef54ab410adb83fe70d198d122e
|
|
@ -83,6 +83,7 @@ public class BlockWire extends BlockConductor
|
|||
|
||||
world.setBlockTileEntity(x, y, z, TileEntity.createAndLoadEntity(nbt));
|
||||
((IConductor) world.getBlockTileEntity(x, y, z)).refresh();
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import universalelectricity.core.vector.VectorHelper;
|
|||
*
|
||||
* @author Calclavia
|
||||
*/
|
||||
public class TileEntityTickWire extends TileEntityWire implements IElectrical
|
||||
public class TileEntityTickWire extends TileEntityWire
|
||||
{
|
||||
private final HashMap<ForgeDirection, TileEntityFurnace> furnaces = new HashMap<ForgeDirection, TileEntityFurnace>();
|
||||
private float energyBuffer;
|
||||
|
@ -40,7 +40,7 @@ public class TileEntityTickWire extends TileEntityWire implements IElectrical
|
|||
ForgeDirection direction = entry.getKey();
|
||||
TileEntityFurnace tileEntity = entry.getValue();
|
||||
|
||||
if (tileEntity.getStackInSlot(0) == null)
|
||||
if (!tileEntity.isInvalid() && tileEntity.getStackInSlot(0) == null)
|
||||
{
|
||||
/**
|
||||
* Steal power from furnace.
|
||||
|
@ -56,7 +56,7 @@ public class TileEntityTickWire extends TileEntityWire implements IElectrical
|
|||
|
||||
if (tileEntity.furnaceBurnTime > 0)
|
||||
{
|
||||
this.getNetwork().produce(ElectricityPack.getFromWatts(ResonantInduction.FURNACE_WATTAGE, FURNACE_VOLTAGE));
|
||||
this.getNetwork().produce(ElectricityPack.getFromWatts(ResonantInduction.FURNACE_WATTAGE / 20, FURNACE_VOLTAGE));
|
||||
}
|
||||
|
||||
if (doBlockStateUpdate != tileEntity.furnaceBurnTime > 0)
|
||||
|
@ -68,7 +68,7 @@ public class TileEntityTickWire extends TileEntityWire implements IElectrical
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
|
||||
{
|
||||
this.energyBuffer += receive.getWatts();
|
||||
|
@ -121,53 +121,31 @@ public class TileEntityTickWire extends TileEntityWire implements IElectrical
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Furnace Connection
|
||||
*/
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
{
|
||||
super.getAdjacentConnections();
|
||||
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), side);
|
||||
|
||||
if (tileEntity instanceof TileEntityFurnace)
|
||||
{
|
||||
this.adjacentConnections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
return this.adjacentConnections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
return new ElectricityPack();
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
return this.furnaces.size() > 0 ? ResonantInduction.FURNACE_WATTAGE : 0;
|
||||
return this.furnaces.size() > 0 ? ResonantInduction.FURNACE_WATTAGE / 20 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Override
|
||||
public float getVoltage()
|
||||
{
|
||||
return FURNACE_VOLTAGE;
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import resonantinduction.PacketHandler;
|
||||
import resonantinduction.base.IPacketReceiver;
|
||||
|
@ -21,6 +22,9 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
public int dyeID = DEFAULT_COLOR;
|
||||
public boolean isInsulated = false;
|
||||
|
||||
/** Client Side Connection Check */
|
||||
public boolean isTick = false;
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
|
@ -59,7 +63,7 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider)
|
||||
if (tileEntity.getClass().isInstance(this) && tileEntity instanceof INetworkProvider)
|
||||
{
|
||||
this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork());
|
||||
}
|
||||
|
@ -113,7 +117,7 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketHandler.getTileEntityPacket(this, this.isInsulated, this.dyeID);
|
||||
return PacketHandler.getTileEntityPacket(this, this.isInsulated, this.dyeID, this instanceof TileEntityTickWire);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,6 +127,7 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
{
|
||||
this.isInsulated = input.readBoolean();
|
||||
this.dyeID = input.readInt();
|
||||
this.isTick = input.readBoolean();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -141,6 +146,30 @@ public class TileEntityWire extends TileEntityUniversalConductor implements IPac
|
|||
this.isInsulated = nbt.getBoolean("isInsulated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Furnace connection for tick wires
|
||||
*/
|
||||
@Override
|
||||
public TileEntity[] getAdjacentConnections()
|
||||
{
|
||||
super.getAdjacentConnections();
|
||||
|
||||
if (this.isTick)
|
||||
{
|
||||
for (byte i = 0; i < 6; i++)
|
||||
{
|
||||
ForgeDirection side = ForgeDirection.getOrientation(i);
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), side);
|
||||
|
||||
if (tileEntity instanceof TileEntityFurnace)
|
||||
{
|
||||
this.adjacentConnections[i] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.adjacentConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue