Fixed a crash, also fixed the Logistical Transporter not connecting on chunk load.

I have absolutely no idea why, but for some reason calling isBlockProvidingIndirectPowerTo() before checking connections fixes the issue. Probably something related to chunk loading.
This commit is contained in:
Aidan C. Brady 2014-08-18 16:10:44 -04:00
parent 497af914dc
commit 57452a562e
3 changed files with 40 additions and 26 deletions

View file

@ -59,11 +59,6 @@ public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork>
public HashList<TransporterStack> transit = new HashList<TransporterStack>();
public Set<TransporterStack> needsSync = new HashSet<TransporterStack>();
public PartLogisticalTransporter()
{
redstoneReactive = false;
}
@Override
public String getType()
@ -135,6 +130,12 @@ public class PartLogisticalTransporter extends PartTransmitter<InventoryNetwork>
{
return TransporterUtils.getConnections(this)[side.ordinal()];
}
@Override
public boolean handlesRedstone()
{
return false;
}
@Override
public void update()

View file

@ -159,6 +159,11 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
}
}
public boolean handlesRedstone()
{
return true;
}
public boolean renderCenter()
{
return false;
@ -202,7 +207,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
{
byte connections = 0x00;
if(redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z()))
if(handlesRedstone() && redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z()))
{
return connections;
}
@ -227,7 +232,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
{
byte connections = 0x00;
if(redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z()))
if(handlesRedstone() && redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z()))
{
return connections;
}
@ -381,7 +386,9 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
@Override
public boolean canConnect(ForgeDirection side)
{
if(redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z()))
boolean powered = world().isBlockIndirectlyGettingPowered(x(), y(), z());
if(handlesRedstone() && redstoneReactive && powered)
{
return false;
}
@ -512,21 +519,24 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
if(possibleTransmitters != currentTransmitterConnections)
{
boolean nowPowered = redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z());
if(nowPowered != redstonePowered)
if(handlesRedstone())
{
redstonePowered = nowPowered;
if(nowPowered)
boolean nowPowered = redstoneReactive && world().isBlockIndirectlyGettingPowered(x(), y(), z());
if(nowPowered != redstonePowered)
{
onRedstoneSplit();
redstonePowered = nowPowered;
if(nowPowered)
{
onRedstoneSplit();
}
else {
onRedstoneJoin();
}
tile().notifyTileChange();
}
else {
onRedstoneJoin();
}
tile().notifyTileChange();
}
}
@ -572,7 +582,10 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
@Override
public void onNeighborChanged()
{
redstoneRefresh();
if(handlesRedstone())
{
redstoneRefresh();
}
}
@Override
@ -683,7 +696,7 @@ public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart,
@Override
public boolean onRightClick(EntityPlayer player, int side)
{
if(!world().isRemote && !(this instanceof PartLogisticalTransporter))
if(!world().isRemote && handlesRedstone())
{
redstoneReactive ^= true;
refreshConnections();

View file

@ -7,9 +7,9 @@ import mekanism.api.gas.GasNetwork;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.transmitters.IGridTransmitter;
import mekanism.api.transmitters.TransmissionType;
import mekanism.common.EnergyNetwork;
import mekanism.common.FluidNetwork;
import mekanism.common.Mekanism;
import mekanism.common.PacketHandler;
import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage;
import net.minecraft.entity.player.EntityPlayer;
@ -41,7 +41,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
{
TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj);
if(tileEntity instanceof IGridTransmitter)
if(tileEntity instanceof IGridTransmitter && ((IGridTransmitter)tileEntity).getTransmissionType() == TransmissionType.ENERGY)
{
((IGridTransmitter<EnergyNetwork>)tileEntity).getTransmitterNetwork().clientEnergyScale = message.power;
}
@ -50,7 +50,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
{
TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj);
if(tileEntity instanceof IGridTransmitter)
if(tileEntity instanceof IGridTransmitter && ((IGridTransmitter)tileEntity).getTransmissionType() == TransmissionType.GAS)
{
GasNetwork net = ((IGridTransmitter<GasNetwork>)tileEntity).getTransmitterNetwork();
@ -67,7 +67,7 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
{
TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj);
if(tileEntity instanceof IGridTransmitter)
if(tileEntity instanceof IGridTransmitter && ((IGridTransmitter)tileEntity).getTransmissionType() == TransmissionType.FLUID)
{
FluidNetwork net = ((IGridTransmitter<FluidNetwork>)tileEntity).getTransmitterNetwork();