From d4134b44433d53d273b76ad1725e1d1275e8c9f6 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Tue, 16 Nov 2021 20:08:32 +0300 Subject: [PATCH 1/3] Added null check for all attributes (now ghast as base mob will work), started removing all modifiers from the entity (to avoid random bosses with other modifiers being OP) --- .../ecobosses/bosses/LivingEcoBoss.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java index a1a6a5d..e2fe248 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java @@ -150,18 +150,23 @@ public class LivingEcoBoss extends PluginDependent { movementSpeed.addModifier(new AttributeModifier(entity.getUniqueId(), "ecobosses-movement-multiplier", boss.getMovementSpeedMultiplier() - 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1)); AttributeInstance maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH); - assert maxHealth != null; - maxHealth.setBaseValue(boss.getMaxHealth()); - - entity.setHealth(maxHealth.getValue()); + if (maxHealth != null) { + maxHealth.getModifiers().clear(); + maxHealth.setBaseValue(boss.getMaxHealth()); + entity.setHealth(maxHealth.getValue()); + } AttributeInstance followRange = entity.getAttribute(Attribute.GENERIC_FOLLOW_RANGE); - assert followRange != null; - followRange.setBaseValue(boss.getFollowRange()); + if (followRange != null) { + followRange.getModifiers().clear(); + followRange.setBaseValue(boss.getFollowRange()); + } AttributeInstance attackDamage = entity.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE); - assert attackDamage != null; - attackDamage.setBaseValue(boss.getAttackDamage()); + if (attackDamage != null) { + attackDamage.getModifiers().clear(); + attackDamage.setBaseValue(boss.getAttackDamage()); + } for (OptionedSound sound : boss.getSpawnSounds()) { entity.getWorld().playSound(entity.getLocation(), sound.sound(), sound.volume(), sound.pitch()); From 97a07f31bfbfae17ba38441c0c13e7c7f922549f Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Tue, 16 Nov 2021 20:08:32 +0300 Subject: [PATCH 2/3] Added null check for all attributes (now ghast as base mob will work), started removing all modifiers from the entity (to avoid random bosses with other modifiers being OP) --- .../ecobosses/bosses/LivingEcoBoss.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java index a1a6a5d..e2fe248 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/LivingEcoBoss.java @@ -150,18 +150,23 @@ public class LivingEcoBoss extends PluginDependent { movementSpeed.addModifier(new AttributeModifier(entity.getUniqueId(), "ecobosses-movement-multiplier", boss.getMovementSpeedMultiplier() - 1, AttributeModifier.Operation.MULTIPLY_SCALAR_1)); AttributeInstance maxHealth = entity.getAttribute(Attribute.GENERIC_MAX_HEALTH); - assert maxHealth != null; - maxHealth.setBaseValue(boss.getMaxHealth()); - - entity.setHealth(maxHealth.getValue()); + if (maxHealth != null) { + maxHealth.getModifiers().clear(); + maxHealth.setBaseValue(boss.getMaxHealth()); + entity.setHealth(maxHealth.getValue()); + } AttributeInstance followRange = entity.getAttribute(Attribute.GENERIC_FOLLOW_RANGE); - assert followRange != null; - followRange.setBaseValue(boss.getFollowRange()); + if (followRange != null) { + followRange.getModifiers().clear(); + followRange.setBaseValue(boss.getFollowRange()); + } AttributeInstance attackDamage = entity.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE); - assert attackDamage != null; - attackDamage.setBaseValue(boss.getAttackDamage()); + if (attackDamage != null) { + attackDamage.getModifiers().clear(); + attackDamage.setBaseValue(boss.getAttackDamage()); + } for (OptionedSound sound : boss.getSpawnSounds()) { entity.getWorld().playSound(entity.getLocation(), sound.sound(), sound.volume(), sound.pitch()); From b13bcdd14cc388ba38d306ac3d09e1149b0e0f94 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Sat, 27 Nov 2021 13:45:57 +0300 Subject: [PATCH 3/3] Fixed consuming 2 eggs instead of 1 --- .../com/willfp/ecobosses/bosses/listeners/SpawnListeners.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/SpawnListeners.java b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/SpawnListeners.java index e8507a0..42906d4 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/SpawnListeners.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecobosses/bosses/listeners/SpawnListeners.java @@ -134,8 +134,6 @@ public class SpawnListeners extends PluginDependent implements Listen return; } - item.setAmount(item.getAmount() - 1); - if (event.getHand() == EquipmentSlot.HAND) { ItemStack hand = event.getPlayer().getInventory().getItemInMainHand(); hand.setAmount(hand.getAmount() - 1);