Removed PersistentWorld/Tile +LegacyBlock support.
This commit is contained in:
parent
48064ad07f
commit
f1b9e30d88
12 changed files with 67 additions and 270 deletions
buildcraft_client/net/minecraft/src
common/net/minecraft/src
|
@ -18,7 +18,6 @@ import net.minecraft.src.buildcraft.api.IBlockPipe;
|
|||
import net.minecraft.src.buildcraft.api.IPipe;
|
||||
import net.minecraft.src.buildcraft.api.IPipe.DrawingState;
|
||||
import net.minecraft.src.buildcraft.api.Orientations;
|
||||
import net.minecraft.src.buildcraft.core.BlockIndex;
|
||||
import net.minecraft.src.buildcraft.core.ClassMapping;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.EntityBlock;
|
||||
|
@ -27,8 +26,6 @@ import net.minecraft.src.buildcraft.core.EntityLaser;
|
|||
import net.minecraft.src.buildcraft.core.EntityRobot;
|
||||
import net.minecraft.src.buildcraft.core.IInventoryRenderer;
|
||||
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
|
||||
import net.minecraft.src.buildcraft.core.PersistentTile;
|
||||
import net.minecraft.src.buildcraft.core.PersistentWorld;
|
||||
import net.minecraft.src.buildcraft.core.RenderEnergyLaser;
|
||||
import net.minecraft.src.buildcraft.core.RenderEntityBlock;
|
||||
import net.minecraft.src.buildcraft.core.RenderLaser;
|
||||
|
@ -125,19 +122,23 @@ public class mod_BuildCraftCore extends NetworkMod {
|
|||
// renderblocks.renderStandardBlock(block, i, j, k);
|
||||
|
||||
} else if (block.getRenderType() == BuildCraftCore.markerModel) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
float f = block.getBlockBrightness(iblockaccess, i, j, k);
|
||||
if (Block.lightValue[block.blockID] > 0)
|
||||
f = 1.0F;
|
||||
tessellator.setColorOpaque_F(f, f, f);
|
||||
renderMarkerWithMeta(iblockaccess, block, i, j, k, iblockaccess.getBlockMetadata(i, j, k));
|
||||
|
||||
} else if (block.getRenderType() == BuildCraftCore.pipeModel) {
|
||||
PersistentTile tile = PersistentWorld.getWorld(iblockaccess).getTile(new BlockIndex(i, j, k));
|
||||
|
||||
TileEntity tile = iblockaccess.getBlockTileEntity(i, j, k);
|
||||
|
||||
if (tile == null || !(tile instanceof IPipe))
|
||||
legacyPipeRender(renderblocks, iblockaccess, i, j, k, block, l);
|
||||
else
|
||||
pipeRender(renderblocks, iblockaccess, tile.tile, (IPipe) tile, block, l);
|
||||
pipeRender(renderblocks, iblockaccess, tile, (IPipe) tile, block, l);
|
||||
|
||||
} else if (block.getRenderType() == BuildCraftCore.oilModel)
|
||||
renderblocks.renderBlockFluids(block, i, j, k);
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ import net.minecraft.src.buildcraft.transport.BptItemPipeIron;
|
|||
import net.minecraft.src.buildcraft.transport.BptItemPipeWodden;
|
||||
import net.minecraft.src.buildcraft.transport.GuiHandler;
|
||||
import net.minecraft.src.buildcraft.transport.ItemGate;
|
||||
import net.minecraft.src.buildcraft.transport.LegacyBlock;
|
||||
import net.minecraft.src.buildcraft.transport.LegacyTile;
|
||||
import net.minecraft.src.buildcraft.transport.Pipe;
|
||||
import net.minecraft.src.buildcraft.transport.PipeLogicWood;
|
||||
import net.minecraft.src.buildcraft.transport.PipeTriggerProvider;
|
||||
|
@ -153,10 +151,6 @@ public class BuildCraftTransport {
|
|||
|
||||
mod_BuildCraftCore.initialize();
|
||||
|
||||
Property loadLegacyPipes = BuildCraftCore.mainConfiguration.getOrCreateBooleanProperty("loadLegacyPipes",
|
||||
Configuration.CATEGORY_GENERAL, true);
|
||||
loadLegacyPipes.comment = "set to true to load pre 2.2.5 worlds pipes";
|
||||
|
||||
Property alwaysConnect = BuildCraftCore.mainConfiguration.getOrCreateBooleanProperty("pipes.alwaysConnect",
|
||||
Configuration.CATEGORY_GENERAL, DefaultProps.PIPES_ALWAYS_CONNECT);
|
||||
alwaysConnect.comment = "set to false to deactivate pipe connection rules, true by default";
|
||||
|
@ -290,34 +284,6 @@ public class BuildCraftTransport {
|
|||
|
||||
alwaysConnectPipes = Boolean.parseBoolean(alwaysConnect.value);
|
||||
|
||||
if (loadLegacyPipes.value.equals("true")) {
|
||||
Property woodenPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("woodenPipe.id",
|
||||
DefaultProps.WOODEN_PIPE_ID);
|
||||
Property stonePipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("stonePipe.id",
|
||||
DefaultProps.STONE_PIPE_ID);
|
||||
Property ironPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("ironPipe.id",
|
||||
DefaultProps.IRON_PIPE_ID);
|
||||
Property goldenPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("goldenPipe.id",
|
||||
DefaultProps.GOLDEN_PIPE_ID);
|
||||
Property diamondPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("diamondPipe.id",
|
||||
DefaultProps.DIAMOND_PIPE_ID);
|
||||
Property obsidianPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("obsidianPipe.id",
|
||||
DefaultProps.OBSIDIAN_PIPE_ID);
|
||||
Property cobblestonePipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("cobblestonePipe.id",
|
||||
DefaultProps.COBBLESTONE_PIPE_ID);
|
||||
|
||||
CoreProxy.registerBlock(new LegacyBlock(Integer.parseInt(woodenPipeId.value), pipeItemsWood.shiftedIndex));
|
||||
CoreProxy.registerBlock(new LegacyBlock(Integer.parseInt(stonePipeId.value), pipeItemsStone.shiftedIndex));
|
||||
CoreProxy.registerBlock(new LegacyBlock(Integer.parseInt(ironPipeId.value), pipeItemsIron.shiftedIndex));
|
||||
CoreProxy.registerBlock(new LegacyBlock(Integer.parseInt(goldenPipeId.value), pipeItemsGold.shiftedIndex));
|
||||
CoreProxy.registerBlock(new LegacyBlock(Integer.parseInt(diamondPipeId.value), pipeItemsDiamond.shiftedIndex));
|
||||
CoreProxy.registerBlock(new LegacyBlock(Integer.parseInt(obsidianPipeId.value), pipeItemsObsidian.shiftedIndex));
|
||||
CoreProxy
|
||||
.registerBlock(new LegacyBlock(Integer.parseInt(cobblestonePipeId.value), pipeItemsCobblestone.shiftedIndex));
|
||||
|
||||
CoreProxy.registerTileEntity(LegacyTile.class, "net.buildcraft.src.buildcraft.transport.legacy.LegacyTile");
|
||||
}
|
||||
|
||||
BuildCraftCore.mainConfiguration.save();
|
||||
|
||||
new BptBlockPipe(genericPipeBlock.blockID);
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.minecraft.src.buildcraft.core;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public abstract class PersistentTile {
|
||||
|
||||
public TileEntity tile;
|
||||
|
||||
public BlockIndex index;
|
||||
|
||||
public void setTile(TileEntity tile) {
|
||||
this.tile = tile;
|
||||
index = new BlockIndex(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return tile != null && !tile.isInvalid();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.minecraft.src.buildcraft.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.src.IBlockAccess;
|
||||
|
||||
public class PersistentWorld {
|
||||
|
||||
private static HashMap<Long, PersistentWorld> worlds = new HashMap<Long, PersistentWorld>();
|
||||
private static Long lastBlockAccess = null;
|
||||
private static PersistentWorld lastWorld = null;
|
||||
|
||||
private TreeMap<BlockIndex, PersistentTile> tiles = new TreeMap<BlockIndex, PersistentTile>();
|
||||
|
||||
public PersistentTile createTile(PersistentTile defaultTile, BlockIndex index) {
|
||||
PersistentTile result = null;
|
||||
|
||||
if (!tiles.containsKey(index)) {
|
||||
tiles.put(index, defaultTile);
|
||||
result = defaultTile;
|
||||
} else {
|
||||
result = tiles.get(index);
|
||||
|
||||
if (result == defaultTile) {
|
||||
|
||||
} else if (!result.getClass().equals(defaultTile.getClass())) {
|
||||
tiles.remove(index);
|
||||
tiles.put(index, defaultTile);
|
||||
result.destroy();
|
||||
result = defaultTile;
|
||||
} else
|
||||
defaultTile.destroy();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void storeTile(PersistentTile tile, BlockIndex index) {
|
||||
if (tiles.containsKey(index)) {
|
||||
PersistentTile old = tiles.get(index);
|
||||
|
||||
if (old == tile)
|
||||
return;
|
||||
|
||||
tiles.remove(index).destroy();
|
||||
}
|
||||
|
||||
tiles.put(index, tile);
|
||||
}
|
||||
|
||||
public PersistentTile getTile(BlockIndex index) {
|
||||
return tiles.get(index);
|
||||
}
|
||||
|
||||
public void removeTile(BlockIndex index) {
|
||||
if (tiles.containsKey(index))
|
||||
tiles.remove(index).destroy();
|
||||
}
|
||||
|
||||
public static PersistentWorld getWorld(IBlockAccess blockAccess) {
|
||||
Long hash = CoreProxy.getHash(blockAccess);
|
||||
if (!hash.equals(lastBlockAccess)) {
|
||||
if (!worlds.containsKey(hash))
|
||||
worlds.put(hash, new PersistentWorld());
|
||||
|
||||
lastBlockAccess = hash;
|
||||
lastWorld = worlds.get(hash);
|
||||
}
|
||||
|
||||
return lastWorld;
|
||||
}
|
||||
|
||||
}
|
|
@ -35,8 +35,6 @@ import net.minecraft.src.buildcraft.api.tools.IToolWrench;
|
|||
import net.minecraft.src.buildcraft.core.BlockIndex;
|
||||
import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.PersistentTile;
|
||||
import net.minecraft.src.buildcraft.core.PersistentWorld;
|
||||
import net.minecraft.src.buildcraft.core.Utils;
|
||||
import net.minecraft.src.forge.ITextureProvider;
|
||||
|
||||
|
@ -198,8 +196,7 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
|
|||
}
|
||||
|
||||
pipeRemoved.put(new BlockIndex(i, j, k), pipe);
|
||||
|
||||
PersistentWorld.getWorld(world).removeTile(new BlockIndex(i, j, k));
|
||||
world.removeBlockTileEntity(i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -490,6 +487,7 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
|
|||
}
|
||||
|
||||
public static Pipe createPipe(int key) {
|
||||
|
||||
try {
|
||||
return pipes.get(key).getConstructor(int.class).newInstance(key);
|
||||
} catch (Throwable t) {
|
||||
|
@ -498,21 +496,28 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Pipe createPipe(IBlockAccess blockAccess, int i, int j, int k, int key) {
|
||||
Pipe pipe = createPipe(key);
|
||||
pipe.setPosition(i, j, k);
|
||||
|
||||
return (Pipe) PersistentWorld.getWorld(blockAccess).createTile(pipe, new BlockIndex(i, j, k));
|
||||
|
||||
public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, int blockId, int meta) {
|
||||
|
||||
boolean placed = world.setBlockAndMetadataWithNotify(i, j, k, blockId, meta);
|
||||
|
||||
if (placed) {
|
||||
|
||||
TileGenericPipe tile = (TileGenericPipe) world.getBlockTileEntity(i, j, k);
|
||||
tile.initialize(pipe);
|
||||
}
|
||||
|
||||
return placed;
|
||||
}
|
||||
|
||||
public static Pipe getPipe(IBlockAccess blockAccess, int i, int j, int k) {
|
||||
PersistentTile tile = PersistentWorld.getWorld(blockAccess).getTile(new BlockIndex(i, j, k));
|
||||
|
||||
TileGenericPipe tile = (TileGenericPipe) blockAccess.getBlockTileEntity(i, j, k);
|
||||
|
||||
if (tile == null || !tile.isValid() || !(tile instanceof Pipe))
|
||||
return null;
|
||||
else
|
||||
return (Pipe) tile;
|
||||
if (tile != null && !tile.isInvalid())
|
||||
return tile.pipe;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isFullyDefined(Pipe pipe) {
|
||||
|
@ -520,6 +525,6 @@ public class BlockGenericPipe extends BlockContainer implements IBlockPipe, ITex
|
|||
}
|
||||
|
||||
public static boolean isValid(Pipe pipe) {
|
||||
return isFullyDefined(pipe) && pipe.isValid();
|
||||
return isFullyDefined(pipe);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class BptBlockPipe extends BptBlock {
|
|||
public void buildBlock(BptSlotInfo slot, IBptContext context) {
|
||||
int pipeId = slot.cpt.getInteger("pipeId");
|
||||
|
||||
Pipe pipe = BlockGenericPipe.createPipe(context.world(), slot.x, slot.y, slot.z, pipeId);
|
||||
Pipe pipe = BlockGenericPipe.createPipe(pipeId);
|
||||
|
||||
for (int i = 0; i < pipe.wireSet.length; ++i)
|
||||
if (slot.cpt.hasKey("wire" + i))
|
||||
|
@ -109,8 +109,7 @@ public class BptBlockPipe extends BptBlock {
|
|||
}
|
||||
}
|
||||
|
||||
context.world().setBlockAndMetadataWithNotify(slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta);
|
||||
BlockGenericPipe.placePipe(pipe, context.world(), slot.x, slot.y, slot.z, slot.blockId, slot.meta);
|
||||
|
||||
if (BuildCraftCore.itemBptProps[pipeId] != null)
|
||||
BuildCraftCore.itemBptProps[pipeId].buildBlock(slot, context);
|
||||
|
|
|
@ -46,11 +46,15 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe {
|
|||
if (l == 5)
|
||||
i++;
|
||||
}
|
||||
|
||||
if (itemstack.stackSize == 0)
|
||||
return false;
|
||||
|
||||
if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {
|
||||
BlockGenericPipe.createPipe(world, i, j, k, shiftedIndex);
|
||||
if (world.setBlockAndMetadataWithNotify(i, j, k, blockID, 0)) {
|
||||
|
||||
Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex);
|
||||
if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) {
|
||||
|
||||
Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
|
||||
Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
|
||||
// To move to a proxt
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.minecraft.src.buildcraft.transport;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class LegacyBlock extends BlockContainer {
|
||||
|
||||
public int newPipeId;
|
||||
|
||||
public LegacyBlock(int itemId, int newPipeId) {
|
||||
super(itemId, Material.glass);
|
||||
this.newPipeId = newPipeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getBlockEntity() {
|
||||
return new LegacyTile();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
|
||||
package net.minecraft.src.buildcraft.transport;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.BuildCraftTransport;
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
||||
public class LegacyTile extends TileEntity {
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
int pipeId = ((LegacyBlock) Block.blocksList[worldObj.getBlockId(xCoord, yCoord, zCoord)]).newPipeId;
|
||||
|
||||
BlockGenericPipe.createPipe(worldObj, xCoord, yCoord, zCoord, pipeId);
|
||||
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord, zCoord, BuildCraftTransport.genericPipeBlock.blockID, meta);
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,6 @@ import net.minecraft.src.buildcraft.api.Trigger;
|
|||
import net.minecraft.src.buildcraft.api.TriggerParameter;
|
||||
import net.minecraft.src.buildcraft.core.ActionRedstoneOutput;
|
||||
import net.minecraft.src.buildcraft.core.IDropControlInventory;
|
||||
import net.minecraft.src.buildcraft.core.PersistentTile;
|
||||
import net.minecraft.src.buildcraft.core.Utils;
|
||||
import net.minecraft.src.buildcraft.core.network.IndexInPayload;
|
||||
import net.minecraft.src.buildcraft.core.network.PacketPayload;
|
||||
|
@ -41,7 +40,7 @@ import net.minecraft.src.buildcraft.core.network.PacketUpdate;
|
|||
import net.minecraft.src.buildcraft.core.network.TilePacketWrapper;
|
||||
import net.minecraft.src.buildcraft.transport.Gate.GateConditional;
|
||||
|
||||
public class Pipe extends PersistentTile implements IPipe, IDropControlInventory {
|
||||
public class Pipe implements IPipe, IDropControlInventory {
|
||||
|
||||
public int[] signalStrength = new int[] { 0, 0, 0, 0 };
|
||||
|
||||
|
@ -108,9 +107,7 @@ public class Pipe extends PersistentTile implements IPipe, IDropControlInventory
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTile(TileEntity tile) {
|
||||
super.setTile(tile);
|
||||
|
||||
this.container = (TileGenericPipe) tile;
|
||||
|
||||
|
@ -118,6 +115,7 @@ public class Pipe extends PersistentTile implements IPipe, IDropControlInventory
|
|||
logic.setTile((TileGenericPipe) tile);
|
||||
|
||||
setPosition(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
setWorld(tile.worldObj);
|
||||
}
|
||||
|
||||
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
|
||||
|
@ -187,6 +185,7 @@ public class Pipe extends PersistentTile implements IPipe, IDropControlInventory
|
|||
}
|
||||
|
||||
public void updateEntity() {
|
||||
|
||||
transport.updateEntity();
|
||||
logic.updateEntity();
|
||||
|
||||
|
|
|
@ -34,13 +34,10 @@ import net.minecraft.src.buildcraft.api.PowerProvider;
|
|||
import net.minecraft.src.buildcraft.api.SafeTimeTracker;
|
||||
import net.minecraft.src.buildcraft.api.TileNetworkData;
|
||||
import net.minecraft.src.buildcraft.api.Trigger;
|
||||
import net.minecraft.src.buildcraft.core.BlockIndex;
|
||||
import net.minecraft.src.buildcraft.core.CoreProxy;
|
||||
import net.minecraft.src.buildcraft.core.DefaultProps;
|
||||
import net.minecraft.src.buildcraft.core.IDropControlInventory;
|
||||
import net.minecraft.src.buildcraft.core.ITileBufferHolder;
|
||||
import net.minecraft.src.buildcraft.core.PersistentTile;
|
||||
import net.minecraft.src.buildcraft.core.PersistentWorld;
|
||||
import net.minecraft.src.buildcraft.core.TileBuffer;
|
||||
import net.minecraft.src.buildcraft.core.network.ISynchronizedTile;
|
||||
import net.minecraft.src.buildcraft.core.network.IndexInPayload;
|
||||
|
@ -88,6 +85,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
}
|
||||
|
||||
if (pipe != null) {
|
||||
|
||||
pipe.setTile(this);
|
||||
pipe.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
@ -102,13 +100,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
|
||||
super.invalidate();
|
||||
|
||||
if (BlockGenericPipe.isValid(pipe))
|
||||
BlockGenericPipe.removePipe(pipe);
|
||||
|
||||
// Clean the persistent world in case the tile is still here.
|
||||
PersistentWorld.getWorld(worldObj).removeTile(new BlockIndex(xCoord, yCoord, zCoord));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -120,16 +116,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
if (!initialized) {
|
||||
initialize();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
if (pipe == null)
|
||||
return;
|
||||
|
||||
initialize(pipe);
|
||||
|
||||
if (!BlockGenericPipe.isValid(pipe))
|
||||
return;
|
||||
|
||||
if (blockNeighborChange) {
|
||||
|
||||
computeConnections();
|
||||
pipe.onNeighborBlockChange(0);
|
||||
blockNeighborChange = false;
|
||||
|
@ -144,7 +141,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
pipe.updateEntity();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
public void initialize(Pipe pipe) {
|
||||
|
||||
if (initialized)
|
||||
return;
|
||||
|
||||
this.pipe = pipe;
|
||||
|
||||
tileBuffer = new TileBuffer[6];
|
||||
|
||||
for (Orientations o : Orientations.dirs()) {
|
||||
|
@ -168,30 +171,20 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ILiqu
|
|||
|
||||
if (pipe != null)
|
||||
pipe.initialize();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private void bindPipe() {
|
||||
if (!pipeBound) {
|
||||
if (pipe == null) {
|
||||
PersistentTile tile = PersistentWorld.getWorld(worldObj).getTile(new BlockIndex(xCoord, yCoord, zCoord));
|
||||
|
||||
if (tile != null && tile instanceof Pipe)
|
||||
pipe = (Pipe) tile;
|
||||
}
|
||||
|
||||
if (pipe != null) {
|
||||
pipe.setTile(this);
|
||||
pipe.setWorld(worldObj);
|
||||
|
||||
if (worldObj == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
PersistentWorld.getWorld(worldObj).storeTile(pipe, new BlockIndex(xCoord, yCoord, zCoord));
|
||||
pipeId = pipe.itemID;
|
||||
pipeBound = true;
|
||||
}
|
||||
|
||||
if (!pipeBound && pipe != null) {
|
||||
|
||||
pipe.setTile(this);
|
||||
pipe.setWorld(worldObj);
|
||||
|
||||
pipeId = pipe.itemID;
|
||||
pipeBound = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,9 +100,12 @@ public class PipeItemsStripes extends Pipe implements IItemTravelingHook, IPower
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean convertPipe(PipeTransportItems pipe, EntityData data) {
|
||||
|
||||
if (data.item.item.getItem() instanceof ItemPipe)
|
||||
|
||||
if (!(data.item.item.itemID == BuildCraftTransport.pipeItemsStipes.shiftedIndex)) {
|
||||
Pipe newPipe = BlockGenericPipe.createPipe(worldObj, xCoord, yCoord, zCoord, data.item.item.itemID);
|
||||
|
||||
Pipe newPipe = BlockGenericPipe.createPipe(data.item.item.itemID);
|
||||
newPipe.setTile(this.container);
|
||||
newPipe.setWorld(worldObj);
|
||||
this.container.pipe = newPipe;
|
||||
|
|
Loading…
Add table
Reference in a new issue