diff --git a/src/main/java/train/common/blocks/BlockTCRail.java b/src/main/java/train/common/blocks/BlockTCRail.java index f2bc4e578..04e91e41a 100644 --- a/src/main/java/train/common/blocks/BlockTCRail.java +++ b/src/main/java/train/common/blocks/BlockTCRail.java @@ -68,16 +68,13 @@ public boolean hasTileEntity(int metadata) { @Override public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { - TileTCRail tileEntity = (TileTCRail) world.getTileEntity(x,y,z); - if (tileEntity == null){ - return; + TileEntity tileEntity = world.getTileEntity(x,y,z); + if (tileEntity instanceof TileTCRailGag) { + tileEntity = world.getTileEntity(((TileTCRailGag)tileEntity).originX, ((TileTCRailGag)tileEntity).originY, ((TileTCRailGag)tileEntity).originZ); + } + if(tileEntity instanceof TileTCRail){ + ((TileTCRail)tileEntity).lastPlayerToInteract = player; } - - if (tileEntity.isLinkedToRail){ - TileTCRailGag tileGag = (TileTCRailGag) world.getTileEntity(tileEntity.linkedX, tileEntity.linkedY, tileEntity.linkedZ); - tileEntity = (TileTCRail) world.getTileEntity(tileGag.originX, tileGag.originY, tileGag.originZ); - } - tileEntity.lastPlayerToInteract = player; }