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);
- if (event.getSource() == ModDamageSource.causeBoundPlayer(player)) {
- BoundPlayersList.removeUsername(bound.getUUID());
- } else {
- BoundPlayersList.setUsername(bound.getUUID(), bound.getName());
- }
- if (!player.world.isRemote) {
- /** Adds potion effect to bound player. */
- serverPlayerEntity.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