Search in sources :

Example 1 with IPantable

use of riskyken.armourersWorkshop.api.common.painting.IPantable in project Armourers-Workshop by RiskyKen.

the class ItemColourPicker method onItemUse.

@SuppressWarnings("deprecation")
@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);
    boolean changePaintType = (boolean) ToolOptions.CHANGE_PAINT_TYPE.readFromNBTBool(stack.stackTagCompound);
    PaintType paintType = getToolPaintType(stack);
    if (player.isSneaking() & block == ModBlocks.colourMixer & getToolHasColour(stack)) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te != null && te instanceof IPantable) {
            if (!world.isRemote) {
                int colour = getToolColour(stack);
                ;
                ((IPantable) te).setColour(colour);
                ((IPantable) te).setPaintType(paintType, 0);
            }
        }
        return true;
    }
    if (block instanceof IPantableBlock) {
        IPantableBlock paintable = (IPantableBlock) block;
        PaintType targetPaintType = paintable.getPaintType(world, x, y, z, side);
        if (paintable.isRemoteOnly(world, x, y, z, side) & world.isRemote) {
            int colour = paintable.getColour(world, x, y, z, side);
            NBTTagCompound compound = new NBTTagCompound();
            byte[] paintData = new byte[4];
            Color c = new Color(colour);
            paintData[0] = (byte) c.getRed();
            paintData[1] = (byte) c.getGreen();
            paintData[2] = (byte) c.getBlue();
            if (changePaintType) {
                paintData[3] = (byte) targetPaintType.getKey();
            } else {
                paintData[3] = (byte) paintType.getKey();
            }
            PaintingHelper.setPaintData(compound, paintData);
            PacketHandler.networkWrapper.sendToServer(new MessageClientGuiToolOptionUpdate(compound));
        } else if (!paintable.isRemoteOnly(world, x, y, z, side) & !world.isRemote) {
            setToolColour(stack, ((IPantableBlock) block).getColour(world, x, y, z, side));
            if (changePaintType) {
                setToolPaintType(stack, targetPaintType);
            } else {
                setToolPaintType(stack, paintType);
            }
        }
        if (!world.isRemote) {
            world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PICKER, 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) MessageClientGuiToolOptionUpdate(riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiToolOptionUpdate) Color(java.awt.Color) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) 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) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 2 with IPantable

use of riskyken.armourersWorkshop.api.common.painting.IPantable in project Armourers-Workshop by RiskyKen.

the class ItemHueTool 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) {
        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);
        }
        if (!world.isRemote) {
            UndoManager.end(player);
            world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.BURN, 1.0F, 1.0F);
        }
        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);
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityArmourer(riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer) MessageClientToolPaintBlock(riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock) 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) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 3 with IPantable

use of riskyken.armourersWorkshop.api.common.painting.IPantable in project Armourers-Workshop by RiskyKen.

the class ItemPaintRoller 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) {
        if (!world.isRemote) {
            UndoManager.begin(player);
        }
        paintArea(world, block, player, stack, x, y, z, side);
        if (!world.isRemote) {
            world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, LibSounds.PAINT, 1.0F, world.rand.nextFloat() * 0.1F + 0.9F);
            UndoManager.end(player);
        }
        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);
            }
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) 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) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 4 with IPantable

use of riskyken.armourersWorkshop.api.common.painting.IPantable 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 5 with IPantable

use of riskyken.armourersWorkshop.api.common.painting.IPantable in project Armourers-Workshop by RiskyKen.

the class ItemDyeBottle 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;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Block(net.minecraft.block.Block) IPantable(riskyken.armourersWorkshop.api.common.painting.IPantable) PaintType(riskyken.armourersWorkshop.common.painting.PaintType)

Aggregations

Block (net.minecraft.block.Block)5 TileEntity (net.minecraft.tileentity.TileEntity)5 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)5 PaintType (riskyken.armourersWorkshop.common.painting.PaintType)5 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)4 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)3 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)2 Color (java.awt.Color)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockMannequin (riskyken.armourersWorkshop.common.blocks.BlockMannequin)1 MessageClientGuiToolOptionUpdate (riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiToolOptionUpdate)1 MessageClientToolPaintBlock (riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock)1 TileEntityMannequin (riskyken.armourersWorkshop.common.tileentities.TileEntityMannequin)1