use of club.nsdn.nyasamarailway.tileblock.functional.BlockPierTag in project NyaSamaRailway by NSDN.
the class ItemPierBuilder method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
Block block = world.getBlock(x, y, z);
if (block == null)
return false;
if (player.isSneaking()) {
endBlock = block;
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.endBlock", endBlock.getLocalizedName()));
} else {
if (endBlock == null)
return false;
if (!(block instanceof BlockPierTag))
return false;
else {
world.setBlock(x, y, z, Blocks.air);
block = world.getBlock(x, y + 1, z);
}
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.begin"));
// dy = -1 to use pier tag
for (int dy = -1; !reachesEndBlock(world, x, y - dy - 1, z); dy++) {
traversalCounter = 0;
TraversalBlocks(world, block, x, y - dy, z);
if (traversalCounter > TRAVERSAL_MAX) {
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.abort"));
break;
}
}
if (player instanceof EntityPlayerMP)
player.addChatComponentMessage(new ChatComponentTranslation("info.PierBuilder.finish"));
}
return !world.isRemote;
}
Aggregations