mirror of
https://github.com/Artillex-Studios/AxMinions.git
synced 2024-11-25 12:05:56 +01:00
Fix
This commit is contained in:
parent
856a8dbbb8
commit
3842824a65
@ -653,7 +653,7 @@ class Minion(
|
||||
if (linkedChest == null) return
|
||||
|
||||
if (ticking) {
|
||||
Scheduler.get().runAt(linkedChest) {
|
||||
Scheduler.get().runAt(linkedChest) { a ->
|
||||
if (linkedChest!!.world!!.isChunkLoaded(linkedChest!!.blockX shr 4, linkedChest!!.blockZ shr 4)) {
|
||||
linkedInventory = (linkedChest?.block?.state as? Container)?.inventory
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ package com.artillexstudios.axminions.minions
|
||||
|
||||
import com.artillexstudios.axminions.api.minions.Minion
|
||||
import com.artillexstudios.axminions.api.minions.utils.ChunkPos
|
||||
import com.artillexstudios.axapi.scheduler.Scheduler
|
||||
import java.util.Collections
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
import kotlin.concurrent.read
|
||||
import kotlin.concurrent.write
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Chunk
|
||||
|
||||
object Minions {
|
||||
@ -17,8 +19,19 @@ object Minions {
|
||||
val chunkZ = chunk.z
|
||||
val world = chunk.world
|
||||
|
||||
run breaking@{
|
||||
lock.read {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
Scheduler.get().run { a ->
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
it.setTicking(true)
|
||||
return@breaking
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
it.setTicking(true)
|
||||
@ -27,6 +40,7 @@ object Minions {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun isTicking(chunk: Chunk): Boolean {
|
||||
@ -34,14 +48,12 @@ object Minions {
|
||||
val chunkZ = chunk.z
|
||||
val world = chunk.world
|
||||
|
||||
lock.read {
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
return it.ticking
|
||||
}
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
return it.ticking
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
@ -50,8 +62,19 @@ object Minions {
|
||||
val chunkZ = chunk.z
|
||||
val world = chunk.world
|
||||
|
||||
run breaking@{
|
||||
lock.read {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
Scheduler.get().run { a ->
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
it.setTicking(false)
|
||||
return@breaking
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
if (world.uid == it.worldUUID && it.x == chunkX && it.z == chunkZ) {
|
||||
it.setTicking(false)
|
||||
@ -68,7 +91,7 @@ object Minions {
|
||||
val world = minion.getLocation().world ?: return
|
||||
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
lock.write {
|
||||
Scheduler.get().run { a ->
|
||||
var pos: ChunkPos? = null
|
||||
run breaking@{
|
||||
minions.forEach {
|
||||
@ -112,7 +135,7 @@ object Minions {
|
||||
val world = minion.getLocation().world ?: return
|
||||
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
lock.write {
|
||||
Scheduler.get().run { a ->
|
||||
val iterator = minions.iterator()
|
||||
while (iterator.hasNext()) {
|
||||
val next = iterator.next()
|
||||
|
@ -71,7 +71,7 @@ class LumberMinionType : MinionType("lumber", AxMinionsPlugin.INSTANCE.getResour
|
||||
val down = it.getRelative(BlockFace.DOWN).type
|
||||
loot.addAll(it.getDrops(minion.getTool()))
|
||||
|
||||
if (down == Material.DIRT || down == Material.GRASS_BLOCK || down == Material.COARSE_DIRT || down == Material.ROOTED_DIRT || down == Material.DIRT_PATH || down == Material.MUD || down == Material.MUDDY_MANGROVE_ROOTS) {
|
||||
if (down == Material.DIRT || down == Material.GRASS_BLOCK || down == Material.COARSE_DIRT || down == Material.ROOTED_DIRT || down == Material.DIRT_PATH || down == Material.MUD || down == Material.MUDDY_MANGROVE_ROOTS || down == Material.PODZOL) {
|
||||
it.type = getSaplingType(it.type)
|
||||
} else {
|
||||
it.type = Material.AIR
|
||||
|
Loading…
Reference in New Issue
Block a user