fix #3056, int. server fluid crash bug

This commit is contained in:
asiekierka 2015-10-06 10:47:32 +02:00
parent 73c5ae6657
commit 521774c829
3 changed files with 15 additions and 7 deletions

View file

@ -0,0 +1,4 @@
Bugs fixed:
* [#3056] PipeTransportFluids crash (asie)
* Random crashes with integrated server tile entity lookup (asie)

View file

@ -23,6 +23,7 @@ import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
@ -151,12 +152,15 @@ public class CoreProxyClient extends CoreProxy {
@Override @Override
public TileEntity getServerTile(TileEntity source) { public TileEntity getServerTile(TileEntity source) {
if (source.getWorldObj().isRemote) { if (Minecraft.getMinecraft().isSingleplayer() && source.getWorldObj().isRemote) {
WorldServer w = DimensionManager.getWorld(source.getWorldObj().provider.dimensionId); WorldServer w = DimensionManager.getWorld(source.getWorldObj().provider.dimensionId);
if (w != null) { if (w != null) {
TileEntity t = w.getTileEntity(source.xCoord, source.yCoord, source.zCoord); Chunk c = w.getChunkFromBlockCoords(source.xCoord, source.zCoord);
if (t != null && t.getClass().equals(source.getClass())) { if (c != null) {
return t; TileEntity t = c.getTileEntityUnsafe(source.xCoord & 15, source.yCoord, source.zCoord & 15);
if (t != null && t.getClass().equals(source.getClass())) {
return t;
}
} }
} }
} }

View file

@ -427,9 +427,9 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler,
public FluidRenderData createServerFluidRenderData() { public FluidRenderData createServerFluidRenderData() {
FluidRenderData rCache = new FluidRenderData(); FluidRenderData rCache = new FluidRenderData();
rCache.fluidID = fluidType != null ? fluidType.getFluid().getID() : 0; if (fluidType != null && fluidType.getFluid() != null) {
rCache.color = fluidType != null ? fluidType.getFluid().getColor(fluidType) : 0; rCache.fluidID = fluidType.getFluid().getID();
if (fluidType != null) { rCache.color = fluidType.getFluid().getColor(fluidType);
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
rCache.amount[i] = sections[i].amount; rCache.amount[i] = sections[i].amount;
} }