Search in sources :

Example 11 with PaintType

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

the class ItemBurnTool method usedOnBlockSide.

@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
    int intensity = (Integer) ToolOptions.INTENSITY.readFromNBT(stack.getTagCompound());
    IPantableBlock worldColourable = (IPantableBlock) block;
    if (worldColourable.isRemoteOnly(world, bl.x, bl.y, bl.z, side) & world.isRemote) {
        byte[] rgbt = new byte[4];
        int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, side);
        PaintType oldPaintType = worldColourable.getPaintType(world, bl.x, bl.y, bl.z, side);
        Color c = UtilColour.makeColourDarker(new Color(oldColour), intensity);
        rgbt[0] = (byte) c.getRed();
        rgbt[1] = (byte) c.getGreen();
        rgbt[2] = (byte) c.getBlue();
        rgbt[3] = (byte) oldPaintType.getKey();
        if (block == ModBlocks.boundingBox && oldPaintType == PaintType.NONE) {
            rgbt[3] = (byte) PaintType.NORMAL.getKey();
        }
        MessageClientToolPaintBlock message = new MessageClientToolPaintBlock(bl.x, bl.y, bl.z, (byte) side, rgbt);
        PacketHandler.networkWrapper.sendToServer(message);
    } else if (!worldColourable.isRemoteOnly(world, bl.x, bl.y, bl.z, side) & !world.isRemote) {
        int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, side);
        byte oldPaintType = (byte) worldColourable.getPaintType(world, bl.x, bl.y, bl.z, side).getKey();
        int newColour = UtilColour.makeColourDarker(new Color(oldColour), intensity).getRGB();
        UndoManager.blockPainted(player, world, bl.x, bl.y, bl.z, oldColour, oldPaintType, side);
        ((IPantableBlock) block).setColour(world, bl.x, bl.y, bl.z, newColour, side);
    }
}
Also used : Color(java.awt.Color) MessageClientToolPaintBlock(riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock) PaintType(riskyken.armourersWorkshop.common.painting.PaintType) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 12 with PaintType

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

the class ItemDodgeTool method usedOnBlockSide.

@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
    int intensity = (Integer) ToolOptions.INTENSITY.readFromNBT(stack.getTagCompound());
    IPantableBlock worldColourable = (IPantableBlock) block;
    if (worldColourable.isRemoteOnly(world, bl.x, bl.y, bl.z, side) & world.isRemote) {
        byte[] rgbt = new byte[4];
        int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, side);
        PaintType oldPaintType = worldColourable.getPaintType(world, bl.x, bl.y, bl.z, side);
        Color c = UtilColour.makeColourBighter(new Color(oldColour), intensity);
        rgbt[0] = (byte) c.getRed();
        rgbt[1] = (byte) c.getGreen();
        rgbt[2] = (byte) c.getBlue();
        rgbt[3] = (byte) oldPaintType.getKey();
        if (block == ModBlocks.boundingBox && oldPaintType == PaintType.NONE) {
            rgbt[3] = (byte) PaintType.NORMAL.getKey();
        }
        MessageClientToolPaintBlock message = new MessageClientToolPaintBlock(bl.x, bl.y, bl.z, (byte) side, rgbt);
        PacketHandler.networkWrapper.sendToServer(message);
    } else if (!worldColourable.isRemoteOnly(world, bl.x, bl.y, bl.z, side) & !world.isRemote) {
        int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, side);
        byte oldPaintType = (byte) worldColourable.getPaintType(world, bl.x, bl.y, bl.z, side).getKey();
        int newColour = UtilColour.makeColourBighter(new Color(oldColour), intensity).getRGB();
        UndoManager.blockPainted(player, world, bl.x, bl.y, bl.z, oldColour, oldPaintType, side);
        ((IPantableBlock) block).setColour(world, bl.x, bl.y, bl.z, newColour, side);
    }
}
Also used : Color(java.awt.Color) MessageClientToolPaintBlock(riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock) PaintType(riskyken.armourersWorkshop.common.painting.PaintType) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 13 with PaintType

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

the class ItemHueTool method addInformation.

@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) {
    super.addInformation(stack, player, list, p_77624_4_);
    Color c = new Color(getToolColour(stack));
    PaintType paintType = getToolPaintType(stack);
    String hex = String.format("#%02x%02x%02x", c.getRed(), c.getGreen(), c.getBlue());
    String colourText = TranslateUtils.translate("item.armourersworkshop:rollover.colour", c.getRGB());
    String hexText = TranslateUtils.translate("item.armourersworkshop:rollover.hex", hex);
    String paintText = TranslateUtils.translate("item.armourersworkshop:rollover.paintType", paintType.getLocalizedName());
    list.add(colourText);
    list.add(hexText);
    list.add(paintText);
    list.add(TranslateUtils.translate("item.armourersworkshop:rollover.openSettings"));
}
Also used : Color(java.awt.Color) PaintType(riskyken.armourersWorkshop.common.painting.PaintType)

Example 14 with PaintType

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

the class ItemHueTool method usedOnBlockSide.

