pjc21

itemEvents.zs

May 16th, 2021
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. CTEventManager.register<MCLivingEntityUseItemEvent>((event) => {
  2.  
  3. val entity = event.entityLiving as MCLivingEntity;
  4.  
  5. if (entity is MCPlayerEntity) {
  6.  
  7. var itemStack = event.item as IItemStack;
  8. var duration = event.duration as int;
  9.  
  10. if (itemStack.commandString.startsWith('<item:minecraft:potion') && duration == 0 && itemStack.hasTag && itemStack.hasEffect) {
  11.  
  12. val activeEffectsOnPlaayer = entity.getActivePotionMap();
  13.  
  14. if !(activeEffectsOnPlaayer.isEmpty) {
  15. for playerPotionEffect, playerEffectInstance in activeEffectsOnPlaayer {
  16. entity.removePotionEffect(playerPotionEffect);
  17. }
  18. }
  19. }
  20. }
  21. });
Advertisement
Add Comment
Please, Sign In to add comment