CompoundTag modifierTag = new CompoundTag(); modifierTag.putDouble("Amount", modifier.getAmount()); modifierTag.putString("Name", modifier.getName()); modifierTag.putInt("Operation", modifier.getOperation().ordinal()); UUID uuid = modifier.getUniqueId();
public void activateAttributes() { double healthScale = getDouble("health_scale"); if (healthScale > 0) { Player player = mage.getPlayer(); if (player != null) { player.setHealthScale(healthScale); } } Collection<EntityAttributeModifier> modifiers = getAttributeModifiers(); if (modifiers == null) return; LivingEntity entity = mage.getLivingEntity(); if (entity == null) return; for (EntityAttributeModifier modifier : modifiers) { AttributeInstance attribute = entity.getAttribute(modifier.attribute); // Only do this once, it's really here to clean up attributes that may have gotten stuck on server crash if (!checkedAttributes) { Collection<AttributeModifier> existingModifiers = attribute.getModifiers(); for (AttributeModifier existing : existingModifiers) { if (existing.getName().equalsIgnoreCase(modifier.modifier.getName())) { mage.getController().getLogger().warning("Removed duplicate attribute modifier " + modifier.modifier.getName() + ", was this leftover from a server crash?"); attribute.removeModifier(existing); break; } } } attribute.addModifier(modifier.modifier); } checkedAttributes = true; }