Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. package com.TheRPGAdventurer.ROTD.client.items;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Collections;
  5. import java.util.Iterator;
  6. import java.util.List;
  7.  
  8. import javax.annotation.Nullable;
  9.  
  10. import com.TheRPGAdventurer.ROTD.DragonMounts;
  11. import com.TheRPGAdventurer.ROTD.client.sound.ModSounds;
  12. import com.TheRPGAdventurer.ROTD.server.entity.IDragonWhistle;
  13. import com.TheRPGAdventurer.ROTD.server.network.MessageDragonWhistle;
  14.  
  15. import net.minecraft.client.util.ITooltipFlag;
  16. import net.minecraft.entity.Entity;
  17. import net.minecraft.entity.ai.EntityAINearestAttackableTarget.Sorter;
  18. import net.minecraft.entity.player.EntityPlayer;
  19. import net.minecraft.item.Item;
  20. import net.minecraft.item.ItemStack;
  21. import net.minecraft.util.ActionResult;
  22. import net.minecraft.util.EnumActionResult;
  23. import net.minecraft.util.EnumHand;
  24. import net.minecraft.util.ResourceLocation;
  25. import net.minecraft.util.SoundCategory;
  26. import net.minecraft.util.math.AxisAlignedBB;
  27. import net.minecraft.world.World;
  28. import net.minecraftforge.fml.relauncher.Side;
  29. import net.minecraftforge.fml.relauncher.SideOnly;
  30.  
  31. public class ItemDragonWhistle extends Item {
  32.  
  33. ItemDragonWhistle.Commands commands;
  34. private final MessageDragonWhistle dcw = new MessageDragonWhistle();
  35.  
  36. public ItemDragonWhistle() {
  37. this.setUnlocalizedName("dragon_whistle");
  38. this.setRegistryName(new ResourceLocation(DragonMounts.MODID, "dragon_whistle"));
  39. this.setMaxStackSize(1);
  40. this.setCreativeTab(DragonMounts.TAB);
  41. }
  42.  
  43. public void setCommands(ItemDragonWhistle.Commands commands) {
  44. this.commands = commands;
  45. }
  46.  
  47. public ItemDragonWhistle.Commands getCommands() {
  48. return commands;
  49. }
  50.  
  51. @Override // this is the major problem , when i use its commands to add Info, the game crashes causing a nullpointer exception which means the command never works in the first place
  52. @SideOnly(Side.CLIENT)
  53. public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
  54. // tooltip.add(StatCollector.translateToLocal(commands.toString().toLowerCase()));
  55. }
  56.  
  57.  
  58. @Override
  59. public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand hand) {
  60. ItemStack itemStackIn = player.getHeldItem(hand);
  61.  
  62. worldIn.playSound(player, player.getPosition(), ModSounds.DRAGON_WHISTLE, SoundCategory.PLAYERS, 1, 1);
  63. return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
  64. }
  65.  
  66. /*
  67. if(dragon.isTamed() && dragon.isOwner(player)) {
  68. if (dragon.isFlying() || dragon.isHovering()) {
  69. dragon.setFlying(false);
  70. dragon.setHovering(false);
  71. }
  72.  
  73. }*/
  74.  
  75. // @SubscribeEvent
  76. /// public void onTick(ClientTickEvent evt) {
  77. // BitSet flags = dcw.getFlags();
  78. // flags.set(0, commands == Commands.COME);
  79. // flags.set(1, commands == Commands.CIRCLE);
  80. // flags.set(2, KEY_HOVERCANCEL.isPressed());
  81.  
  82. // send message to server if it has changed
  83. // if (dcw.hasChanged()) {
  84. // DragonMounts.NETWORK_WRAPPER.sendToServer(dcw);
  85. // }
  86. // }
  87.  
  88. public enum Commands {
  89. NONE(),
  90. COME(),
  91. CIRCLE();
  92.  
  93.  
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement