Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void performEffect(LivingEntity entity, int amplifier) {
- entity.level().getEntities(entity, entity.getBoundingBox().inflate(2.0D)).stream().filter(e -> e instanceof Player).map(e -> (Player) e).filter(nearbyPlayer -> nearbyPlayer.hasEffect(MobEffects.ABSORPTION)).forEach(nearbyPlayer -> {
- Set<Player> playersSet = new HashSet<>(List.of(nearbyPlayer, (Player) entity));
- if (entity.getServer() != null) {
- ServerLevel overworld = entity.getServer().getLevel(Level.OVERWORLD);
- overworld.getCapability(BindingCapability.BOUND).ifPresent(bound -> {
- playersSet.forEach(player -> {
- bound.getPlayers().computeIfAbsent(player.getUniqueID(), orNewId -> {
- PlayerData data = new PlayerData(new CompoundNBT());
- data.setId(player.getUniqueID().toString());
- data.setName(player.getName().getString());
- data.getBoundPlayer().setName(playersSet.stream().filter(p -> p != player).findFirst().orElse(player).getName().getString());
- data.getBoundPlayer().setId(playersSet.stream().filter(p -> p != player).findFirst().orElse(player).getUniqueID());
- return data;
- });
- });
- playersSet.forEach(player -> {
- player.removePotionEffect(this);
- if (!player.world.isRemote) {
- player.world.playSound(null, player.getPosition(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.HOSTILE, 0.5F, 1.0F);
- overworld.spawnParticle(ParticleTypes.EXPLOSION, player.posX, player.posY, player.posZ, 24, 2.0D, 2.0D, 2.0D, 0.0D);
- }
- });
- });
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement