Search in sources :

Example 1 with BlockPierTag

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;
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) Block(net.minecraft.block.Block) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPierTag(club.nsdn.nyasamarailway.tileblock.functional.BlockPierTag)

Aggregations

BlockPierTag (club.nsdn.nyasamarailway.tileblock.functional.BlockPierTag)1 Block (net.minecraft.block.Block)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)1