Guest User

Untitled

a guest
Aug 31st, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package top.mod.item;
  2. import net.minecraft.entity.Entity;
  3. import net.minecraft.entity.EntityLivingBase;
  4. import net.minecraft.entity.projectile.EntityThrowable;
  5. import net.minecraft.init.Items;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.util.DamageSource;
  8. import net.minecraft.util.EnumParticleTypes;
  9. import net.minecraft.util.datafix.DataFixer;
  10. import net.minecraft.util.math.RayTraceResult;
  11. import net.minecraft.world.World;
  12. public class EntityKnife extends EntityThrowable{
  13. public EntityKnife(World worldIn) {
  14. super(worldIn);
  15.  
  16. }
  17. public EntityKnife(World worldIn, EntityLivingBase throwerIn) {
  18. super(worldIn, throwerIn);
  19.  
  20. }
  21. public EntityKnife(World worldIn, double x, double y, double z) {
  22. super(worldIn, x, y, z);
  23.  
  24. }
  25. public static void func_189662_a(DataFixer p_189662_0_)
  26. {
  27. EntityThrowable.func_189661_a(p_189662_0_, "knife");
  28. }
  29.  
  30. @Override
  31. protected void onImpact(RayTraceResult result)
  32. {
  33. if(result.entityHit != null)
  34. {
  35. result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 41.0F);
  36. }
  37. if(!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
  38. {
  39. int i = 1;
  40.  
  41. if(this.rand.nextInt(32) == 0)
  42. {
  43. i = 4;
  44. }
  45.  
  46. double d0 = 0.08D;
  47.  
  48. for (int k = 0; k < 8; ++k)
  49. {
  50. this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, this.posX, this.posY, this.posZ, ((double) this.rand.nextFloat() - 0.5D) * 0.08D, ((double) this.rand.nextFloat() - 0.5D) * 0.08D, ((double) this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Item.getIdFromItem(Items.EGG)});
  51. {
  52. if (true) {
  53. this.worldObj.createExplosion((Entity) this, i, k, 10F, i, true);
  54. }
  55. this.kill();
  56. }
  57.  
  58. if (!this.worldObj.isRemote)
  59. {
  60. this.setDead();
  61. }
  62. }
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment