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 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 NewHorizonsCoreMod by GTNewHorizons.
the class CustomDropsHandler method onMobDrops.
@SubscribeEvent
public void onMobDrops(LivingDropsEvent pEvent) {
try {
EntityLivingBase tEntity = pEvent.entityLiving;
UUID tUUID = null;
EntityPlayer tEP = null;
if (pEvent.source.getEntity() != null) {
if (pEvent.source.getEntity() instanceof EntityPlayer) {
tEP = (EntityPlayer) pEvent.source.getEntity();
tUUID = tEP.getUniqueID();
if (_mDeathDebugPlayers.contains(tUUID))
PlayerChatHelper.SendInfo(tEP, String.format("Killed entity: [%s]", tEntity.getClass().getName()));
}
}
if (// Not doing anything, only players are valid
tEP == null)
return;
if (// Nope,
tEP instanceof net.minecraftforge.common.util.FakePlayer)
// fakeplayers
return;
CustomDrop tCustomDrop = _mCustomDrops.FindDropEntry(tEntity);
// no custom drop defined for this
if (tCustomDrop == null)
return;
// mob, skipping
HandleCustomDrops(tCustomDrop, tEntity, tEP, pEvent.drops);
} catch (Exception e) {
e.printStackTrace();
}
}
use of net.minecraft.entity.EntityLivingBase in project VanillaTeleporter by dyeo.
the class BlockTeleporter method onEntityWalk.
@Override
public void onEntityWalk(World world, BlockPos pos, Entity entity) {
TeleporterNode destinationNode = null;
IBlockState state = world.getBlockState(pos);
EnumType type = EnumType.byMetadata(getMetaFromState(state));
if (entity instanceof EntityLivingBase && entity.hasCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null)) {
ITeleportHandler teleportHandler = entity.getCapability(CapabilityTeleportHandler.TELEPORT_CAPABILITY, null);
if (!world.isRemote) {
if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
teleportHandler.setOnTeleporter(entity.getPosition().distanceSq(pos) <= 1);
teleportHandler.setDimension(entity.dimension);
if (teleportHandler.getOnTeleporter()) {
boolean isHostile = (entity instanceof EntityMob) || (entity instanceof EntityWolf && ((EntityWolf) entity).isAngry());
boolean isPassive = (entity instanceof EntityAnimal);
if ((isHostile == false || isHostile == ModConfiguration.teleportHostileMobs) && (isPassive == false || isPassive == ModConfiguration.teleportPassiveMobs)) {
destinationNode = TeleporterUtility.teleport((EntityLivingBase) entity, pos);
}
}
}
}
if (teleportHandler.getTeleportStatus() == EnumTeleportStatus.INACTIVE) {
TileEntityTeleporter tEnt = (TileEntityTeleporter) world.getTileEntity(pos);
if (tEnt != null) {
tEnt.spawnParticles();
}
}
if (type.isRecall() && entity instanceof EntityPlayerMP && destinationNode != null) {
WorldServer nextWorld = world.getMinecraftServer().worldServerForDimension(destinationNode.dimension);
breakBlockRecall(world, nextWorld, pos, destinationNode.pos, state, (EntityPlayerMP) entity);
}
}
}
use of net.minecraft.entity.EntityLivingBase in project BetterWithAddons by DaedalusGame.
the class EntityKarateZombie method attackEntityFrom.
@Override
public boolean attackEntityFrom(DamageSource source, float amount) {
EntityLivingBase entity = this.getAttackTarget();
boolean success = super.attackEntityFrom(source, amount);
if (success && getCurrentMove() == MartialArts.Disarm && !this.isDead) {
if (entity == source.getImmediateSource() && entity != null) {
disarm(entity);
}
randomizeMove();
}
return success;
}
Aggregations