use of org.spongepowered.common.bridge.entitycollision.CollisionCapabilityBridge in project SpongeCommon by SpongePowered.
the class LevelChunkMixin_EntityCollision method entityCollision$allowEntityCollision.
private <T extends Entity> boolean entityCollision$allowEntityCollision(final List<T> entities) {
if (((LevelBridge) this.shadow$getLevel()).bridge$isFake()) {
return true;
}
final PhaseContext<@NonNull ?> phaseContext = PhaseTracker.getInstance().getPhaseContext();
if (!phaseContext.allowsEntityCollisionEvents()) {
// allow explosions
return true;
}
final Object source = phaseContext.getSource();
if (source == null) {
return true;
}
CollisionCapabilityBridge collisionBridge = null;
if (source instanceof LocatableBlock) {
final LocatableBlock locatable = (LocatableBlock) source;
final BlockType blockType = locatable.location().block().type();
collisionBridge = (CollisionCapabilityBridge) blockType;
} else if (source instanceof CollisionCapabilityBridge) {
collisionBridge = (CollisionCapabilityBridge) source;
}
if (collisionBridge == null) {
return true;
}
if (collisionBridge.collision$requiresCollisionsCacheRefresh()) {
collisionBridge.collision$initializeCollisionState(this.shadow$getLevel());
collisionBridge.collision$requiresCollisionsCacheRefresh(false);
}
return !((collisionBridge.collision$getMaxCollisions() >= 0) && (entities.size() >= collisionBridge.collision$getMaxCollisions()));
}
Aggregations