net.minecraft.block.CropBlock Java Examples

The following examples show how to use net.minecraft.block.CropBlock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BonemealAuraHack.java    From Wurst7 with GNU General Public License v3.0 6 votes vote down vote up
private boolean isCorrectBlock(BlockPos pos)
{
	Block block = BlockUtils.getBlock(pos);
	
	if(!(block instanceof Fertilizable) || block instanceof GrassBlock
		|| !((Fertilizable)block).canGrow(MC.world, MC.world.random, pos,
			BlockUtils.getState(pos)))
		return false;
	
	if(block instanceof SaplingBlock)
		return saplings.isChecked();
	else if(block instanceof CropBlock)
		return crops.isChecked();
	else if(block instanceof StemBlock)
		return stems.isChecked();
	else if(block instanceof CocoaBlock)
		return cocoa.isChecked();
	else
		return other.isChecked();
}
 
Example #2
Source File: OxygenCollectorBlockEntity.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
private int collectOxygen(BlockPos center) {
    Optional<CelestialBodyType> celestialBodyType = CelestialBodyType.getByDimType(world.getRegistryKey());

    if (celestialBodyType.isPresent()) {
        if (celestialBodyType.get().getAtmosphere().getComposition().containsKey(AtmosphericGas.OXYGEN)) {
            int minX = center.getX() - 5;
            int minY = center.getY() - 5;
            int minZ = center.getZ() - 5;
            int maxX = center.getX() + 5;
            int maxY = center.getY() + 5;
            int maxZ = center.getZ() + 5;

            float leafBlocks = 0;

            for (BlockPos pos : BlockPos.iterate(minX, minY, minZ, maxX, maxY, maxZ)) {
                BlockState blockState = world.getBlockState(pos);
                if (blockState.isAir()) {
                    continue;
                }
                if (blockState.getBlock() instanceof LeavesBlock && !blockState.get(LeavesBlock.PERSISTENT)) {
                    leafBlocks++;
                } else if (blockState.getBlock() instanceof CropBlock) {
                    leafBlocks += 0.75F;
                }
            }

            if (leafBlocks < 2) return 0;

            double oxyCount = 20 * (leafBlocks / 14.0F);
            return (int) Math.ceil(oxyCount) / 20; //every tick
        } else {
            return 183 / 20;
        }
    } else {
        return 183 / 20;
    }
}
 
Example #3
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "keepRunning", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/world/ServerWorld;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;",
        ordinal = 0
) )
private BlockState getWartBlockState(ServerWorld serverWorld, BlockPos pos)
{
    BlockState state = serverWorld.getBlockState(pos);
    if (isFarmingCleric && state.getBlock() == Blocks.NETHER_WART && state.get(NetherWartBlock.AGE) == 3)
    {
        return ((CropBlock)Blocks.WHEAT).withAge(((CropBlock)Blocks.WHEAT).getMaxAge());
    }
    return state;
}
 
Example #4
Source File: IPlantable.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
default PlantType getPlantType(BlockView world, BlockPos pos) {
	if (this instanceof CropBlock) return PlantType.Crop;
	if (this instanceof SaplingBlock) return PlantType.Plains;
	if (this instanceof FlowerBlock) return PlantType.Plains;
	if (this == Blocks.CACTUS) return PlantType.Desert;
	if (this == Blocks.LILY_PAD) return PlantType.Water;
	if (this == Blocks.RED_MUSHROOM) return PlantType.Cave;
	if (this == Blocks.BROWN_MUSHROOM) return PlantType.Cave;
	if (this == Blocks.NETHER_WART) return PlantType.Nether;
	if (this == Blocks.TALL_GRASS) return PlantType.Plains;
	return net.minecraftforge.common.PlantType.Plains;
}