Advertisement
jayhillx

LifeBindingEffect 03

May 19th, 2021
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. public void performEffect(LivingEntity entity, int amplifier) {
  2. Effect bindingEffect = LifeBindingPotion.LIFE_BINDING_EFFECT.get();
  3.  
  4. if (entity.isPotionActive(bindingEffect)) {
  5.  
  6. for (LivingEntity livingEntity : entity.world.getEntitiesWithinAABB(LivingEntity.class, entity.getBoundingBox().grow(2.0D))) {
  7. if (livingEntity.isAlive() && livingEntity != entity) {
  8.  
  9. if (!(livingEntity instanceof PlayerEntity && ((PlayerEntity) livingEntity).isCreative())) {
  10.  
  11. if (livingEntity instanceof PlayerEntity && entity instanceof PlayerEntity) {
  12. PlayerEntity player1 = (PlayerEntity)livingEntity;
  13. PlayerEntity player2 = (PlayerEntity)entity;
  14.  
  15. if (player1.isPotionActive(bindingEffect) && player2.isPotionActive(bindingEffect)) {
  16.  
  17. PlayerEntity.getUUID(player1.getGameProfile());
  18. PlayerEntity.getUUID(player2.getGameProfile());
  19.  
  20. player1.removePotionEffect(LifeBindingPotion.LIFE_BINDING_EFFECT.get());
  21. player2.removePotionEffect(LifeBindingPotion.LIFE_BINDING_EFFECT.get());
  22.  
  23. player1.getEntityWorld().playSound(null, (player1).getPosition(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.HOSTILE, 0.5F, 1.0F);
  24.  
  25. ((ServerWorld)player1.world).spawnParticle(ParticleTypes.EXPLOSION, player1.getPosX(), player1.getPosYHeight(1.0D), player1.getPosZ(), 8, 2.0D, 2.0D, 2.0D, 1.0D);
  26. ((ServerWorld)player2.world).spawnParticle(ParticleTypes.EXPLOSION, player2.getPosX(), player2.getPosYHeight(1.0D), player2.getPosZ(), 8, 2.0D, 2.0D, 2.0D, 1.0D);
  27.  
  28. CapabilityHelper.setPlayerBound((ServerPlayerEntity) player1, true);
  29. CapabilityHelper.setPlayerBound((ServerPlayerEntity) player2, true);
  30. }
  31. }
  32. }
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement