Fix re-render boundary checks

This commit is contained in:
Gabriel Tofvesson 2021-07-07 20:55:34 +02:00
parent 97e17cba3f
commit 5701a20cc8
2 changed files with 13 additions and 9 deletions

View File

@ -1,6 +1,7 @@
package dev.w1zzrd.invtweaks.feature; package dev.w1zzrd.invtweaks.feature;
import dev.w1zzrd.invtweaks.serialization.ChestNameConfig; import dev.w1zzrd.invtweaks.serialization.ChestNameConfig;
import dev.w1zzrd.spigot.wizcompat.packet.EntityCreator;
import dev.w1zzrd.spigot.wizcompat.serialization.PersistentData; import dev.w1zzrd.spigot.wizcompat.serialization.PersistentData;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -123,12 +124,13 @@ public final class NamedChestManager {
if (chunk == null) if (chunk == null)
return; return;
chunk.streamEntries().forEach(entry -> { sendEntityDespawnPackets(
final Object entity = entry.getEntity(() -> null); target,
chunk.streamEntries()
if (entity != null) .map(entry -> entry.getEntity(() -> null))
sendEntityDespawnPacket(target, getEntityID(entity)); .filter(Objects::nonNull)
}); .mapToInt(EntityCreator::getEntityID).toArray()
);
}); });
} }
@ -268,7 +270,7 @@ public final class NamedChestManager {
.filter(chunk -> { .filter(chunk -> {
final ChestNameConfig.ChestNameWorldEntry.ChestNameChunkEntry chestChunk = config.getChunkEntry(worldID, chunk.getRender().x(), chunk.getRender().z()); 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().x() < xMin ||
chunk.getRender().z() > zMax || chunk.getRender().z() > zMax ||
chunk.getRender().z() < zMin || chunk.getRender().z() < zMin ||

View File

@ -12,8 +12,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.*; import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static dev.w1zzrd.spigot.wizcompat.command.CommandUtils.errorMessage; import static dev.w1zzrd.spigot.wizcompat.command.CommandUtils.errorMessage;
import static org.bukkit.Material.*; import static org.bukkit.Material.*;