From 86d85ede6b33812cddfdf0ad0a21c64387a16059 Mon Sep 17 00:00:00 2001 From: TomTom <93038247+AverageGithub@users.noreply.github.com> Date: Tue, 12 Mar 2024 18:26:33 +0100 Subject: [PATCH] Add storage limit for fisher and slayer minions --- .../listeners/MinionDamageListener.kt | 5 ++++- .../minions/miniontype/FisherMinionType.kt | 4 +++- .../minions/miniontype/MinerMinionType.kt | 20 ++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionDamageListener.kt b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionDamageListener.kt index 71a515d..7a31ce6 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionDamageListener.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/listeners/MinionDamageListener.kt @@ -17,8 +17,11 @@ class MinionDamageListener : Listener { fun onMinionKillEntityEvent(event: MinionKillEntityEvent) { val entitySize = AxMinionsPlugin.integrations.getStackerIntegration().getStackSize(event.target) + val amount = ThreadLocalRandom.current().nextInt(1, 4) * entitySize event.minion.setActions(event.minion.getActionAmount() + entitySize) - event.minion.setStorage(event.minion.getStorage() + ThreadLocalRandom.current().nextInt(1, 4) * entitySize) + if (event.minion.getStorage() + amount < event.minion.getType().getDouble("storage", event.minion.getLevel())) { + event.minion.setStorage(event.minion.getStorage() + amount * entitySize) + } Scheduler.get().runLaterAt(event.target.location, { event.target.location.world!!.getNearbyEntities(event.target.location, 4.0, 4.0, 4.0).filterIsInstance().fastFor { item -> diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/FisherMinionType.kt b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/FisherMinionType.kt index 6e91ed0..12bd2fd 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/FisherMinionType.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/FisherMinionType.kt @@ -76,7 +76,9 @@ class FisherMinionType : MinionType("fisher", AxMinionsPlugin.INSTANCE.getResour val xp = ThreadLocalRandom.current().nextInt(6) + 1 minion.addToContainerOrDrop(loot) - minion.setStorage(minion.getStorage() + xp) + if (minion.getStorage() + xp < minion.getType().getDouble("storage", minion.getLevel())) { + minion.setStorage(minion.getStorage() + xp) + } minion.setActions(minion.getActionAmount() + 1) minion.damageTool() } diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt index f6aea67..1c17f98 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/minions/miniontype/MinerMinionType.kt @@ -68,7 +68,9 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource when (getConfig().getString("mode").lowercase(Locale.ENGLISH)) { "sphere" -> { LocationUtils.getAllBlocksInRadius(minion.getLocation(), minion.getRange(), false).fastFor { location -> - if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) { + if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators() + .isChunkFullyLoaded(location) + ) { val gen = Main.getPlacedGenerators().getLoaded(location) val possible = gen?.isBlockPossibleToMine(location) ?: false @@ -100,7 +102,9 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource asyncExecutor!!.execute { LocationUtils.getAllBlocksInRadius(minion.getLocation(), minion.getRange(), false) .fastFor { location -> - if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) { + if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators() + .isChunkFullyLoaded(location) + ) { val gen = Main.getPlacedGenerators().getLoaded(location) val possible = gen?.isBlockPossibleToMine(location) ?: false @@ -127,7 +131,9 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource } else { LocationUtils.getAllBlocksInRadius(minion.getLocation(), minion.getRange(), false) .fastFor { location -> - if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) { + if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators() + .isChunkFullyLoaded(location) + ) { val gen = Main.getPlacedGenerators().getLoaded(location) val possible = gen?.isBlockPossibleToMine(location) ?: false @@ -154,7 +160,9 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource "line" -> { faces.fastFor { LocationUtils.getAllBlocksFacing(minion.getLocation(), minion.getRange(), it).fastFor { location -> - if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) { + if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators() + .isChunkFullyLoaded(location) + ) { val gen = Main.getPlacedGenerators().getLoaded(location) val possible = gen?.isBlockPossibleToMine(location) ?: false @@ -181,7 +189,9 @@ class MinerMinionType : MinionType("miner", AxMinionsPlugin.INSTANCE.getResource "face" -> { LocationUtils.getAllBlocksFacing(minion.getLocation(), minion.getRange(), minion.getDirection().facing) .fastFor { location -> - if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators().isChunkFullyLoaded(location)) { + if (AxMinionsPlugin.integrations.kGeneratorsIntegration && Main.getPlacedGenerators() + .isChunkFullyLoaded(location) + ) { val gen = Main.getPlacedGenerators().getLoaded(location) val possible = gen?.isBlockPossibleToMine(location) ?: false