use of net.minecraft.world.entity.boss.enderdragon.EnderDragon in project SpongeCommon by SpongePowered.
the class LivingEntityMixin_EntityCollision method collisions$pushEntities.
// This injection allows maxEntityCramming to be applied first before checking for max collisions
@Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I", remap = false))
private int collisions$pushEntities(final List<Entity> list) {
for (final Entity entity : list) {
// ignore players and entities with parts (ex. EnderDragon)
if (this.shadow$getCommandSenderWorld().isClientSide() || entity == null || entity instanceof Player || entity instanceof EnderDragon) {
continue;
}
if (this.collision$requiresCollisionsCacheRefresh()) {
this.collision$initializeCollisionState(this.shadow$getCommandSenderWorld());
this.collision$requiresCollisionsCacheRefresh(false);
}
if (this.collision$getMaxCollisions() >= 0 && list.size() >= this.collision$getMaxCollisions()) {
// Don't process any more collisions
break;
}
this.shadow$doPush(entity);
}
// We always return '0' to prevent the original loop from running.
return 0;
}
use of net.minecraft.world.entity.boss.enderdragon.EnderDragon in project SpongeCommon by SpongePowered.
the class EntityActivationRange method initializeEntityActivationState.
/**
* Initialize entity activation state.
*
* @param entity Entity to check
*/
public static void initializeEntityActivationState(final Entity entity) {
final ActivationCapabilityBridge spongeEntity = (ActivationCapabilityBridge) entity;
if (entity.level.isClientSide()) {
return;
}
// types that should always be active
if (entity instanceof Player && !((PlatformEntityBridge) entity).bridge$isFakePlayer() || entity instanceof ThrowableProjectile || entity instanceof EnderDragon || entity instanceof EnderDragonPart || entity instanceof WitherBoss || entity instanceof AbstractHurtingProjectile || entity instanceof LightningBolt || entity instanceof PrimedTnt || entity instanceof Painting || entity instanceof EndCrystal || entity instanceof FireworkRocketEntity || // Always tick falling blocks
entity instanceof FallingBlockEntity) {
return;
}
final InheritableConfigHandle<WorldConfig> configAdapter = SpongeGameConfigs.getForWorld(entity.level);
final EntityActivationRangeCategory config = configAdapter.get().entityActivationRange;
final EntityTypeBridge type = (EntityTypeBridge) entity.getType();
final ResourceLocation key = EntityType.getKey(entity.getType());
final byte activationType = spongeEntity.activation$getActivationType();
final String activationTypeName = EntityActivationRange.activationTypeMappings.getOrDefault(activationType, "misc");
if (!type.bridge$isActivationRangeInitialized()) {
EntityActivationRange.addEntityToConfig(config.autoPopulate, key, activationType, activationTypeName);
type.bridge$setActivationRangeInitialized(true);
}
final EntityActivationRangeCategory.ModSubCategory entityMod = config.mods.get(key.getNamespace());
final int defaultActivationRange = config.globalRanges.get(activationTypeName);
if (entityMod == null) {
// use default activation range
spongeEntity.activation$setActivationRange(defaultActivationRange);
if (defaultActivationRange > 0) {
spongeEntity.activation$setDefaultActivationState(false);
}
} else {
if (!entityMod.enabled) {
spongeEntity.activation$setDefaultActivationState(true);
return;
}
final Integer defaultModActivationRange = entityMod.defaultRanges.get(activationTypeName);
final Integer entityActivationRange = entityMod.entities.get(key.getPath());
if (defaultModActivationRange != null && entityActivationRange == null) {
spongeEntity.activation$setActivationRange(defaultModActivationRange);
if (defaultModActivationRange > 0) {
spongeEntity.activation$setDefaultActivationState(false);
}
} else if (entityActivationRange != null) {
spongeEntity.activation$setActivationRange(entityActivationRange);
if (entityActivationRange > 0) {
spongeEntity.activation$setDefaultActivationState(false);
}
}
}
}
Aggregations