Search in sources :

Example 1 with Fertilizer

use of com.almuradev.content.type.block.type.crop.processor.fertilizer.Fertilizer in project Almura by AlmuraDev.

the class CropBlockImpl method canUseBonemeal.

@Override
public boolean canUseBonemeal(final World world, final Random random, final BlockPos pos, final IBlockState state) {
    if (!world.isRemote) {
        if (!this.isMaxAge(state)) {
            // Return TRUE always when in Dev mode!
            if (SpongeImplHooks.isDeobfuscatedEnvironment()) {
                return true;
            }
            // TODO Maybe best to move this into an interact listener and make this hook do nothing
            final CropBlockStateDefinition definition = this.definition(state);
            if (definition.fertilizer != null) {
                final Fertilizer fertilizer = definition.fertilizer;
                // TODO Pre-1.13, this is just a mess...maybe need a Deprecated "LazyItemState" that checks data
                final DoubleRange chanceRange = fertilizer.getOrLoadChanceRangeForItem(new ItemStack(Items.DYE, 1, 15));
                if (chanceRange != null) {
                    return RANDOM.nextDouble() <= (chanceRange.random(RANDOM) / 100);
                }
            }
        }
    }
    return false;
}
Also used : CropBlockStateDefinition(com.almuradev.content.type.block.type.crop.state.CropBlockStateDefinition) DoubleRange(com.almuradev.toolbox.util.math.DoubleRange) ItemStack(net.minecraft.item.ItemStack) Fertilizer(com.almuradev.content.type.block.type.crop.processor.fertilizer.Fertilizer)

Aggregations

Fertilizer (com.almuradev.content.type.block.type.crop.processor.fertilizer.Fertilizer)1 CropBlockStateDefinition (com.almuradev.content.type.block.type.crop.state.CropBlockStateDefinition)1 DoubleRange (com.almuradev.toolbox.util.math.DoubleRange)1 ItemStack (net.minecraft.item.ItemStack)1