From e8b0d5cf46a06337b7382f13ce8fb28242741fb9 Mon Sep 17 00:00:00 2001 From: Jack Sorrell Date: Sun, 21 Feb 2021 13:42:08 -0500 Subject: [PATCH] Update for 1.16.5 and add redstone option for 'useful composters' --- README.md | 4 ++- gradle.properties | 12 +++---- src/main/java/skyblock/SkyBlockSettings.java | 32 +++++++++++-------- .../skyblock/mixin/ComposterBlockMixin.java | 12 ++++--- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 0db283dd..ca2f527e 100644 --- a/README.md +++ b/README.md @@ -47,11 +47,13 @@ Enable with ```/skyblock wanderingTraderSkyblockTrades true``` ### Useful Composters -Enable with ```/skyblock usefulComposters true``` +Enable with ```/skyblock usefulComposters true``` or ```/skyblock usefulComposters redstone``` - Provides a nicer way to get sand/red sand than the 64/24 you can get at a time from a wandering trader. - Makes dirt generation nicer too. - Compost result depends on the biome. Get sand in deserts, beaches, warm oceans etc, red sand from badlands, and dirt elsewhere. + +- When set to ```redstone```, the composter outputs bonemeal without a redstone signal. ## Installation - Install [Fabric](https://fabricmc.net/use) diff --git a/gradle.properties b/gradle.properties index 11f8eda7..1d9c3520 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,16 +2,16 @@ org.gradle.jvmargs=-Xmx1G # Mod Properties -mod_version = 2.1.2 +mod_version = 2.1.3 maven_group = carpet-extension archives_base_name = skyblock # Fabric Properties # see https://modmuss50.me/fabric.html -minecraft_version=1.16.4 -yarn_mappings=1.16.4+build.9 -loader_version=0.10.8 -fabric_api_version=0.29.3+1.16 +minecraft_version=1.16.5 +yarn_mappings=1.16.5+build.4 +loader_version=0.11.1 +fabric_api_version=0.30.3+1.16 # see https://masa.dy.fi/maven/carpet/fabric-carpet/ -carpet_core_version=1.16.4-1.4.21+v201216 +carpet_core_version=1.16.5-1.4.27+v210217 diff --git a/src/main/java/skyblock/SkyBlockSettings.java b/src/main/java/skyblock/SkyBlockSettings.java index 42035d9b..50f83f65 100644 --- a/src/main/java/skyblock/SkyBlockSettings.java +++ b/src/main/java/skyblock/SkyBlockSettings.java @@ -5,28 +5,34 @@ import carpet.settings.Validator; import net.minecraft.server.command.ServerCommandSource; +import java.util.Locale; + import static carpet.settings.RuleCategory.FEATURE; public class SkyBlockSettings { public static final String SKYBLOCK = "skyblock"; - @Rule(desc = "Add trades to the wandering trader for Skyblock", category = {SKYBLOCK, FEATURE}, validate = WanderingTraderSkyblockTradesChange.class) + @Rule(desc = "Add trades to the wandering trader for Skyblock", category = {SKYBLOCK, FEATURE}) public static boolean wanderingTraderSkyblockTrades = false; - - public static class WanderingTraderSkyblockTradesChange extends Validator { - @Override - public Boolean validate(ServerCommandSource source, ParsedRule currentRule, Boolean newValue, String string) { -// if (newValue) { -// Trades.mergeWanderingTraderOffers(Trades.getSkyblockWanderingTraderOffers()); -// } else { -// Trades.mergeWanderingTraderOffers(new Int2ObjectOpenHashMap<>()); -// } -// return newValue; + + + public static boolean doUsefulComposters = false; + public static boolean usefulCompostersNeedRedstone = false; + + private static class UsefulCompostersSetting extends Validator { + @Override public String validate(ServerCommandSource source, ParsedRule currentRule, String newValue, String string) { + doUsefulComposters = !newValue.toLowerCase(Locale.ROOT).equals("false"); + usefulCompostersNeedRedstone = newValue.toLowerCase(Locale.ROOT).equals("redstone"); + return newValue; } } - @Rule(desc = "Composters create sand, red sand, and dirt depending on biome", category = {SKYBLOCK, FEATURE}) - public static boolean usefulComposters = false; + @Rule(desc = "Composters create sand, red sand, and dirt depending on biome", + category = {SKYBLOCK, FEATURE}, + options = {"true", "false", "redstone"}, + validate = UsefulCompostersSetting.class + ) + public static String usefulComposters = "false"; } diff --git a/src/main/java/skyblock/mixin/ComposterBlockMixin.java b/src/main/java/skyblock/mixin/ComposterBlockMixin.java index c1db04f5..2291fed6 100644 --- a/src/main/java/skyblock/mixin/ComposterBlockMixin.java +++ b/src/main/java/skyblock/mixin/ComposterBlockMixin.java @@ -90,8 +90,10 @@ private static void emptyComposter(BlockState state, WorldAccess world, BlockPos )) @SuppressWarnings("unused") private static void setComposterOutput(BlockState arg0, World world, BlockPos pos, CallbackInfoReturnable cir, float f, double d, double e, double g, ItemEntity dropItemEntity) { - if (SkyBlockSettings.usefulComposters) { - dropItemEntity.setStack(new ItemStack(getComposterDrop(world, pos))); + if (SkyBlockSettings.doUsefulComposters) { + if (!SkyBlockSettings.usefulCompostersNeedRedstone || world.isReceivingRedstonePower(pos)) { + dropItemEntity.setStack(new ItemStack(getComposterDrop(world, pos))); + } } } @@ -101,8 +103,10 @@ private static void setComposterOutput(BlockState arg0, World world, BlockPos po )) @SuppressWarnings("unused") private void setInventory(BlockState state, WorldAccess world, BlockPos pos, CallbackInfoReturnable cir) { - if (SkyBlockSettings.usefulComposters) { - cir.setReturnValue(new FullComposterInventory(state, world, pos)); + if (SkyBlockSettings.doUsefulComposters) { + if (!SkyBlockSettings.usefulCompostersNeedRedstone || ((World)world).isReceivingRedstonePower(pos)) { + cir.setReturnValue(new FullComposterInventory(state, world, pos)); + } } } }