use of stevekung.mods.moreplanets.util.blocks.BlockCropsMP in project MorePlanets by SteveKunG.
the class EntityAINibiruVillagerHarvestFarmland method shouldMoveTo.
@Override
protected boolean shouldMoveTo(World world, BlockPos pos) {
Block block = world.getBlockState(pos).getBlock();
if (block == NibiruBlocks.INFECTED_FARMLAND) {
pos = pos.up();
IBlockState iblockstate = world.getBlockState(pos);
block = iblockstate.getBlock();
if (block instanceof BlockCropsMP && iblockstate.getValue(BlockCropsMP.AGE).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0)) {
this.field_179501_f = 0;
return true;
}
if (block == Blocks.AIR && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0)) {
this.field_179501_f = 1;
return true;
}
}
return false;
}
use of stevekung.mods.moreplanets.util.blocks.BlockCropsMP in project MorePlanets by SteveKunG.
the class EntityAINibiruVillagerHarvestFarmland method updateTask.
@Override
public void updateTask() {
super.updateTask();
this.theVillager.getLookHelper().setLookPosition(this.destinationBlock.getX() + 0.5D, this.destinationBlock.getY() + 1, this.destinationBlock.getZ() + 0.5D, 10.0F, this.theVillager.getVerticalFaceSpeed());
if (this.getIsAboveDestination()) {
World world = this.theVillager.world;
BlockPos blockpos = this.destinationBlock.up();
IBlockState iblockstate = world.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (this.field_179501_f == 0 && block instanceof BlockCropsMP && iblockstate.getValue(BlockCropsMP.AGE).intValue() == 7) {
world.destroyBlock(blockpos, true);
} else if (this.field_179501_f == 1 && block == Blocks.AIR) {
InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();
for (int i = 0; i < inventorybasic.getSizeInventory(); ++i) {
ItemStack itemStack = inventorybasic.getStackInSlot(i);
boolean flag = false;
if (!itemStack.isEmpty()) {
if (itemStack.getItem() == NibiruItems.INFECTED_WHEAT_SEEDS) {
world.setBlockState(blockpos, NibiruBlocks.INFECTED_WHEAT_BLOCK.getDefaultState(), 3);
flag = true;
} else if (itemStack.getItem() == NibiruItems.NIBIRU_FRUITS && itemStack.getItemDamage() == 6) {
world.setBlockState(blockpos, NibiruBlocks.TERRABERRY_BLOCK.getDefaultState(), 3);
flag = true;
}
}
if (flag) {
itemStack.shrink(1);
if (itemStack.getCount() <= 0) {
inventorybasic.setInventorySlotContents(i, ItemStack.EMPTY);
}
break;
}
}
}
this.field_179501_f = -1;
this.runDelay = 10;
}
}
Aggregations