use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock 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);
}
}
}
use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock 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;
}
use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock in project Armourers-Workshop by RiskyKen.
the class MessageClientToolPaintBlock method onMessage.
@SuppressWarnings("deprecation")
@Override
public IMessage onMessage(MessageClientToolPaintBlock message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
if (player != null && player.getEntityWorld() != null) {
World world = player.getEntityWorld();
Block block = world.getBlock(message.x, message.y, message.z);
if (block instanceof IPantableBlock) {
UndoManager.begin(player);
IPantableBlock paintable = (IPantableBlock) block;
int oldColour = paintable.getColour(world, message.x, message.y, message.z, message.side);
PaintType oldPaintType = paintable.getPaintType(world, message.x, message.y, message.z, message.side);
UndoManager.blockPainted(player, world, message.x, message.y, message.z, oldColour, (byte) oldPaintType.getKey(), message.side);
paintable.setColour(world, message.x, message.y, message.z, message.rgbt, message.side);
paintable.setPaintType(world, message.x, message.y, message.z, PaintType.getPaintTypeFormSKey(message.rgbt[3]), message.side);
UndoManager.end(player);
}
}
return null;
}
use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock in project Armourers-Workshop by RiskyKen.
the class ItemPaintbrush method usedOnBlockSide.
@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
int colour = getToolColour(stack);
PaintType paintType = getToolPaintType(stack);
IPantableBlock worldColourable = (IPantableBlock) block;
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();
UndoManager.blockPainted(player, world, bl.x, bl.y, bl.z, oldColour, oldPaintType, side);
((IPantableBlock) block).setColour(world, bl.x, bl.y, bl.z, colour, side);
((IPantableBlock) block).setPaintType(world, bl.x, bl.y, bl.z, paintType, side);
}
use of riskyken.armourersWorkshop.api.common.painting.IPantableBlock 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;
}
Aggregations