use of org.spongepowered.common.mixin.plugin.entitycollisions.interfaces.IModData_Collisions in project SpongeCommon by SpongePowered.
the class MixinChunk_Collisions method allowEntityCollision.
private <T extends Entity> boolean allowEntityCollision(List<T> listToFill) {
if (this.world instanceof IMixinWorldServer) {
IMixinWorldServer spongeWorld = (IMixinWorldServer) this.world;
if (spongeWorld.isProcessingExplosion()) {
// allow explosions
return true;
}
final PhaseContext<?> phaseContext = PhaseTracker.getInstance().getCurrentContext();
LocatableBlock locatable = phaseContext.getSource(LocatableBlock.class).orElse(null);
if (locatable != null) {
BlockType blockType = locatable.getLocation().getBlockType();
IModData_Collisions spongeBlock = (IModData_Collisions) blockType;
if (spongeBlock.requiresCollisionsCacheRefresh()) {
spongeBlock.initializeCollisionState(this.world);
spongeBlock.requiresCollisionsCacheRefresh(false);
}
return !((spongeBlock.getMaxCollisions() >= 0) && (listToFill.size() >= spongeBlock.getMaxCollisions()));
}
IModData_Collisions spongeEntity = phaseContext.getSource(IModData_Collisions.class).orElse(null);
if (spongeEntity != null) {
if (spongeEntity.requiresCollisionsCacheRefresh()) {
spongeEntity.initializeCollisionState(this.world);
spongeEntity.requiresCollisionsCacheRefresh(false);
}
return !((spongeEntity.getMaxCollisions() >= 0) && (listToFill.size() >= spongeEntity.getMaxCollisions()));
}
return true;
}
return true;
}
Aggregations