Fixed a bug where RF and IC2 tunnels could vaporize them selves.
Fixed Bug: #0514 - An unknown error occurs frequently
This commit is contained in:
+17
-5
@@ -80,6 +80,12 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
public static ThreadLocal<Boolean> disableFacadeOcclusion = new ThreadLocal<Boolean>();
|
||||
public CableBusContainer cb = new CableBusContainer( this );
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return cb.isInWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesTick()
|
||||
{
|
||||
@@ -467,11 +473,7 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if ( tile() instanceof TIInventoryTile )
|
||||
((TIInventoryTile) tile()).rebuildSlotMap();
|
||||
|
||||
if ( world() != null )
|
||||
world().notifyBlocksOfNeighborChange( x(), y(), z(), Platform.air );
|
||||
notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -543,4 +545,14 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds
|
||||
tile().remPart( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if ( tile() instanceof TIInventoryTile )
|
||||
((TIInventoryTile) tile()).rebuildSlotMap();
|
||||
|
||||
if ( world() != null && world().blockExists( x(), y(), z() ) )
|
||||
world().notifyBlocksOfNeighborChange( x(), y(), z(), Platform.air );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -140,4 +140,16 @@ public class AECableSchematicTile extends AEGenericSchematicTile implements IPar
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+15
-7
@@ -74,8 +74,8 @@ public class P2PCache implements IGridCache
|
||||
|
||||
// AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq
|
||||
// );
|
||||
updateTunnel( t.freq, t.output );
|
||||
updateTunnel( t.freq, !t.output );
|
||||
updateTunnel( t.freq, t.output, true );
|
||||
updateTunnel( t.freq, !t.output, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +98,7 @@ public class P2PCache implements IGridCache
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
|
||||
updateTunnel( t.freq, !t.output );
|
||||
updateTunnel( t.freq, !t.output, false );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,18 +122,26 @@ public class P2PCache implements IGridCache
|
||||
else
|
||||
inputs.remove( t.freq );
|
||||
|
||||
updateTunnel( t.freq, !t.output );
|
||||
updateTunnel( t.freq, !t.output, false );
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTunnel(long freq, boolean updateOutputs)
|
||||
private void updateTunnel(long freq, boolean updateOutputs, boolean configChange)
|
||||
{
|
||||
for (PartP2PTunnel p : outputs.get( freq ))
|
||||
p.onChange();
|
||||
{
|
||||
if ( configChange )
|
||||
p.onTunnelConfigChange();
|
||||
p.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
PartP2PTunnel in = inputs.get( freq );
|
||||
if ( in != null )
|
||||
in.onChange();
|
||||
{
|
||||
if ( configChange )
|
||||
in.onTunnelConfigChange();
|
||||
in.onTunnelNetworkChange();
|
||||
}
|
||||
}
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs(long freq, Class<? extends PartP2PTunnel> c)
|
||||
|
||||
@@ -64,6 +64,12 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
||||
boolean inWorld = false;
|
||||
public boolean requiresDynamicRender = false;
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return inWorld;
|
||||
}
|
||||
|
||||
public void setHost(IPartHost host)
|
||||
{
|
||||
tcb.clearContainer();
|
||||
@@ -364,12 +370,15 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
partChanged();
|
||||
}
|
||||
|
||||
public void removeFromWorld()
|
||||
{
|
||||
if ( !inWorld )
|
||||
return;
|
||||
|
||||
inWorld = false;
|
||||
|
||||
for (ForgeDirection s : ForgeDirection.values())
|
||||
@@ -378,6 +387,8 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
||||
if ( part != null )
|
||||
part.removeFromWorld();
|
||||
}
|
||||
|
||||
partChanged();
|
||||
}
|
||||
|
||||
public boolean canConnectRedstone(EnumSet<ForgeDirection> enumSet)
|
||||
@@ -1014,4 +1025,10 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer
|
||||
tcb.cleanup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
tcb.notifyNeighbors();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,20 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
{
|
||||
if ( getEnergySinkTile() == null )
|
||||
return null;
|
||||
|
||||
|
||||
return getEnergySinkTile().getWorldObj();
|
||||
}
|
||||
|
||||
private boolean isTileValid()
|
||||
{
|
||||
TileEntity te = getEnergySinkTile();
|
||||
|
||||
if ( te == null )
|
||||
return false;
|
||||
|
||||
return !te.isInvalid() && te.getWorldObj().blockExists( te.xCoord, te.yCoord, te.zCoord );
|
||||
}
|
||||
|
||||
final private void addToENet()
|
||||
{
|
||||
if ( getEnergySinkWorld() == null )
|
||||
@@ -42,7 +52,7 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
// re-add
|
||||
removeFromENet();
|
||||
|
||||
if ( !isInIC2() && Platform.isServer() )
|
||||
if ( !isInIC2() && Platform.isServer() && isTileValid() )
|
||||
{
|
||||
getLayerFlags().add( LayerFlags.IC2_ENET );
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergySink) getEnergySinkTile() ) );
|
||||
@@ -63,6 +73,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink
|
||||
|
||||
final private boolean interestedInIC2()
|
||||
{
|
||||
if ( !((IPartHost) this).isInWorld() )
|
||||
return false;
|
||||
|
||||
int interested = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
|
||||
@@ -35,6 +35,14 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
return getEnergySourceTile().getWorldObj();
|
||||
}
|
||||
|
||||
private boolean isTileValid()
|
||||
{
|
||||
TileEntity te = getEnergySourceTile();
|
||||
if ( te == null )
|
||||
return false;
|
||||
return !te.isInvalid();
|
||||
}
|
||||
|
||||
final private void addToENet()
|
||||
{
|
||||
if ( getEnergySourceWorld() == null )
|
||||
@@ -43,7 +51,7 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
// re-add
|
||||
removeFromENet();
|
||||
|
||||
if ( !isInIC2() && Platform.isServer() )
|
||||
if ( !isInIC2() && Platform.isServer() && isTileValid() )
|
||||
{
|
||||
getLayerFlags().add( LayerFlags.IC2_ENET );
|
||||
MinecraftForge.EVENT_BUS.post( new ic2.api.energy.event.EnergyTileLoadEvent( (IEnergySink) getEnergySourceTile() ) );
|
||||
@@ -64,6 +72,9 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource
|
||||
|
||||
final private boolean interestedInIC2()
|
||||
{
|
||||
if ( !((IPartHost) this).isInWorld() )
|
||||
return false;
|
||||
|
||||
int interested = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
|
||||
@@ -103,7 +103,13 @@ public class PartP2PIC2Power extends PartP2PTunnel<PartP2PIC2Power> implements i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
getHost().notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTunnelConfigChange()
|
||||
{
|
||||
getHost().partChanged();
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
cachedInv = null;
|
||||
PartP2PItems input = getInput();
|
||||
if ( input != null && output )
|
||||
input.onChange();
|
||||
input.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
IInventory getDest()
|
||||
@@ -161,8 +161,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
oldSize = getDest().getSizeInventory();
|
||||
if ( olderSize != oldSize )
|
||||
{
|
||||
getHost().partChanged();
|
||||
tile.getWorldObj().notifyBlocksOfNeighborChange( tile.xCoord, tile.yCoord, tile.zCoord, Platform.air );
|
||||
getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,8 +176,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
oldSize = getDest().getSizeInventory();
|
||||
if ( olderSize != oldSize )
|
||||
{
|
||||
getHost().partChanged();
|
||||
tile.getWorldObj().notifyBlocksOfNeighborChange( tile.xCoord, tile.yCoord, tile.zCoord, Platform.air );
|
||||
getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +198,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
if ( !output )
|
||||
{
|
||||
@@ -217,7 +215,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IPipeCo
|
||||
{
|
||||
PartP2PItems input = getInput();
|
||||
if ( input != null )
|
||||
input.onChange();
|
||||
input.getHost().notifyNeighbors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,12 +116,12 @@ public class PartP2PLiquids extends PartP2PTunnel<PartP2PLiquids> implements IFl
|
||||
{
|
||||
PartP2PLiquids in = getInput();
|
||||
if ( in != null )
|
||||
in.onChange();
|
||||
in.onTunnelNetworkChange();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
cachedTank = null;
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ public class PartP2PRFPower extends PartP2PTunnel<PartP2PRFPower> implements cof
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
getHost().partChanged();
|
||||
getHost().notifyNeighbors();
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
|
||||
@@ -49,7 +49,7 @@ public class PartP2PRedstone extends PartP2PTunnel<PartP2PRedstone>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
setNetworkReady();
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
// :P
|
||||
}
|
||||
|
||||
newTunnel.onChange();
|
||||
newTunnel.onTunnelNetworkChange();
|
||||
}
|
||||
|
||||
mc.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED );
|
||||
@@ -165,7 +165,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
{
|
||||
PartP2PTunnel newTunnel = (PartP2PTunnel) newBus;
|
||||
newTunnel.output = oldOutput;
|
||||
newTunnel.onChange();
|
||||
newTunnel.onTunnelNetworkChange();
|
||||
|
||||
try
|
||||
{
|
||||
@@ -216,7 +216,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
}
|
||||
}
|
||||
|
||||
onChange();
|
||||
onTunnelConfigChange();
|
||||
|
||||
ItemStack p2pItem = getItemStack( PartItemStack.Wrench );
|
||||
String type = p2pItem.getUnlocalizedName();
|
||||
@@ -231,6 +231,10 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onTunnelConfigChange()
|
||||
{
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(PartItemStack type)
|
||||
{
|
||||
if ( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick )
|
||||
@@ -271,7 +275,7 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
return new TunnelCollection( new ArrayList(), getClass() );
|
||||
}
|
||||
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -92,9 +92,9 @@ public class PartP2PTunnelME extends PartP2PTunnel<PartP2PTunnelME> implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange()
|
||||
public void onTunnelNetworkChange()
|
||||
{
|
||||
super.onChange();
|
||||
super.onTunnelNetworkChange();
|
||||
if ( !output )
|
||||
{
|
||||
try
|
||||
|
||||
@@ -87,6 +87,12 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
{
|
||||
return cb.isInWorld();
|
||||
}
|
||||
|
||||
protected void updateTileSetting()
|
||||
{
|
||||
if ( cb.requiresDynamicRender )
|
||||
@@ -283,7 +289,13 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
@Override
|
||||
public void partChanged()
|
||||
{
|
||||
if ( worldObj != null )
|
||||
notifyNeighbors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyNeighbors()
|
||||
{
|
||||
if ( worldObj != null && worldObj.blockExists( xCoord, yCoord, zCoord ) )
|
||||
worldObj.notifyBlocksOfNeighborChange( xCoord, yCoord, zCoord, Platform.air );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user