Fixed bad cast, fixed tubes and pipes losing capacity after world load

This commit is contained in:
aidancbrady 2015-05-22 13:06:46 -04:00
parent 0b04665055
commit fa71836e0d
4 changed files with 12 additions and 8 deletions

View file

@ -295,13 +295,15 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork>
for(Coord4D coord : possibleAcceptors.keySet()) for(Coord4D coord : possibleAcceptors.keySet())
{ {
EnumSet<ForgeDirection> sides = acceptorDirections.get(coord); EnumSet<ForgeDirection> sides = acceptorDirections.get(coord);
IGasHandler acceptor = (IGasHandler)coord.getTileEntity(getWorld()); TileEntity tile = coord.getTileEntity(getWorld());
if(sides == null || sides.isEmpty()) if(!(tile instanceof IGasHandler) || sides == null || sides.isEmpty())
{ {
continue; continue;
} }
IGasHandler acceptor = (IGasHandler)tile;
for(ForgeDirection side : sides) for(ForgeDirection side : sides)
{ {
if(acceptor != null && acceptor.canReceiveGas(side, type)) if(acceptor != null && acceptor.canReceiveGas(side, type))

View file

@ -295,13 +295,14 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork>
for(Coord4D coord : possibleAcceptors.keySet()) for(Coord4D coord : possibleAcceptors.keySet())
{ {
EnumSet<ForgeDirection> sides = acceptorDirections.get(coord); EnumSet<ForgeDirection> sides = acceptorDirections.get(coord);
TileEntity tile = coord.getTileEntity(getWorld());
if(sides == null || sides.isEmpty()) if(sides == null || sides.isEmpty())
{ {
continue; continue;
} }
IFluidHandler acceptor = (IFluidHandler)coord.getTileEntity(getWorld()); IFluidHandler acceptor = (IFluidHandler)tile;
for(ForgeDirection side : sides) for(ForgeDirection side : sides)
{ {

View file

@ -127,12 +127,13 @@ public class PartMechanicalPipe extends PartTransmitter<IFluidHandler, FluidNetw
{ {
super.load(nbtTags); super.load(nbtTags);
tier = Tier.PipeTier.values()[nbtTags.getInteger("tier")];
buffer.setCapacity(getCapacity());
if(nbtTags.hasKey("cacheFluid")) if(nbtTags.hasKey("cacheFluid"))
{ {
buffer.setFluid(FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cacheFluid"))); buffer.setFluid(FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cacheFluid")));
} }
tier = Tier.PipeTier.values()[nbtTags.getInteger("tier")];
} }
@Override @Override

View file

@ -134,6 +134,7 @@ public class PartPressurizedTube extends PartTransmitter<IGasHandler, GasNetwork
super.load(nbtTags); super.load(nbtTags);
tier = TubeTier.values()[nbtTags.getInteger("tier")]; tier = TubeTier.values()[nbtTags.getInteger("tier")];
buffer.setMaxGas(getCapacity());
if(nbtTags.hasKey("cacheGas")) if(nbtTags.hasKey("cacheGas"))
{ {
@ -303,8 +304,7 @@ public class PartPressurizedTube extends PartTransmitter<IGasHandler, GasNetwork
{ {
return super.getCachedAcceptor(side); return super.getCachedAcceptor(side);
} }
return null; return null;
} }
} }