Advertisement
4epB9Ik

ZtonesFix

Jul 10th, 2017
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. /*  1:   */ package com.riciJak.Ztones.network;
  2. /*  2:   */
  3. /*  3:   */ import io.netty.buffer.ByteBuf;
  4. /*  4:   */ import io.netty.buffer.ByteBufInputStream;
  5. /*  5:   */ import java.io.IOException;
  6.  
  7.             import com.riciJak.Ztones.item.block.ItemDecoBlocks2;
  8.  
  9. /*  6:   */ import net.minecraft.entity.player.EntityPlayer;
  10. /*  7:   */ import net.minecraft.item.ItemStack;
  11. /*  8:   */
  12. /*  9:   */ public class ToggleMetaData
  13. /* 10:   */   implements IZTPacket
  14. /* 11:   */ {
  15. /* 12:18 */   private boolean incDamage = false;
  16. /* 13:   */  
  17. /* 14:   */   public ToggleMetaData() {}
  18. /* 15:   */  
  19. /* 16:   */   public ToggleMetaData(boolean incDamage)
  20. /* 17:   */   {
  21. /* 18:24 */     this.incDamage = incDamage;
  22. /* 19:   */   }
  23. /* 20:   */  
  24. /* 21:   */   public void processData(EntityPlayer entityPlayer, ByteBufInputStream bbis)
  25. /* 22:   */     throws IOException
  26. /* 23:   */   {
  27. /* 24:33 */     ItemStack itemStack = entityPlayer.getHeldItem();
  28. /* 25:34 */     if (itemStack != null && ((itemStack.getItem() instanceof ItemDecoBlocks2)))
  29. /* 26:   */     {
  30. /* 27:36 */       boolean incDmg = bbis.readBoolean();
  31. /* 28:37 */       int maxDmg = 15;
  32. /* 29:   */      
  33. /* 30:39 */       int itemDmg = itemStack.getItemDamage();
  34. /* 31:40 */       itemDmg += (incDmg ? 1 : -1);
  35. /* 32:41 */       if (itemDmg > maxDmg) {
  36. /* 33:43 */         itemDmg = 0;
  37. /* 34:45 */       } else if (itemDmg < 0) {
  38. /* 35:47 */         itemDmg = maxDmg;
  39. /* 36:   */       }
  40. /* 37:49 */       itemStack.setItemDamage(itemDmg);
  41. /* 38:   */     }
  42. /* 39:   */   }
  43. /* 40:   */  
  44. /* 41:   */   public void appendData(ByteBuf buffer)
  45. /* 42:   */     throws IOException
  46. /* 43:   */   {
  47. /* 44:57 */     buffer.writeBoolean(this.incDamage);
  48. /* 45:   */   }
  49. /* 46:   */ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement