use of mods.railcraft.api.core.items.ITrackItem in project Railcraft by Railcraft.
the class EntityCartTrackRelayer method replace.
private void replace() {
BlockPos pos = getPosition();
if (TrackTools.isRailBlockAt(worldObj, pos.down()))
pos = pos.down();
Block block = WorldPlugin.getBlock(worldObj, pos);
if (TrackTools.isRailBlock(block)) {
ItemStack trackExist = patternInv.getStackInSlot(SLOT_EXIST);
ItemStack trackStock = getStackInSlot(SLOT_STOCK);
boolean nextToSuspended = false;
for (EnumFacing side : EnumSet.of(EnumFacing.EAST, EnumFacing.WEST, EnumFacing.NORTH, EnumFacing.SOUTH)) {
TileEntity tile = WorldPlugin.getBlockTile(worldObj, pos.offset(side));
if (tile instanceof IOutfittedTrackTile) {
IOutfittedTrackTile track = (IOutfittedTrackTile) tile;
if (track.getTrackKitInstance() instanceof TrackKitSuspended) {
nextToSuspended = true;
break;
}
}
}
if (nextToSuspended)
return;
if (trackExist != null && trackStock != null)
if (trackExist.getItem() instanceof ITrackItem) {
ITrackItem trackItem = (ITrackItem) trackExist.getItem();
if (trackItem.getPlacedBlock() == block) {
TileEntity tile = worldObj.getTileEntity(pos);
if (trackItem.isPlacedTileEntity(trackExist, tile)) {
BlockRailBase.EnumRailDirection trackShape = removeOldTrack(pos, block);
placeNewTrack(pos, SLOT_STOCK, trackShape);
}
}
} else if (InvTools.isStackEqualToBlock(trackExist, block)) {
BlockRailBase.EnumRailDirection trackShape = removeOldTrack(pos, block);
placeNewTrack(pos, SLOT_STOCK, trackShape);
}
}
}
Aggregations