forked from virt-mirrors/Sit
added the handSitting toggle that enables sitting using the hand
This commit is contained in:
parent
384767b24c
commit
c2e708ba38
3 changed files with 14 additions and 0 deletions
|
@ -211,6 +211,7 @@ public class Events {
|
|||
Sit.server = s;
|
||||
Sit.commandManager = s.getCommandManager();
|
||||
UseBlockCallback.EVENT.register((pl, world, hand, hitResult) -> {
|
||||
if (!Config.handSitting) return ActionResult.PASS;
|
||||
ServerPlayerEntity player = Sit.server.getPlayerManager().getPlayer(pl.getUuid());
|
||||
if (player == null) return ActionResult.PASS;
|
||||
if (hand == net.minecraft.util.Hand.MAIN_HAND && hitResult.getType() == HitResult.Type.BLOCK) {
|
||||
|
|
|
@ -40,6 +40,12 @@ public class ModMenu implements ModMenuApi {
|
|||
.binding(Config.defaults.sitWhileSeated, () -> Config.sitWhileSeated, n -> Config.sitWhileSeated = n)
|
||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||
.build())
|
||||
.option(Option.<Boolean>createBuilder()
|
||||
.name(Text.of("Sitting with Hand"))
|
||||
.description(OptionDescription.of(Text.of("Toggles the player's ability to sit with their hand.")))
|
||||
.binding(Config.defaults.handSitting,()-> Config.handSitting, n -> Config.handSitting = n)
|
||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||
.build())
|
||||
.group(OptionGroup.createBuilder()
|
||||
.name(lang("general.sittable"))
|
||||
.description(OptionDescription.of(lang("general.sittable.description")))
|
||||
|
|
|
@ -42,6 +42,7 @@ public class Config {
|
|||
}
|
||||
}
|
||||
}
|
||||
public static boolean handSitting = defaults.handSitting;
|
||||
public static HandRequirement mainReq = defaults.mainReq;
|
||||
public static boolean mainBlock = defaults.mainBlock;
|
||||
public static boolean mainFood = defaults.mainFood;
|
||||
|
@ -113,6 +114,8 @@ public class Config {
|
|||
customBlocks = validateCustomBlocks(new Gson().fromJson((String)
|
||||
properties.computeIfAbsent("custom-blocks", a -> gson.toJson(defaults.customBlocks)), listType));
|
||||
} catch (JsonSyntaxException ignore) {}
|
||||
|
||||
handSitting = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.sitting", a -> String.valueOf(defaults.handSitting)));
|
||||
mainReq = HandRequirement.get((String) properties.computeIfAbsent("hand.main.requirement", a -> String.valueOf(defaults.mainReq)));
|
||||
mainBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.main.block", a -> String.valueOf(defaults.mainBlock)));
|
||||
mainFood = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.main.food", a -> String.valueOf(defaults.mainFood)));
|
||||
|
@ -164,9 +167,11 @@ public class Config {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String lang(String key, Object... args) {
|
||||
return LangReader.of("config.sit."+key, args).getTxT().getString();
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
try (var file = Files.newBufferedWriter(configFile().toPath(), StandardCharsets.UTF_8)) {
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
|
@ -195,6 +200,7 @@ public class Config {
|
|||
.append("\n# ").append(lang("general.sittable_blocks.description_8")).getString());
|
||||
file.write("\ncustom-blocks="+gson.toJson(customBlocks));
|
||||
file.write("\n\n# "+lang("hand"));
|
||||
file.write("\nhand.sitting=" + handSitting);
|
||||
file.write("\n# "+Sit.lang("config.sit."+
|
||||
"hand.requirements.description")
|
||||
.append("\n# ").append(lang("hand.requirements.description_2"))
|
||||
|
@ -229,6 +235,7 @@ public class Config {
|
|||
public static boolean fullBlocksOn = false;
|
||||
public static boolean customOn = false;
|
||||
public static List<String> customBlocks = List.of("minecraft:campfire|.46|1|lit=false","minecraft:soul_campfire|.46|1|lit=false,waterlogged=false");
|
||||
public static boolean handSitting = true;
|
||||
public static HandRequirement mainReq = HandRequirement.empty;
|
||||
public static boolean mainBlock = false;
|
||||
public static boolean mainFood = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue