Skip to content

Commit

Permalink
Update for 1.16.5 and add redstone option for 'useful composters'
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorrell committed Feb 21, 2021
1 parent e78c03e commit e8b0d5c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 19 additions & 13 deletions src/main/java/skyblock/SkyBlockSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> {
@Override
public Boolean validate(ServerCommandSource source, ParsedRule<Boolean> 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<String> {
@Override public String validate(ServerCommandSource source, ParsedRule<String> 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";
}
12 changes: 8 additions & 4 deletions src/main/java/skyblock/mixin/ComposterBlockMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<BlockState> 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)));
}
}
}

Expand All @@ -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<SidedInventory> 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));
}
}
}
}

0 comments on commit e8b0d5c

Please sign in to comment.