use of net.minecraft.block.BlockCrops in project VoodooCraft by Mod-DevCafeTeam.
the class HexGreenFingers method activeUse.
@Override
public ItemStack activeUse(ItemStack stackIn, World world, EntityPlayer player, EnumHand hand, int strength, @Nullable EntityLivingBase target) {
if (world.isRemote)
return super.activeUse(stackIn, world, player, hand, strength, target);
RayTraceResult result = Minecraft.getMinecraft().objectMouseOver;
BlockPos pos = result.getBlockPos();
Block block = world.getBlockState(pos).getBlock();
if (block instanceof BlockCrops) {
if (block instanceof BlockBeetroot) {
world.setBlockState(pos, block.getDefaultState().cycleProperty(BlockBeetroot.BEETROOT_AGE));
} else {
world.setBlockState(pos, block.getDefaultState().cycleProperty(BlockCrops.AGE));
}
}
return super.activeUse(stackIn, world, player, hand, strength, target);
}
use of net.minecraft.block.BlockCrops in project BetterWithAddons by DaedalusGame.
the class BlockCropRice method updateTick.
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
checkAndDropBlock(world, pos, state);
int meta = state.getValue(AGE);
double growthChance = 15D;
if (world.getBlockState(pos.down()).getBlock().isFertile(world, pos.down()))
growthChance /= 1.33D;
else if (world.getBlockState(pos.down()).getBlock().canSustainPlant(world.getBlockState(pos.down()), world, pos.down(), EnumFacing.UP, this))
growthChance /= 1.2D;
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
IBlockState check = world.getBlockState(pos.offset(facing));
if (check.getBlock() instanceof BlockCrops)
growthChance /= 1.1D;
}
if (!isMaxAge(state)) {
if (rand.nextInt(MathHelper.floor(growthChance)) == 0)
world.setBlockState(pos, state.withProperty(AGE, meta + 1));
}
}
use of net.minecraft.block.BlockCrops in project minecolonies by Minecolonies.
the class EntityAIWorkFarmer method containsPlants.
/**
* Checks to see if field contains plants.
*
* @param field the field to check.
* @return Boolean if there were plants found.
*/
private boolean containsPlants(final Field field) {
BlockPos position;
IBlockState blockState;
while (handleOffset(field)) {
// Check to see if the block is a plant, and if it is, break it.
position = field.getLocation().down().south(workingOffset.getZ()).east(workingOffset.getX());
blockState = world.getBlockState(position.up());
if (blockState.getBlock() instanceof BlockCrops) {
return true;
}
}
return false;
}
use of net.minecraft.block.BlockCrops in project minecolonies by Minecolonies.
the class EntityAIWorkFarmer method initialize.
/**
* This (re)initializes a field.
* Checks the block above to see if it is a plant, if so, breaks it. Then tills.
*/
private AIState initialize() {
@Nullable final BuildingFarmer buildingFarmer = getOwnBuilding();
if (buildingFarmer == null || checkForHoe() || buildingFarmer.getCurrentField() == null) {
return AIState.PREPARING;
}
@Nullable final Field field = buildingFarmer.getCurrentField();
if (workingOffset != null) {
final BlockPos position = field.getLocation().down().south(workingOffset.getZ()).east(workingOffset.getX());
// Still moving to the block
if (walkToBlock(position.up())) {
return AIState.FARMER_INITIALIZE;
}
// Check to see if the block is a plant, and if it is, break it.
final IBlockState blockState = world.getBlockState(position.up());
if (blockState.getBlock() instanceof IGrowable && (!(blockState.getBlock() instanceof BlockCrops) || ((BlockCrops) blockState.getBlock()).getItem(world, position.up(), blockState) != field.getSeed())) {
mineBlock(position.up());
setDelay(getLevelDelay());
return AIState.FARMER_INITIALIZE;
}
// hoe the block if able to.
if (hoeIfAble(position, field)) {
setDelay(getLevelDelay());
return AIState.FARMER_INITIALIZE;
}
if (shouldPlant(position, field) && !plantCrop(field.getSeed(), position)) {
resetVariables();
return AIState.PREPARING;
}
}
if (!handleOffset(field)) {
resetVariables();
shouldDumpInventory = true;
field.setInitialized(true);
field.setNeedsWork(false);
return AIState.IDLE;
}
setDelay(getLevelDelay());
return AIState.FARMER_INITIALIZE;
}
use of net.minecraft.block.BlockCrops in project BetterWithAddons by DaedalusGame.
the class BlockCropRush method updateTick.
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
checkAndDropBlock(world, pos, state);
BlockPos up = pos.up();
int meta = state.getValue(AGE);
double growthChance = 15D;
if (world.getBlockState(pos.down()).getBlock().isFertile(world, pos.down()))
growthChance /= 1.33D;
else if (world.getBlockState(pos.down()).getBlock().canSustainPlant(world.getBlockState(pos.down()), world, pos.down(), EnumFacing.UP, this))
growthChance /= 1.2D;
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
IBlockState check = world.getBlockState(pos.offset(facing));
if (check.getBlock() instanceof BlockCrops)
growthChance /= 1.1D;
}
if (!isMaxAge(state)) {
if (world.getLightFromNeighbors(up) > 12) {
if (rand.nextInt(MathHelper.floor(growthChance)) == 0)
world.setBlockState(pos, state.withProperty(AGE, meta + 1));
}
}
}
Aggregations