Try fixing looting

This commit is contained in:
TomTom 2024-03-07 16:35:31 +01:00
parent e5e9a4fb91
commit 9534c5f960
4 changed files with 13 additions and 7 deletions

View File

@ -7,6 +7,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.read
import kotlin.concurrent.write
import org.bukkit.Chunk
import org.bukkit.Location
object Minions {
internal val lock = ReentrantReadWriteLock()

View File

@ -11,6 +11,7 @@ import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.MobType
import net.minecraft.world.entity.animal.Fox
import net.minecraft.world.entity.decoration.ArmorStand
import net.minecraft.world.item.AxeItem
import net.minecraft.world.item.ItemStack
@ -28,13 +29,13 @@ import org.bukkit.entity.Player
import org.bukkit.event.entity.EntityPotionEffectEvent
object DamageHandler {
private var DUMMY_ENTITY: LivingEntity? = null
private var DUMMY_ENTITY: Fox? = null
fun damage(source: Minion, entity: Entity) {
val nmsEntity = (entity as CraftEntity).handle
if (DUMMY_ENTITY === null) {
DUMMY_ENTITY =
ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, nmsEntity.level() as ServerLevel)
Fox(net.minecraft.world.entity.EntityType.FOX, nmsEntity.level() as ServerLevel)
}
synchronized(DUMMY_ENTITY!!) {
@ -132,7 +133,8 @@ object DamageHandler {
val f4 =
1.0f + if (sweep > 0) SweepingEdgeEnchantment.getSweepingDamageRatio(sweep) else 0.0f * f
val list: List<LivingEntity> = (source.getLocation().world as CraftWorld).handle
.getEntitiesOfClass(LivingEntity::class.java, nmsEntity.boundingBox.inflate(1.0, 0.25, 1.0)).filter { it !is Player }
.getEntitiesOfClass(LivingEntity::class.java, nmsEntity.boundingBox.inflate(1.0, 0.25, 1.0))
.filter { it !is Player }
val iterator: Iterator<*> = list.iterator()
while (iterator.hasNext()) {

View File

@ -11,6 +11,7 @@ import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.MobType
import net.minecraft.world.entity.animal.Fox
import net.minecraft.world.entity.decoration.ArmorStand
import net.minecraft.world.item.AxeItem
import net.minecraft.world.item.ItemStack
@ -28,13 +29,13 @@ import org.bukkit.entity.Player
import org.bukkit.event.entity.EntityPotionEffectEvent
object DamageHandler {
private var DUMMY_ENTITY: LivingEntity? = null
private var DUMMY_ENTITY: Fox? = null
fun damage(source: Minion, entity: Entity) {
val nmsEntity = (entity as CraftEntity).handle
if (DUMMY_ENTITY === null) {
DUMMY_ENTITY =
ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, nmsEntity.level() as ServerLevel)
Fox(net.minecraft.world.entity.EntityType.FOX, nmsEntity.level() as ServerLevel)
}
synchronized(DUMMY_ENTITY!!) {

View File

@ -8,9 +8,11 @@ import net.minecraft.server.level.ServerLevel
import net.minecraft.util.Mth
import net.minecraft.world.effect.MobEffectInstance
import net.minecraft.world.effect.MobEffects
import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.MobType
import net.minecraft.world.entity.animal.Fox
import net.minecraft.world.entity.decoration.ArmorStand
import net.minecraft.world.item.AxeItem
import net.minecraft.world.item.ItemStack
@ -28,13 +30,13 @@ import org.bukkit.entity.Player
import org.bukkit.event.entity.EntityPotionEffectEvent
object DamageHandler {
private var DUMMY_ENTITY: LivingEntity? = null
private var DUMMY_ENTITY: Fox? = null
fun damage(source: Minion, entity: Entity) {
val nmsEntity = (entity as CraftEntity).handle
if (DUMMY_ENTITY === null) {
DUMMY_ENTITY =
ArmorStand(net.minecraft.world.entity.EntityType.ARMOR_STAND, nmsEntity.level() as ServerLevel)
Fox(EntityType.FOX, nmsEntity.level() as ServerLevel)
}
synchronized(DUMMY_ENTITY!!) {