Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SubscribeEvent
- public void onPlayerDeath(LivingDeathEvent event) {
- Entity entity = event.getEntity();
- if (entity instanceof PlayerEntity) {
- PlayerEntity player = (PlayerEntity)entity;
- for (ServerPlayerEntity serverPlayerEntity : player.getServer().getPlayerList().getPlayers()) {
- if (player.getCapability(BindingCapabilities.LIFE_BOUND_CAPABILITY).orElse(null).isBound()) {
- IBoundCapability bound = player.getCapability(BindingCapabilities.LIFE_BOUND_CAPABILITY).orElse(null);
- /** Stops a loop of bound players from dying. */
- if (event.getSource() == ModDamageSource.LIFE_BINDING) {
- serverPlayerEntity.removePotionEffect(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get());
- }
- /** Adds potion effect to bound player. */
- player.getServer().getPlayerList().getPlayerByUUID(bound.getUUID()).addPotionEffect(new EffectInstance(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get(), 300));
- /** Removes potion from player who had died/triggered the event. */
- player.removePotionEffect(LifeBindingPotion.LIFE_DAMAGING_EFFECT.get());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement