use of net.minecraft.entity.passive.IAnimals in project RFTools by McJty.
the class TickShieldBlockTileEntity method handleDamage.
private void handleDamage() {
damageTimer--;
if (damageTimer > 0) {
return;
}
damageTimer = 10;
if (beamBox == null) {
int xCoord = getPos().getX();
int yCoord = getPos().getY();
int zCoord = getPos().getZ();
beamBox = new AxisAlignedBB(xCoord - .4, yCoord - .4, zCoord - .4, xCoord + 1.4, yCoord + 2.0, zCoord + 1.4);
}
if (shieldBlock != null) {
ShieldTEBase shieldTileEntity = (ShieldTEBase) getWorld().getTileEntity(shieldBlock);
if (shieldTileEntity != null) {
List<Entity> l = getWorld().getEntitiesWithinAABB(Entity.class, beamBox);
for (Entity entity : l) {
if ((damageBits & AbstractShieldBlock.META_HOSTILE) != 0 && entity instanceof IMob) {
if (checkEntityDamage(shieldTileEntity, HostileFilter.HOSTILE)) {
shieldTileEntity.applyDamageToEntity(entity);
}
} else if ((damageBits & AbstractShieldBlock.META_PASSIVE) != 0 && entity instanceof IAnimals) {
if (checkEntityDamage(shieldTileEntity, AnimalFilter.ANIMAL)) {
shieldTileEntity.applyDamageToEntity(entity);
}
} else if ((damageBits & AbstractShieldBlock.META_PLAYERS) != 0 && entity instanceof EntityPlayer) {
if (checkPlayerDamage(shieldTileEntity, (EntityPlayer) entity)) {
shieldTileEntity.applyDamageToEntity(entity);
}
}
}
}
}
}
use of net.minecraft.entity.passive.IAnimals in project RFTools by McJty.
the class SensorTileEntity method checkEntitiesPassive.
private boolean checkEntitiesPassive(BlockPos pos1, EnumFacing dir) {
List<Entity> entities = getWorld().getEntitiesWithinAABB(EntityCreature.class, getCachedBox(pos1, dir));
int cnt = 0;
for (Entity entity : entities) {
if (entity instanceof IAnimals && !(entity instanceof IMob)) {
cnt++;
if (cnt >= number) {
return true;
}
}
}
return false;
}
use of net.minecraft.entity.passive.IAnimals in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onEntityJoinWorldEvent.
@SubscribeEvent
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
World world = event.getWorld();
if (world.isRemote) {
return;
}
WorldProvider provider = world.provider;
if (!(provider instanceof GenericWorldProvider))
return;
DimensionInformation dimensionInformation = ((GenericWorldProvider) provider).getDimensionInformation();
if (dimensionInformation.isNoanimals() && event.getEntity() instanceof IAnimals && !(event.getEntity() instanceof IMob)) {
event.setCanceled(true);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.getEntity().getClass().getName());
}
}
use of net.minecraft.entity.passive.IAnimals in project RFToolsDimensions by McJty.
the class ForgeEventHandlers method onEntitySpawnEvent.
@SubscribeEvent
public void onEntitySpawnEvent(LivingSpawnEvent.CheckSpawn event) {
World world = event.getWorld();
WorldProvider provider = world.provider;
if (!(provider instanceof GenericWorldProvider))
return;
DimensionInformation dimensionInformation = ((GenericWorldProvider) provider).getDimensionInformation();
if (PowerConfiguration.preventSpawnUnpowered) {
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
if (storage.getEnergyLevel(provider.getDimension()) <= 0) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Dimension power low: Prevented a spawn of " + event.getEntity().getClass().getName());
}
}
if (dimensionInformation.hasEffectType(EffectType.EFFECT_STRONGMOBS) || dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS)) {
if (event.getEntity() instanceof EntityLivingBase) {
EntityLivingBase entityLivingBase = (EntityLivingBase) event.getEntity();
IAttributeInstance entityAttribute = entityLivingBase.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH);
double newMax = entityAttribute.getBaseValue() * (dimensionInformation.hasEffectType(EffectType.EFFECT_BRUTALMOBS) ? GeneralConfiguration.brutalMobsFactor : GeneralConfiguration.strongMobsFactor);
entityAttribute.setBaseValue(newMax);
entityLivingBase.setHealth((float) newMax);
}
}
if (event.getEntity() instanceof IMob) {
/* BlockPos coordinate = new BlockPos((int) event.getEntity().posX, (int) event.getEntity().posY, (int) event.getEntity().posZ);
if (PeacefulAreaManager.isPeaceful(new GlobalCoordinate(coordinate, id))) {
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful manager: Prevented a spawn of " + event.entity.getClass().getName());
} else */
if (dimensionInformation.isPeaceful()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Peaceful dimension: Prevented a spawn of " + event.getEntity().getClass().getName());
}
} else if (event.getEntity() instanceof IAnimals && dimensionInformation.isNoanimals()) {
// RFTools dimension.
event.setResult(Event.Result.DENY);
Logging.logDebug("Noanimals dimension: Prevented a spawn of " + event.getEntity().getClass().getName());
}
// @todo
}
Aggregations