Search in sources :

Example 1 with BlockMannequin

use of riskyken.armourersWorkshop.common.blocks.BlockMannequin in project Armourers-Workshop by RiskyKen.

the class ItemPaintbrush method onItemUse.

@Override
public boolean onItemUse(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 (player.isSneaking() & block == ModBlocks.colourMixer) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te != null && te instanceof IPantable) {
            if (!world.isRemote) {
                int colour = ((IPantable) te).getColour(0);
                PaintType paintType = ((IPantable) te).getPaintType(0);
                setToolColour(stack, colour);
                setToolPaintType(stack, paintType);
            }
        }
        return true;
    }
    if (block instanceof IPantableBlock) {
        int newColour = getToolColour(stack);
        if (!world.isRemote) {
            UndoManager.begin(player);
            if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
                for (int i = 0; i < 6; i++) {
                    usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, i);
                }
            } else {
                usedOnBlockSide(stack, player, world, new BlockLocation(x, y, z), block, side);
            }
            UndoManager.end(player);
            if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
                world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);
            } else {
                world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 1.5F);
            }
        } else {
            spawnPaintParticles(world, x, y, z, side, newColour);
        }
        return true;
    }
    if (block == ModBlocks.armourerBrain & player.isSneaking()) {
        if (!world.isRemote) {
            TileEntity te = world.getTileEntity(x, y, z);
            if (te != null && te instanceof TileEntityArmourer) {
                ((TileEntityArmourer) te).toolUsedOnArmourer(this, world, stack, player);
            }
        }
        ModLogger.log("armourer");
        return true;
    }
    if (block == ModBlocks.mannequin) {
        if (!world.isRemote) {
            TileEntity te = ((BlockMannequin) block).getMannequinTileEntity(world, x, y, z);
            if (te != null && te instanceof TileEntityMannequin) {
                int newColour = getToolColour(stack);
                if (player.isSneaking()) {
                    ((TileEntityMannequin) te).setHairColour(newColour);
                } else {
                    ((TileEntityMannequin) te).setSkinColour(newColour);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockMannequin(riskyken.armourersWorkshop.common.blocks.BlockMannequin) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) Block(net.minecraft.block.Block) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock) IPantable(riskyken.armourersWorkshop.api.common.painting.IPantable) PaintType(riskyken.armourersWorkshop.common.painting.PaintType) BlockLocation(riskyken.armourersWorkshop.common.blocks.BlockLocation) TileEntityMannequin(riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 2 with BlockMannequin

use of riskyken.armourersWorkshop.common.blocks.BlockMannequin in project Armourers-Workshop by RiskyKen.

the class DollCraftingHandler method onEntityDestroy.

@Override
public void onEntityDestroy(Entity entity) {
    World world = entity.worldObj;
    if (!world.isRemote) {
        if (entity instanceof EntityFallingBlock) {
            if (((EntityFallingBlock) entity).func_145805_f() == Blocks.anvil) {
                int x = MathHelper.floor_double(entity.posX);
                int y = MathHelper.floor_double(entity.posY) - 1;
                int z = MathHelper.floor_double(entity.posZ);
                Block block = world.getBlock(x, y, z);
                if (block == ModBlocks.mannequin) {
                    ((BlockMannequin) block).convertToDoll(world, x, y, z);
                }
            }
        }
    }
}
Also used : BlockMannequin(riskyken.armourersWorkshop.common.blocks.BlockMannequin) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) Block(net.minecraft.block.Block) World(net.minecraft.world.World)

Aggregations

Block (net.minecraft.block.Block)2 BlockMannequin (riskyken.armourersWorkshop.common.blocks.BlockMannequin)2 EntityFallingBlock (net.minecraft.entity.item.EntityFallingBlock)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)1 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)1 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)1 PaintType (riskyken.armourersWorkshop.common.painting.PaintType)1 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)1 TileEntityMannequin (riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)1