Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
- Integer color = getColorFromStack(stack);
- if (stack.getItemDamage() > getMaxDamage() || color == null) return true;
- if (PaintUtils.instance.isAllowedToReplace(world, x, y, z)) {
- Block block = world.getBlock(x, y, z);
- System.out.println("Material is " + block.getMaterial());
- BlockCanvas newCanvas = new BlockCanvas(block.getMaterial());
- newCanvas.replaceBlock(world, x, y, z);
- }
- final boolean changed;
- if (player.isSneaking()) changed = tryRecolorBlock(world, x, y, z, color, ForgeDirection.VALID_DIRECTIONS);
- else changed = tryRecolorBlock(world, x, y, z, color, ForgeDirection.getOrientation(side));
- if (changed) {
- world.playSoundAtEntity(player, "mob.slime.small", 0.1F, 0.8F);
- if (!player.capabilities.isCreativeMode) {
- if (stack.attemptDamageItem(1, player.getRNG())) {
- final NBTTagCompound tag = ItemUtils.getItemTag(stack);
- tag.removeTag(TAG_COLOR);
- stack.setItemDamage(0);
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement