mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2024-11-25 12:05:56 +01:00
Add storage limit for fisher and slayer minions
This commit is contained in:
parent
9bfcb7af2e
commit
86d85ede6b
@ -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<Item>().fastFor { item ->
|
||||
|
@ -76,7 +76,9 @@ class FisherMinionType : MinionType("fisher", AxMinionsPlugin.INSTANCE.getResour
|
||||
val xp = ThreadLocalRandom.current().nextInt(6) + 1
|
||||
|
||||
minion.addToContainerOrDrop(loot)
|
||||
if (minion.getStorage() + xp < minion.getType().getDouble("storage", minion.getLevel())) {
|
||||
minion.setStorage(minion.getStorage() + xp)
|
||||
}
|
||||
minion.setActions(minion.getActionAmount() + 1)
|
||||
minion.damageTool()
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user