use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiToolOptionUpdate in project Armourers-Workshop by RiskyKen.
the class GuiToolOptions method onGuiClosed.
@Override
public void onGuiClosed() {
NBTTagCompound compound = new NBTTagCompound();
writeToCompound(compound);
PacketHandler.networkWrapper.sendToServer(new MessageClientGuiToolOptionUpdate(compound));
}
use of riskyken.armourersWorkshop.common.network.messages.client.MessageClientGuiToolOptionUpdate 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;
}
Aggregations