use of net.minecraft.entity.effect.EntityWeatherEffect in project SpongeCommon by SpongePowered.
the class EntityActivationRange method initializeEntityActivationState.
/**
* These entities are excluded from Activation range checks.
*
* @param entity Entity to check
* @return boolean If it should always tick.
*/
public static boolean initializeEntityActivationState(Entity entity) {
if (((IMixinWorld) entity.world).isFake()) {
return true;
}
// types that should always be active
if (entity instanceof EntityPlayer && !SpongeImplHooks.isFakePlayer(entity) || entity instanceof EntityThrowable || entity instanceof EntityDragon || entity instanceof MultiPartEntityPart || entity instanceof EntityWither || entity instanceof EntityFireball || entity instanceof EntityWeatherEffect || entity instanceof EntityTNTPrimed || entity instanceof EntityEnderCrystal || entity instanceof EntityFireworkRocket || // Always tick falling blocks
entity instanceof EntityFallingBlock) {
return true;
}
EntityActivationRangeCategory config = ((IMixinWorldServer) entity.world).getActiveConfig().getConfig().getEntityActivationRange();
EntityType type = ((org.spongepowered.api.entity.Entity) entity).getType();
IModData_Activation spongeEntity = (IModData_Activation) entity;
if (type == EntityTypes.UNKNOWN || !(type instanceof SpongeEntityType)) {
return false;
}
final SpongeEntityType spongeType = (SpongeEntityType) type;
final byte activationType = spongeEntity.getActivationType();
if (!spongeType.isActivationRangeInitialized()) {
addEntityToConfig(entity.world, spongeType, activationType);
spongeType.setActivationRangeInitialized(true);
}
EntityActivationModCategory entityMod = config.getModList().get(spongeType.getModId().toLowerCase());
int defaultActivationRange = config.getDefaultRanges().get(activationTypeMappings.get(activationType));
if (entityMod == null) {
// use default activation range
spongeEntity.setActivationRange(defaultActivationRange);
if (defaultActivationRange <= 0) {
return true;
}
return false;
} else if (!entityMod.isEnabled()) {
spongeEntity.setActivationRange(defaultActivationRange);
return true;
}
Integer defaultModActivationRange = entityMod.getDefaultRanges().get(activationTypeMappings.get(activationType));
Integer entityActivationRange = entityMod.getEntityList().get(type.getName().toLowerCase());
if (defaultModActivationRange != null && entityActivationRange == null) {
spongeEntity.setActivationRange(defaultModActivationRange);
if (defaultModActivationRange <= 0) {
return true;
}
return false;
} else if (entityActivationRange != null) {
spongeEntity.setActivationRange(entityActivationRange);
if (entityActivationRange <= 0) {
return true;
}
}
return false;
}
Aggregations