Search in sources :

Example 1 with MessageClientToolPaintBlock

use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock in project Armourers-Workshop by RiskyKen.

the class ItemColourNoiseTool method usedOnBlockSide.

@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
    int intensity = UtilItems.getIntensityFromStack(stack, 16);
    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.addColourNoise(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.addColourNoise(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 2 with MessageClientToolPaintBlock

use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock 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 3 with MessageClientToolPaintBlock

use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock 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 4 with MessageClientToolPaintBlock

use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock 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 5 with MessageClientToolPaintBlock

use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock in project Armourers-Workshop by RiskyKen.

the class ItemShadeNoiseTool method usedOnBlockSide.

@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
    int intensity = UtilItems.getIntensityFromStack(stack, 16);
    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.addShadeNoise(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.addShadeNoise(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)

Aggregations

Color (java.awt.Color)5 IPantableBlock (riskyken.armourersWorkshop.api.common.painting.IPantableBlock)5 MessageClientToolPaintBlock (riskyken.armourersWorkshop.common.network.messages.client.MessageClientToolPaintBlock)5 PaintType (riskyken.armourersWorkshop.common.painting.PaintType)5