mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-30 20:39:10 +00:00
修复刷怪上限
This commit is contained in:
@@ -211,8 +211,8 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay display) {
|
||||
handleBaseEntityLoadEarly(display);
|
||||
} else if (entity instanceof Shulker shulker) {
|
||||
handleCollisionEntityLoadOnEntitiesLoad(shulker);
|
||||
} else if (entity instanceof Interaction interaction) {
|
||||
handleCollisionEntityLoadOnEntitiesLoad(interaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -310,29 +310,29 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
this.plugin.scheduler().sync().runLater(() -> handleBaseEntityLoadLate(display, depth + 1), 1, location.getWorld(), location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
protected void handleCollisionEntityLoadLate(Shulker shulker, int depth) {
|
||||
// remove the shulker if it's not a collision entity, it might be wrongly copied by WorldEdit
|
||||
if (FastNMS.INSTANCE.method$CraftEntity$getHandle(shulker) instanceof CollisionEntity) {
|
||||
protected void handleCollisionEntityLoadLate(Interaction interaction, int depth) {
|
||||
// remove the interaction if it's not a collision entity, it might be wrongly copied by WorldEdit
|
||||
if (FastNMS.INSTANCE.method$CraftEntity$getHandle(interaction) instanceof CollisionEntity) {
|
||||
return;
|
||||
}
|
||||
// not a collision entity
|
||||
Byte flag = shulker.getPersistentDataContainer().get(FURNITURE_COLLISION, PersistentDataType.BYTE);
|
||||
Byte flag = interaction.getPersistentDataContainer().get(FURNITURE_COLLISION, PersistentDataType.BYTE);
|
||||
if (flag == null || flag != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = shulker.getLocation();
|
||||
Location location = interaction.getLocation();
|
||||
World world = location.getWorld();
|
||||
int chunkX = location.getBlockX() >> 4;
|
||||
int chunkZ = location.getBlockZ() >> 4;
|
||||
if (!FastNMS.INSTANCE.isPreventingStatusUpdates(world, chunkX, chunkZ)) {
|
||||
shulker.remove();
|
||||
interaction.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (depth > 2) return;
|
||||
plugin.scheduler().sync().runLater(() -> {
|
||||
handleCollisionEntityLoadLate(shulker, depth + 1);
|
||||
handleCollisionEntityLoadLate(interaction, depth + 1);
|
||||
}, 1, world, chunkX, chunkZ);
|
||||
}
|
||||
|
||||
@@ -364,20 +364,20 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCollisionEntityLoadOnEntitiesLoad(Shulker shulker) {
|
||||
public void handleCollisionEntityLoadOnEntitiesLoad(Interaction interaction) {
|
||||
// faster
|
||||
if (FastNMS.INSTANCE.method$CraftEntity$getHandle(shulker) instanceof CollisionEntity) {
|
||||
shulker.remove();
|
||||
if (FastNMS.INSTANCE.method$CraftEntity$getHandle(interaction) instanceof CollisionEntity) {
|
||||
interaction.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// not a collision entity
|
||||
Byte flag = shulker.getPersistentDataContainer().get(FURNITURE_COLLISION, PersistentDataType.BYTE);
|
||||
Byte flag = interaction.getPersistentDataContainer().get(FURNITURE_COLLISION, PersistentDataType.BYTE);
|
||||
if (flag == null || flag != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
shulker.remove();
|
||||
interaction.remove();
|
||||
}
|
||||
|
||||
private AnchorType getAnchorType(Entity baseEntity, CustomFurniture furniture) {
|
||||
|
||||
@@ -33,8 +33,8 @@ public class FurnitureEventListener implements Listener {
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay itemDisplay) {
|
||||
this.manager.handleBaseEntityLoadEarly(itemDisplay);
|
||||
} else if (entity instanceof Shulker shulker) {
|
||||
this.manager.handleCollisionEntityLoadOnEntitiesLoad(shulker);
|
||||
} else if (entity instanceof Interaction interaction) {
|
||||
this.manager.handleCollisionEntityLoadOnEntitiesLoad(interaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,8 @@ public class FurnitureEventListener implements Listener {
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay itemDisplay) {
|
||||
this.manager.handleBaseEntityLoadEarly(itemDisplay);
|
||||
} else if (entity instanceof Shulker shulker) {
|
||||
this.manager.handleCollisionEntityLoadOnEntitiesLoad(shulker);
|
||||
} else if (entity instanceof Interaction interaction) {
|
||||
this.manager.handleCollisionEntityLoadOnEntitiesLoad(interaction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,8 @@ public class FurnitureEventListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof ItemDisplay itemDisplay) {
|
||||
this.manager.handleBaseEntityLoadLate(itemDisplay, 0);
|
||||
} else if (entity instanceof Shulker shulker) {
|
||||
this.manager.handleCollisionEntityLoadLate(shulker, 0);
|
||||
} else if (entity instanceof Interaction interaction) {
|
||||
this.manager.handleCollisionEntityLoadLate(interaction, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class FurnitureEventListener implements Listener {
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay) {
|
||||
this.manager.handleBaseEntityUnload(entity);
|
||||
} else if (entity instanceof Shulker) {
|
||||
} else if (entity instanceof Interaction) {
|
||||
this.manager.handleCollisionEntityUnload(entity);
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class FurnitureEventListener implements Listener {
|
||||
for (Entity entity : entities) {
|
||||
if (entity instanceof ItemDisplay) {
|
||||
this.manager.handleBaseEntityUnload(entity);
|
||||
} else if (entity instanceof Shulker) {
|
||||
} else if (entity instanceof Interaction) {
|
||||
this.manager.handleCollisionEntityUnload(entity);
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class FurnitureEventListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof ItemDisplay) {
|
||||
this.manager.handleBaseEntityUnload(entity);
|
||||
} else if (entity instanceof Shulker) {
|
||||
} else if (entity instanceof Interaction) {
|
||||
this.manager.handleCollisionEntityUnload(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class InteractionHitBox extends AbstractHitBox {
|
||||
AABB ceAABB = AABB.fromInteraction(new Vec3d(x + offset.x, y + offset.y, z - offset.z), this.size.x, this.size.y);
|
||||
Object nmsAABB = FastNMS.INSTANCE.constructor$AABB(ceAABB.minX, ceAABB.minY, ceAABB.minZ, ceAABB.maxX, ceAABB.maxY, ceAABB.maxZ);
|
||||
collider.accept(new BukkitCollider(
|
||||
FastNMS.INSTANCE.createCollisionShulker(world.serverWorld(), nmsAABB, x, y, z, this.canBeHitByProjectile(), false, this.blocksBuilding()),
|
||||
FastNMS.INSTANCE.createCollisionInteraction(world.serverWorld(), nmsAABB, x, y, z, this.canBeHitByProjectile(), false, this.blocksBuilding()),
|
||||
ColliderType.SHULKER
|
||||
));
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ShulkerHitBox extends AbstractHitBox {
|
||||
Object nmsAABB = FastNMS.INSTANCE.constructor$AABB(ceAABB.minX, ceAABB.minY, ceAABB.minZ, ceAABB.maxX, ceAABB.maxY, ceAABB.maxZ);
|
||||
aabb.accept(entityId, ceAABB);
|
||||
return new BukkitCollider(
|
||||
FastNMS.INSTANCE.createCollisionShulker(level, nmsAABB, x, y, z, this.canBeHitByProjectile(), true, this.blocksBuilding()),
|
||||
FastNMS.INSTANCE.createCollisionInteraction(level, nmsAABB, x, y, z, this.canBeHitByProjectile(), true, this.blocksBuilding()),
|
||||
ColliderType.SHULKER
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1516,7 +1516,7 @@ public class PacketConsumers {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (entityType == Reflections.instance$EntityType$SHULKER) {
|
||||
} else if (entityType == Reflections.instance$EntityType$INTERACTION) {
|
||||
// Cancel collider entity packet
|
||||
int entityId = FastNMS.INSTANCE.field$ClientboundAddEntityPacket$entityId(packet);
|
||||
LoadedFurniture furniture = BukkitFurnitureManager.instance().loadedFurnitureByRealEntityId(entityId);
|
||||
|
||||
Reference in New Issue
Block a user