Advertisement
Guest User

Untitled

a guest
Oct 8th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public class MagicBallEntity extends ProjectileItemEntity {
  2.  
  3. public MagicBallEntity(EntityType<MagicBallEntity> type, World worldIn) {
  4. super(type,worldIn);
  5.  
  6. this.setNoGravity(true); //doesn't work
  7. }
  8. public MagicBallEntity(LivingEntity entity, World worldIn){
  9. super(EntityList.MAGIC_PROJECTILE.get(), entity, worldIn);
  10. }
  11.  
  12. public MagicBallEntity(double x, double y, double z, World worldIn){
  13. super(EntityList.MAGIC_PROJECTILE.get(), x, y, z, worldIn);
  14. }
  15.  
  16. @Override
  17. protected Item getDefaultItem() {
  18. return RegistryHandler.MAGIC_BALL.get().asItem();
  19. }
  20.  
  21. @Override
  22. public IPacket<?> createSpawnPacket() {
  23. return NetworkHooks.getEntitySpawningPacket(this);
  24. }
  25.  
  26. @Override
  27. protected void onImpact(RayTraceResult result) {
  28.  
  29. if(result.getType() == RayTraceResult.Type.ENTITY)
  30. {
  31. Entity entity = ((EntityRayTraceResult)result).getEntity();
  32. int damage = 0;
  33.  
  34. if(entity instanceof Entity)
  35. {
  36. damage = 5;
  37. }
  38.  
  39. entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getEntity()), (float)damage);
  40. }
  41.  
  42. if(!world.isRemote)
  43. {
  44. remove();
  45. }
  46. }
  47.  
  48.  
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement