use of riskyken.armourersWorkshop.common.painting.PaintType 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;
}
use of riskyken.armourersWorkshop.common.painting.PaintType in project Armourers-Workshop by RiskyKen.
the class ItemColourPicker method addInformation.
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean p_77624_4_) {
super.addInformation(stack, player, list, p_77624_4_);
if (getToolHasColour(stack)) {
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);
} else {
String noPaint = TranslateUtils.translate("item.armourersworkshop:rollover.nopaint");
list.add(noPaint);
}
}
use of riskyken.armourersWorkshop.common.painting.PaintType 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;
}
use of riskyken.armourersWorkshop.common.painting.PaintType in project Armourers-Workshop by RiskyKen.
the class ItemPaintRoller method usedOnBlockSide.
@SuppressWarnings("deprecation")
@Override
public void usedOnBlockSide(ItemStack stack, EntityPlayer player, World world, BlockLocation bl, Block block, int side) {
if (block instanceof IPantableBlock) {
int newColour = getToolColour(stack);
PaintType paintType = getToolPaintType(stack);
if (!world.isRemote) {
IPantableBlock worldColourable = (IPantableBlock) block;
if ((Boolean) ToolOptions.FULL_BLOCK_MODE.readFromNBT(stack.getTagCompound())) {
for (int i = 0; i < 6; i++) {
int oldColour = worldColourable.getColour(world, bl.x, bl.y, bl.z, i);
byte oldPaintType = (byte) worldColourable.getPaintType(world, bl.x, bl.y, bl.z, i).getKey();
UndoManager.blockPainted(player, world, bl.x, bl.y, bl.z, oldColour, oldPaintType, i);
((IPantableBlock) block).setColour(world, bl.x, bl.y, bl.z, newColour, i);
((IPantableBlock) block).setPaintType(world, bl.x, bl.y, bl.z, paintType, i);
}
} else {
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, newColour, side);
((IPantableBlock) block).setPaintType(world, bl.x, bl.y, bl.z, paintType, side);
}
} else {
spawnPaintParticles(world, bl.x, bl.y, bl.z, side, newColour);
}
}
}
use of riskyken.armourersWorkshop.common.painting.PaintType in project Armourers-Workshop by RiskyKen.
the class RenderBlockColourable method renderTileEntityAt.
public void renderTileEntityAt(TileEntityBoundingBox tileEntity, double x, double y, double z, float partialTickTime) {
if (!(tileEntity.getSkinPart() instanceof ISkinPartTypeTextured)) {
return;
}
GL11.glDisable(GL11.GL_LIGHTING);
ModRenderHelper.enableAlphaBlend();
renderer.startDrawingQuads();
renderer.setColourRGBA_F(0.7F, 0.7F, 0.7F, markerAlpha);
if (markerAlpha > 0F) {
for (int i = 0; i < 6; i++) {
if (tileEntity.isPaintableSide(i)) {
ForgeDirection dir = ForgeDirection.getOrientation(i);
PaintType paintType = tileEntity.getPaintType(i);
if (paintType != PaintType.NONE) {
bindTexture(MARKERS);
GL11.glColor3f(0.77F, 0.77F, 0.77F);
renderFaceWithMarker(x, y, z, dir, paintType.ordinal());
}
}
}
}
renderer.draw();
GL11.glColor4f(1F, 1F, 1F, 1F);
ModRenderHelper.disableAlphaBlend();
ModRenderHelper.enableLighting();
RenderHelper.enableStandardItemLighting();
}
Aggregations