Advertisement
SuperZanti

Untitled

May 29th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. @Override
  2. public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
  3. Integer color = getColorFromStack(stack);
  4. if (stack.getItemDamage() > getMaxDamage() || color == null) return true;
  5.  
  6. if (PaintUtils.instance.isAllowedToReplace(world, x, y, z)) {
  7. Block block = world.getBlock(x, y, z);
  8. System.out.println("Material is " + block.getMaterial());
  9. BlockCanvas newCanvas = new BlockCanvas(block.getMaterial());
  10. newCanvas.replaceBlock(world, x, y, z);
  11. }
  12.  
  13. final boolean changed;
  14.  
  15. if (player.isSneaking()) changed = tryRecolorBlock(world, x, y, z, color, ForgeDirection.VALID_DIRECTIONS);
  16. else changed = tryRecolorBlock(world, x, y, z, color, ForgeDirection.getOrientation(side));
  17.  
  18. if (changed) {
  19. world.playSoundAtEntity(player, "mob.slime.small", 0.1F, 0.8F);
  20.  
  21. if (!player.capabilities.isCreativeMode) {
  22. if (stack.attemptDamageItem(1, player.getRNG())) {
  23. final NBTTagCompound tag = ItemUtils.getItemTag(stack);
  24. tag.removeTag(TAG_COLOR);
  25. stack.setItemDamage(0);
  26. }
  27. }
  28. }
  29.  
  30. return true;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement