From 17fadd468fbb29b3e36bad742775a3c9c3c4119c Mon Sep 17 00:00:00 2001 From: xalcon Date: Sat, 2 Jul 2022 23:27:15 +0200 Subject: [PATCH] add skylight requirement and allow 0 chance config --- src/main/java/crispytwig/heftycrops/HeftyCrops.java | 4 ++++ src/main/java/crispytwig/heftycrops/registry/Config.java | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/crispytwig/heftycrops/HeftyCrops.java b/src/main/java/crispytwig/heftycrops/HeftyCrops.java index 7a65ef5..1cedafc 100644 --- a/src/main/java/crispytwig/heftycrops/HeftyCrops.java +++ b/src/main/java/crispytwig/heftycrops/HeftyCrops.java @@ -53,10 +53,14 @@ private void doClientStuff(final FMLClientSetupEvent event) { @SubscribeEvent public void onCropGrow(BlockEvent.CropGrowEvent.Post event) { + if(Config.HEFTY_CROP_WEIGHT.get() == 0) return; + BlockPos pos = event.getPos(); LevelAccessor level = event.getWorld(); BlockState postState = event.getState(); + if(Config.HEFTY_CROP_REQUIRES_UNOBSTRUCTED_SKYVIEW.get() && !level.canSeeSky(pos)) return; + // Vanilla Crop Blocks if (postState.is(Blocks.BEETROOTS) && postState.getValue(BeetrootBlock.AGE) == BeetrootBlock.MAX_AGE) { diff --git a/src/main/java/crispytwig/heftycrops/registry/Config.java b/src/main/java/crispytwig/heftycrops/registry/Config.java index bf759b9..eb1ca6b 100644 --- a/src/main/java/crispytwig/heftycrops/registry/Config.java +++ b/src/main/java/crispytwig/heftycrops/registry/Config.java @@ -9,11 +9,13 @@ @Mod.EventBusSubscriber(modid = HeftyCrops.MOD_ID) public class Config { public static final ForgeConfigSpec.IntValue HEFTY_CROP_WEIGHT; + public static final ForgeConfigSpec.BooleanValue HEFTY_CROP_REQUIRES_UNOBSTRUCTED_SKYVIEW; public static ForgeConfigSpec COMMON_CONFIG; static { ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder(); - HEFTY_CROP_WEIGHT = COMMON_BUILDER.comment("Chance of hefty crop spawning. Larger number = rarer. A value of 1 will guarantee a hefty crop spawns.").defineInRange("weight", 25, 1, 100); + HEFTY_CROP_WEIGHT = COMMON_BUILDER.comment("Chance of hefty crop spawning. Larger number = rarer. A value of 1 will guarantee a hefty crop spawns. A value of 0 will disable hefty crop spawns.").defineInRange("weight", 25, 0, 100); + HEFTY_CROP_REQUIRES_UNOBSTRUCTED_SKYVIEW = COMMON_BUILDER.comment("If true, hefty crops may only spawn if the sky is visible (F3 Sky Light Level == 15)").define("requiresUnobstructedSkyView", false); Config.COMMON_CONFIG = COMMON_BUILDER.build(); }