From 5701a20cc83f43e4a7ed84858e57aaaf073c6e60 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Wed, 7 Jul 2021 20:55:34 +0200 Subject: [PATCH] Fix re-render boundary checks --- .../invtweaks/feature/NamedChestManager.java | 16 +++++++++------- .../listener/TreeCapitatorListener.java | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/dev/w1zzrd/invtweaks/feature/NamedChestManager.java b/src/dev/w1zzrd/invtweaks/feature/NamedChestManager.java index aac82e9..b949cd5 100644 --- a/src/dev/w1zzrd/invtweaks/feature/NamedChestManager.java +++ b/src/dev/w1zzrd/invtweaks/feature/NamedChestManager.java @@ -1,6 +1,7 @@ package dev.w1zzrd.invtweaks.feature; import dev.w1zzrd.invtweaks.serialization.ChestNameConfig; +import dev.w1zzrd.spigot.wizcompat.packet.EntityCreator; import dev.w1zzrd.spigot.wizcompat.serialization.PersistentData; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -123,12 +124,13 @@ public final class NamedChestManager { if (chunk == null) return; - chunk.streamEntries().forEach(entry -> { - final Object entity = entry.getEntity(() -> null); - - if (entity != null) - sendEntityDespawnPacket(target, getEntityID(entity)); - }); + sendEntityDespawnPackets( + target, + chunk.streamEntries() + .map(entry -> entry.getEntity(() -> null)) + .filter(Objects::nonNull) + .mapToInt(EntityCreator::getEntityID).toArray() + ); }); } @@ -268,7 +270,7 @@ public final class NamedChestManager { .filter(chunk -> { final ChestNameConfig.ChestNameWorldEntry.ChestNameChunkEntry chestChunk = config.getChunkEntry(worldID, chunk.getRender().x(), chunk.getRender().z()); - return chunk.getRender().x() < xMax || + return chunk.getRender().x() > xMax || chunk.getRender().x() < xMin || chunk.getRender().z() > zMax || chunk.getRender().z() < zMin || diff --git a/src/dev/w1zzrd/invtweaks/listener/TreeCapitatorListener.java b/src/dev/w1zzrd/invtweaks/listener/TreeCapitatorListener.java index c53bb7a..2d2d27f 100644 --- a/src/dev/w1zzrd/invtweaks/listener/TreeCapitatorListener.java +++ b/src/dev/w1zzrd/invtweaks/listener/TreeCapitatorListener.java @@ -12,8 +12,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; - -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import static dev.w1zzrd.spigot.wizcompat.command.CommandUtils.errorMessage; import static org.bukkit.Material.*;