use of blusunrize.immersiveengineering.api.tool.BelljarHandler.DefaultPlantHandler in project ImmersiveEngineering by BluSunrize.
the class ExtraUtilsHelper method registerXUPlant.
static void registerXUPlant(ItemStack seed, Block block, ItemStack soil, ItemStack[] output, final int maxAge, final float growthStep, final boolean useFertilizer) {
IProperty propGrowth = null;
final IBlockState state = block.getDefaultState();
for (IProperty prop : state.getPropertyNames()) if ("growth".equals(prop.getName()))
propGrowth = prop;
if (propGrowth != null) {
IProperty finalPropGrowth = propGrowth;
DefaultPlantHandler handler = new DefaultPlantHandler() {
private HashSet<ComparableItemStack> validSeeds = new HashSet<>();
@Override
protected HashSet<ComparableItemStack> getSeedSet() {
return validSeeds;
}
@Override
public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) {
return !useFertilizer ? growthStep : (growthStep * fertilizer);
}
@Override
@SideOnly(Side.CLIENT)
public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
return new IBlockState[] { state.withProperty(finalPropGrowth, Math.min(maxAge, Math.round(maxAge * growth))) };
}
};
handler.register(seed, output, soil, state);
BelljarHandler.registerHandler(handler);
}
}
Aggregations