use of net.minecraft.item.ItemStack 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.item.ItemStack in project MineFactoryReloaded by powercrystals.
the class TileEntitySludgeBoiler method activateMachine.
@Override
protected boolean activateMachine() {
if (_tank.getLiquid() != null && _tank.getLiquid().amount > 10) {
_tank.drain(10, true);
setWorkDone(getWorkDone() + 1);
_tick++;
if (getWorkDone() >= getWorkMax()) {
ItemStack s = ((WeightedRandomItemStack) WeightedRandom.getRandomItem(_rand, MFRRegistry.getSludgeDrops())).getStack();
doDrop(s);
setWorkDone(0);
}
if (_tick >= 23) {
Area a = new Area(new BlockPosition(this), 3, 3, 3);
List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, a.toAxisAlignedBB());
for (Object o : entities) {
if (o instanceof EntityPlayer) {
((EntityPlayer) o).addPotionEffect(new PotionEffect(Potion.hunger.id, 20 * 20, 0));
}
if (o instanceof EntityPlayer) {
((EntityPlayer) o).addPotionEffect(new PotionEffect(Potion.poison.id, 6 * 20, 0));
}
}
_tick = 0;
}
return true;
}
return false;
}
use of net.minecraft.item.ItemStack in project MineFactoryReloaded by powercrystals.
the class TileEntityUnifier method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
ItemStack output = null;
if (_inventory[0] != null) {
List<String> names = OreDictTracker.getNamesFromItem(_inventory[0]);
if (names == null || names.size() != 1) {
output = _inventory[0].copy();
} else if (_preferredOutputs.containsKey(names.get(0))) {
output = _preferredOutputs.get(names.get(0)).copy();
output.stackSize = _inventory[0].stackSize;
} else {
output = OreDictionary.getOres(names.get(0)).get(0).copy();
output.stackSize = _inventory[0].stackSize;
}
moveItemStack(output);
}
}
}
use of net.minecraft.item.ItemStack 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;
}
use of net.minecraft.item.ItemStack in project MineFactoryReloaded by powercrystals.
the class TileEntityWeather method activateMachine.
@Override
public boolean activateMachine() {
MFRLiquidMover.pumpLiquid(_tank, this);
if (worldObj.getWorldInfo().isRaining() && canSeeSky()) {
BiomeGenBase bgb = worldObj.getBiomeGenForCoords(this.xCoord, this.zCoord);
if (!bgb.canSpawnLightningBolt() && !bgb.getEnableSnow()) {
setIdleTicks(getIdleTicksMax());
return false;
}
setWorkDone(getWorkDone() + 1);
if (getWorkDone() >= getWorkMax()) {
if (bgb.getFloatTemperature() >= 0.15F) {
if (_tank.fill(new LiquidStack(Block.waterStill.blockID, LiquidContainerRegistry.BUCKET_VOLUME), true) > 0) {
setWorkDone(0);
return true;
} else {
setWorkDone(getWorkMax());
return false;
}
} else {
doDrop(new ItemStack(Item.snowball));
setWorkDone(0);
}
}
return true;
}
setIdleTicks(getIdleTicksMax());
return false;
}
Aggregations