@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
    boolean changeHue = (boolean) ToolOptions.CHANGE_HUE.readFromNBTBool(stack.stackTagCompound);
    boolean changeSaturation = (boolean) ToolOptions.CHANGE_SATURATION.readFromNBTBool(stack.stackTagCompound);
    boolean changeBrightness = (boolean) ToolOptions.CHANGE_BRIGHTNESS.readFromNBTBool(stack.stackTagCompound);
    boolean changePaintType = (boolean) ToolOptions.CHANGE_PAINT_TYPE.readFromNBTBool(stack.stackTagCompound);
    Color toolColour = new Color(getToolColour(stack));
    PaintType paintType = getToolPaintType(stack);
    float[] toolhsb;
    toolhsb = Color.RGBtoHSB(toolColour.getRed(), toolColour.getGreen(), toolColour.getBlue(), null);
    IPantableBlock worldColourable = (IPantableBlock) block;
    if (worldColourable.isRemoteOnly(world, bl.x, bl.y, bl.z, side) & world.isRemote) {
        int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, side);
        byte oldPaintType = (byte) worldColourable.getPaintType(world, bl.x, bl.y, bl.z, side).getKey();
        float[] blockhsb;
        Color blockColour = new Color(oldColour);
        blockhsb = Color.RGBtoHSB(blockColour.getRed(), blockColour.getGreen(), blockColour.getBlue(), null);
        float[] recolour = new float[] { blockhsb[0], blockhsb[1], blockhsb[2] };
        if (changeHue) {
            recolour[0] = toolhsb[0];
        }
        if (changeSaturation) {
            recolour[1] = toolhsb[1];
        }
        if (changeBrightness) {
            recolour[2] = toolhsb[2];
        }
        int newColour = Color.HSBtoRGB(recolour[0], recolour[1], recolour[2]);
        Color c = new Color(newColour);
        byte[] rgbt = new byte[4];
        rgbt[0] = (byte) c.getRed();
        rgbt[1] = (byte) c.getGreen();
        rgbt[2] = (byte) c.getBlue();
        rgbt[3] = oldPaintType;
        if (changePaintType) {
            rgbt[3] = (byte) paintType.getKey();
        }
        MessageClientToolPaintBlock message = new MessageClientToolPaintBlock(bl.x, bl.y, bl.z, (byte) side, rgbt);
        PacketHandler.networkWrapper.sendToServer(message);
    } else if (!worldColourable.isRemoteOnly(world, bl.x, bl.y, bl.z, side) & !world.isRemote) {
        int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, side);
        byte oldPaintType = (byte) worldColourable.getPaintType(world, bl.x, bl.y, bl.z, side).getKey();
        float[] blockhsb;
        Color blockColour = new Color(oldColour);
        blockhsb = Color.RGBtoHSB(blockColour.getRed(), blockColour.getGreen(), blockColour.getBlue(), null);
        float[] recolour = new float[] { blockhsb[0], blockhsb[1], blockhsb[2] };
        if (changeHue) {
            recolour[0] = toolhsb[0];
        }
        if (changeSaturation) {
            recolour[1] = toolhsb[1];
        }
        if (changeBrightness) {
            recolour[2] = toolhsb[2];
        }
        int newColour = Color.HSBtoRGB(recolour[0], recolour[1], recolour[2]);
        UndoManager.blockPainted(player, world, bl.x, bl.y, bl.z, oldColour, oldPaintType, side);
        ((IPantableBlock) block).setColour(world, bl.x, bl.y, bl.z, newColour, side);
        if (changePaintType) {
            ((IPantableBlock) block).setPaintType(world, bl.x, bl.y, bl.z, paintType, side);
        }
    }
}
Also used : Color(java.awt.Color) MessageClientToolPaintBlock(riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock) PaintType(riskyken.armourersWorkshop.common.painting.PaintType) IPantableBlock(riskyken.armourersWorkshop.api.common.painting.IPantableBlock)

Example 15 with PaintType

use of riskyken.armourersWorkshop.common.painting.PaintType 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)

Aggregations

PaintType (riskyken.armourersWorkshop.common.painting.PaintType)24 Color (java.awt.Color)12 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)12 Block (net.minecraft.block.Block)6 MessageClientToolPaintBlock (riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock)6 TileEntity (net.minecraft.tileentity.TileEntity)5 IPantable (riskyken.armourersWorkshop.api.common.painting.IPantable)5 TileEntityArmourer (riskyken.armourersWorkshop.common.tileentities.TileEntityArmourer)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 ISkinPartTypeTextured (riskyken.armourersWorkshop.api.common.skin.type.ISkinPartTypeTextured)2 BlockLocation (riskyken.armourersWorkshop.common.blocks.BlockLocation)2 Point (java.awt.Point)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 World (net.minecraft.world.World)1 IPoint3D (riskyken.armourersWorkshop.api.common.IPoint3D)1 ICubeColour (riskyken.armourersWorkshop.api.common.skin.cubes.ICubeColour)1 BlockMannequin (riskyken.armourersWorkshop.common.blocks.BlockMannequin)1 MessageClientGuiColourUpdate (riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiColourUpdate)1 MessageClientGuiToolOptionUpdate (riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiToolOptionUpdate)1