Advertisement
Guest User

Untitled

a guest
Nov 14th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. package com.reactioncraft.net.common;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.annotation.Nullable;
  6.  
  7. import com.reactioncraft.reactioncraft;
  8. import com.reactioncraft.core.ItemBase;
  9. import com.reactioncraft.core.ItemModelProvider;
  10. import com.reactioncraft.integration.instances.IntegratedItems;
  11.  
  12. import net.minecraft.entity.Entity;
  13. import net.minecraft.entity.EntityHanging;
  14. import net.minecraft.entity.EntityList;
  15. import net.minecraft.entity.EntityLiving;
  16. import net.minecraft.entity.EntityLivingBase;
  17. import net.minecraft.entity.IEntityLivingData;
  18. import net.minecraft.entity.boss.EntityDragon;
  19. import net.minecraft.entity.boss.EntityDragonPart;
  20. import net.minecraft.entity.player.EntityPlayer;
  21. import net.minecraft.item.*;
  22. import net.minecraft.nbt.NBTTagCompound;
  23. import net.minecraft.nbt.NBTTagDouble;
  24. import net.minecraft.nbt.NBTTagFloat;
  25. import net.minecraft.nbt.NBTTagList;
  26. import net.minecraft.util.ActionResult;
  27. import net.minecraft.util.EnumActionResult;
  28. import net.minecraft.util.EnumFacing;
  29. import net.minecraft.util.EnumHand;
  30. import net.minecraft.util.math.BlockPos;
  31. import net.minecraft.util.math.MathHelper;
  32. import net.minecraft.world.World;
  33.  
  34. public class ItemCaughtEntity extends ItemBase implements ItemModelProvider
  35. {
  36. public ItemCaughtEntity(String string)
  37. {
  38. super(string);
  39. }
  40.  
  41. @Override
  42. public void registerItemModel(Item item)
  43. {
  44. reactioncraft.proxy.registerItemRenderer(this, 0, "caught");
  45. }
  46.  
  47. public String getItemDisplayName(ItemStack itemStack)
  48. {
  49. return itemStack.getTagCompound().getString("entity") == "player" ? "Caught " + itemStack.getTagCompound().getString("playerUser") + " DNA" : "Caught " + itemStack.getTagCompound().getString("entity");
  50. }
  51.  
  52. /**
  53. * Called when a Block is right-clicked with this Item
  54. */
  55. public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
  56. {
  57. BlockPos blockpos = pos.offset(facing);
  58.  
  59. ItemStack caught = new ItemStack(IntegratedItems.caught);
  60.  
  61. Entity entity = EntityList.createEntityByName(caught.getTagCompound().getString("entity"), worldIn);
  62.  
  63. if (playerIn.canPlayerEdit(blockpos, facing, stack))
  64. {
  65. //EntityHanging entityhanging = this.createEntity(worldIn, blockpos, facing);
  66.  
  67. if (entity != null) //&& entityhanging.onValidSurface())
  68. {
  69. if (!worldIn.isRemote)
  70. {
  71. //entity.play();
  72. worldIn.spawnEntityInWorld(entity);
  73. }
  74.  
  75. --stack.stackSize;
  76. }
  77.  
  78. return EnumActionResult.SUCCESS;
  79. }
  80. else
  81. {
  82. return EnumActionResult.FAIL;
  83. }
  84. }
  85.  
  86. @Override
  87. public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
  88. {
  89. if (itemStack.getTagCompound() != null)
  90. {
  91. list.add("Name: " + itemStack.getTagCompound().getString("entity"));
  92. }
  93. }
  94.  
  95. // /**
  96. // * Spawns the creature specified by the egg's type in the location specified by
  97. // * the last three parameters.
  98. // * Parameters: world, entityID, x, y, z.
  99. // */
  100. // public Entity onItemUse(World parWorld, double parX, double parY, double parZ)
  101. // {
  102. //
  103. // ItemStack caught = new ItemStack(IntegratedItems.caught);
  104. //
  105. // Entity entity = EntityList.createEntityByName(caught.getTagCompound().getString("entity"), parWorld);
  106. //
  107. // if (!parWorld.isRemote) // never spawn entity on client side
  108. // {
  109. // if (entity instanceof EntityLiving)
  110. // {
  111. // entity = (EntityLiving) EntityList
  112. // .createEntityByName(name, parWorld);
  113. // entity.setLocationAndAngles(parX, parY, parZ, (parWorld.rand.nextFloat() * 360.0F), 0.0F);
  114. // parWorld.spawnEntityInWorld(entity);
  115. // ((EntityLiving) entity).onInitialSpawn(parWorld.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData)null);
  116. // ((EntityLiving) entity).playLivingSound();
  117. // }
  118. // else
  119. // {
  120. // //DEBUG
  121. // System.out.println("Entity not found ");
  122. // }
  123. // }
  124. //
  125. // return entity;
  126. // }
  127. //
  128.  
  129. public static NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble)
  130. {
  131. NBTTagList var2 = new NBTTagList();
  132. double[] var3 = par1ArrayOfDouble;
  133. int var4 = par1ArrayOfDouble.length;
  134.  
  135. for (int var5 = 0; var5 < var4; ++var5)
  136. {
  137. double var6 = var3[var5];
  138. var2.appendTag(new NBTTagDouble(var6));
  139. }
  140.  
  141. return var2;
  142. }
  143.  
  144. public static NBTTagList newFloatNBTList(float ... par1ArrayOfFloat)
  145. {
  146. NBTTagList var2 = new NBTTagList();
  147. float[] var3 = par1ArrayOfFloat;
  148. int var4 = par1ArrayOfFloat.length;
  149.  
  150. for (int var5 = 0; var5 < var4; ++var5)
  151. {
  152. float var6 = var3[var5];
  153. var2.appendTag(new NBTTagFloat(var6));
  154. }
  155.  
  156. return var2;
  157. }
  158.  
  159. /**
  160. * allows items to add custom lines of information to the mouseover description
  161. */
  162. //public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
  163. //{
  164. // if (itemStack.getTagCompound() != null)
  165. // {
  166. // list.add("Caught " + itemStack.getTagCompound().getString("entity"));
  167. // }
  168. // else
  169. // {
  170. // list.add("Please craft to see results");
  171. // }
  172.  
  173. // super.addInformation(itemStack, player, list, par4);
  174. //}
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement