use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.
the class GrindingDamage method getDeathMessage.
@Override
public String getDeathMessage(EntityLiving par1EntityLiving) {
EntityLiving entityliving1 = par1EntityLiving.func_94060_bK();
String s = "death.attack." + this.damageType;
if (_msgCount > 0) {
int msg = _rand.nextInt(_msgCount);
if (msg != 0) {
s += "." + msg;
}
}
String s1 = s + ".player";
return entityliving1 != null && StatCollector.func_94522_b(s1) ? StatCollector.translateToLocalFormatted(s1, new Object[] { par1EntityLiving.getTranslatedEntityName(), entityliving1.getTranslatedEntityName() }) : StatCollector.translateToLocalFormatted(s, new Object[] { par1EntityLiving.getTranslatedEntityName() });
}
use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.
the class ItemSafariNet method releaseEntity.
public static Entity releaseEntity(ItemStack itemstack, World world, int x, int y, int z, int side) {
if (world.isRemote) {
return null;
}
Entity spawnedCreature;
int blockId = world.getBlockId(x, y, z);
x += Facing.offsetsXForSide[side];
y += Facing.offsetsYForSide[side];
z += Facing.offsetsZForSide[side];
double spawnOffsetY = 0.0D;
if (side == 1 && Block.blocksList[blockId] != null && Block.blocksList[blockId].getRenderType() == 11) {
spawnOffsetY = 0.5D;
}
if (itemstack.getItemDamage() != 0) {
spawnedCreature = spawnCreature(world, itemstack.getItemDamage(), x + 0.5D, y + spawnOffsetY, z + 0.5D);
} else {
spawnedCreature = spawnCreature(world, itemstack.getTagCompound(), x + 0.5D, y + spawnOffsetY, z + 0.5D, side);
}
if (spawnedCreature != null) {
if ((spawnedCreature instanceof EntityLiving) && itemstack.itemID == MineFactoryReloadedCore.safariNetJailerItem.itemID && itemstack.hasDisplayName()) {
((EntityLiving) spawnedCreature).func_94058_c(itemstack.getDisplayName());
}
if (isSingleUse(itemstack)) {
itemstack.stackSize--;
} else if (itemstack.getItemDamage() != 0) {
itemstack.setItemDamage(0);
} else {
itemstack.setTagCompound(null);
}
}
return spawnedCreature;
}
use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.
the class EntitySafariNet method onImpact.
@Override
protected void onImpact(MovingObjectPosition mop) {
ItemStack storedEntity = dataWatcher.getWatchableObjectItemStack(13);
if (mop.typeOfHit == EnumMovingObjectType.TILE) {
if (ItemSafariNet.isEmpty(storedEntity)) {
dropAsStack(storedEntity);
} else {
ItemSafariNet.releaseEntity(storedEntity, worldObj, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit);
if (ItemSafariNet.isSingleUse(storedEntity)) {
dropAsStack(null);
} else {
dropAsStack(storedEntity);
}
}
} else {
if (ItemSafariNet.isEmpty(storedEntity) && mop.entityHit instanceof EntityLiving) {
ItemSafariNet.captureEntity(storedEntity, (EntityLiving) mop.entityHit);
dropAsStack(storedEntity);
} else {
if (!ItemSafariNet.isEmpty(storedEntity)) {
Entity releasedEntity = ItemSafariNet.releaseEntity(storedEntity, worldObj, (int) mop.entityHit.posX, (int) mop.entityHit.posY, (int) mop.entityHit.posZ, 1);
if (mop.entityHit instanceof EntityLiving) {
if (releasedEntity instanceof EntityLiving) {
//Functional for skeletons.
((EntityLiving) releasedEntity).setAttackTarget((EntityLiving) mop.entityHit);
}
if (releasedEntity instanceof EntityCreature) {
//functional for mobs that extend EntityCreature (everything but Ghasts) and not Skeletons.
((EntityCreature) releasedEntity).setTarget(mop.entityHit);
}
}
if (ItemSafariNet.isSingleUse(storedEntity)) {
dropAsStack(null);
return;
}
}
dropAsStack(storedEntity);
}
}
}
use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.
the class TileEntityRancher method activateMachine.
@Override
public boolean activateMachine() {
MFRLiquidMover.pumpLiquid(_tank, this);
boolean didDrop = false;
List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
for (Object o : entities) {
EntityLiving e = (EntityLiving) o;
if (MFRRegistry.getRanchables().containsKey(e.getClass())) {
IFactoryRanchable r = MFRRegistry.getRanchables().get(e.getClass());
List<ItemStack> drops = r.ranch(worldObj, e, this);
if (drops != null) {
for (ItemStack s : drops) {
if (LiquidContainerRegistry.isLiquid(s)) {
_tank.fill(new LiquidStack(s.itemID, LiquidContainerRegistry.BUCKET_VOLUME, s.getItemDamage()), true);
didDrop = true;
continue;
}
doDrop(s);
didDrop = true;
}
if (didDrop) {
setIdleTicks(20);
return true;
}
}
}
}
setIdleTicks(getIdleTicksMax());
return false;
}
use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.
the class TileEntityVet method activateMachine.
@Override
public boolean activateMachine() {
List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
for (Object o : entities) {
if (!(o instanceof EntityLiving) || o instanceof EntityPlayer || o instanceof EntityMob) {
continue;
}
EntityLiving e = (EntityLiving) o;
for (int i = 0; i < getSizeInventory(); i++) {
ItemStack s = getStackInSlot(i);
if (s != null && s.getItem() instanceof ISyringe) {
if (((ISyringe) s.getItem()).canInject(worldObj, e, s)) {
if (((ISyringe) s.getItem()).inject(worldObj, e, s)) {
s.itemID = MineFactoryReloadedCore.syringeEmptyItem.itemID;
return true;
}
}
}
}
}
setIdleTicks(getIdleTicksMax());
return false;
}
Aggregations