use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.
the class ButcherHandler method playerTick.
@SubscribeEvent
public void playerTick(AttackEntityEvent attackEvent) {
Entity target = attackEvent.getTarget();
EntityLivingBase attacker = attackEvent.getEntityLiving();
if (attacker == null || target == null)
return;
World world = attacker.getEntityWorld();
BlockPos pos = EntityUtil.getEntityFloor(target, 2);
if (!world.isRemote) {
IBlockState state = world.getBlockState(pos);
if (isChopBlock(state) && isSuitableWeapon(attacker.getHeldItemMainhand())) {
attacker.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 200));
attacker.addPotionEffect(new PotionEffect(MobEffects.HUNGER, 200));
splatter(world, pos, 1);
}
}
}
use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.
the class TerratorialHandler method spawnLiving.
@SubscribeEvent
public void spawnLiving(LivingSpawnEvent.CheckSpawn spawnEvent) {
World world = spawnEvent.getWorld();
EntityLivingBase entity = spawnEvent.getEntityLiving();
Chunk chunk = world.getChunkFromBlockCoords(new BlockPos(spawnEvent.getX(), spawnEvent.getY(), spawnEvent.getZ()));
if (!chunk.isLoaded())
return;
if (entity instanceof EntityZombie || entity instanceof EntitySkeleton || entity instanceof EntityCreeper)
spawnEvent.setResult(Event.Result.DENY);
}
use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.
the class AssortedHandler method livingTick.
@SubscribeEvent
public void livingTick(LivingEvent.LivingUpdateEvent updateEvent) {
final EntityLivingBase entity = updateEvent.getEntityLiving();
World world = entity.getEntityWorld();
UUID uuid = entity.getUniqueID();
BlockPos pos = entity.getPosition();
if (!world.isRemote) {
if (entity.isPotionActive(ModPotions.boss)) {
if (!BossList.containsKey(uuid)) {
BossInfoServer displayData = (BossInfoServer) new BossInfoServer(entity.getDisplayName(), Color.PURPLE, Overlay.PROGRESS).setDarkenSky(false);
BossList.put(uuid, displayData);
List<EntityPlayerMP> entities = world.getEntitiesWithinAABB(EntityPlayerMP.class, new AxisAlignedBB(pos).expand(24, 24, 24));
if (entities != null)
for (EntityPlayerMP ply : entities) {
displayData.addPlayer(ply);
}
} else {
BossInfoServer bossInfo = BossList.get(uuid);
bossInfo.setPercent(entity.getHealth() / entity.getMaxHealth());
}
} else if (world.getMinecraftServer().getTickCounter() % BossCleanupThreshold == 0 && BossList.containsKey(uuid)) {
BossInfoServer bossInfo = BossList.get(uuid);
for (EntityPlayerMP ply : bossInfo.getPlayers()) {
bossInfo.removePlayer(ply);
}
BossList.remove(uuid);
}
}
}
use of net.minecraft.entity.EntityLivingBase in project Bookshelf by Darkhax-Minecraft.
the class ModelArmorExtended method syncModel.
/**
* Updates the pose/state of the model to reflect that of the entity it's attatched to.
*
* @param entity The entity to sync the model with.
* @param partialTicks The partial ticks.
*/
private void syncModel(Entity entity, float partialTicks) {
final EntityLivingBase living = (EntityLivingBase) entity;
this.isSneak = living != null ? living.isSneaking() : false;
this.isChild = living != null ? living.isChild() : false;
if (living != null && living instanceof EntityPlayer) {
final EntityPlayer player = (EntityPlayer) living;
final ArmPose poseMainhand = this.getArmPose(player.getHeldItemMainhand(), player);
final ArmPose poseOffhand = this.getArmPose(player.getHeldItemOffhand(), player);
final boolean isRightHanded = player.getPrimaryHand() == EnumHandSide.RIGHT;
this.rightArmPose = isRightHanded ? poseMainhand : poseOffhand;
this.leftArmPose = isRightHanded ? poseOffhand : poseMainhand;
this.swingProgress = player.getSwingProgress(partialTicks);
}
}
use of net.minecraft.entity.EntityLivingBase in project SecurityCraft by Geforce132.
the class TileEntityClaymore method updateEntity.
public void updateEntity() {
if (getWorldObj().isRemote) {
return;
} else {
if (getWorldObj().getBlock(xCoord, yCoord, zCoord) == mod_SecurityCraft.claymoreDefused) {
return;
}
if (cooldown > 0) {
cooldown--;
return;
}
if (cooldown == 0) {
BlockUtils.destroyBlock(getWorldObj(), xCoord, yCoord, zCoord, false);
getWorldObj().createExplosion((Entity) null, entityX, entityY + 0.5F, entityZ, 3.5F, true);
return;
}
int meta = getWorldObj().getBlockMetadata(xCoord, yCoord, zCoord);
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
if (meta == 3) {
axisalignedbb = axisalignedbb.addCoord(0, 0, -mod_SecurityCraft.configHandler.claymoreRange);
} else if (meta == 1) {
axisalignedbb = axisalignedbb.addCoord(0, 0, mod_SecurityCraft.configHandler.claymoreRange);
} else if (meta == 2) {
axisalignedbb = axisalignedbb.addCoord(mod_SecurityCraft.configHandler.claymoreRange, 0, 0);
} else if (meta == 4) {
axisalignedbb = axisalignedbb.addCoord(-mod_SecurityCraft.configHandler.claymoreRange, 0, 0);
}
List<?> list = getWorldObj().getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
Iterator<?> iterator = list.iterator();
EntityLivingBase entityliving;
while (iterator.hasNext()) {
entityliving = (EntityLivingBase) iterator.next();
entityX = entityliving.posX;
entityY = entityliving.posY;
entityZ = entityliving.posZ;
cooldown = 20;
getWorldObj().playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.click", 0.3F, 0.6F);
break;
}
}
}
Aggregations