mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
fix(bukkit): 修复硬碰撞箱发包过多的问题
This commit is contained in:
@@ -249,7 +249,7 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
return this.furnitureByEntityId.get(entityId);
|
||||
}
|
||||
|
||||
protected void handleBaseFurnitureUnload(Entity entity) {
|
||||
protected void handleBaseFurnitureUnload(Entity entity, boolean unloadColliders) {
|
||||
int id = entity.getEntityId();
|
||||
LoadedFurniture furniture = this.furnitureByRealEntityId.remove(id);
|
||||
if (furniture != null) {
|
||||
@@ -262,7 +262,9 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
this.furnitureByEntityId.remove(sub);
|
||||
}
|
||||
for (CollisionEntity collision : furniture.collisionEntities()) {
|
||||
this.furnitureByRealEntityId.remove(FastNMS.INSTANCE.method$Entity$getId(collision));
|
||||
if (unloadColliders) {
|
||||
this.furnitureByRealEntityId.remove(FastNMS.INSTANCE.method$Entity$getId(collision));
|
||||
}
|
||||
if (!isPreventing) collision.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class FurnitureEventListener implements Listener {
|
||||
Entity[] entities = event.getChunk().getEntities();
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay) {
|
||||
this.manager.handleBaseFurnitureUnload(entity);
|
||||
this.manager.handleBaseFurnitureUnload(entity, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class FurnitureEventListener implements Listener {
|
||||
List<Entity> entities = event.getWorld().getEntities();
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay) {
|
||||
this.manager.handleBaseFurnitureUnload(entity);
|
||||
this.manager.handleBaseFurnitureUnload(entity, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class FurnitureEventListener implements Listener {
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onEntityUnload(EntityRemoveFromWorldEvent event) {
|
||||
if (event.getEntity() instanceof ItemDisplay itemDisplay) {
|
||||
this.manager.handleBaseFurnitureUnload(itemDisplay);
|
||||
this.manager.handleBaseFurnitureUnload(itemDisplay, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user