mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 16:03:22 +02:00
Merge branch 'master' into 1.20-1.20.1
# Conflicts: # gradle.properties
This commit is contained in:
commit
4e902c1236
10 changed files with 226 additions and 142 deletions
11
README.md
11
README.md
|
@ -7,17 +7,23 @@
|
||||||
Sit on **stairs**, **slabs**, **carpets** by default, and sit on everything else using the config!
|
Sit on **stairs**, **slabs**, **carpets** by default, and sit on everything else using the config!
|
||||||
You can also customize hand restrictions to stop accidentally sitting down!
|
You can also customize hand restrictions to stop accidentally sitting down!
|
||||||
The mod also has full Geyser support! Enjoy sitting with everyone, weather they are on Bedrock or Java!
|
The mod also has full Geyser support! Enjoy sitting with everyone, weather they are on Bedrock or Java!
|
||||||
|
|
||||||
### Where to install?
|
### Where to install?
|
||||||
**Sit!** works on the server (singleplayer included), with support for clients that join in to use their own settings to sit.
|
**Sit!** works on the server (singleplayer included), also with support for clients that join in to use their own settings to sit.
|
||||||
|
|
||||||
## Help localize Sit! on [Crowdin](https://crowdin.com/project/oth3r-sit)!
|
## Help localize Sit! on [Crowdin](https://crowdin.com/project/oth3r-sit)!
|
||||||

|

|
||||||
|
|
||||||
## Check out my other Projects!
|
## Check out my other Projects!
|
||||||
|
[](https://modrinth.com/mod/caligo)
|
||||||
[](https://modrinth.com/mod/directionhud)
|
[](https://modrinth.com/mod/directionhud)
|
||||||
[](https://modrinth.com/plugin/directionhud-plugin)
|
[](https://modrinth.com/plugin/directionhud-plugin)
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
### Hand Restrictions
|
### Hand Restrictions
|
||||||
Don't want to accidentally sit down? Set custom restrictions for each hand in the config!
|
Don't want to accidentally sit down? Set custom restrictions for each hand in the config!
|
||||||
|
|
||||||
* Per player hand restrictions when connecting to a `Sit!` server on a `Sit!` Client!
|
* Per player hand restrictions when connecting to a `Sit!` server on a `Sit!` Client!
|
||||||
|
|
||||||

|

|
||||||
|
@ -26,6 +32,7 @@ Don't want to accidentally sit down? Set custom restrictions for each hand in th
|
||||||
Want to sit on _**EVERY**_ block? With the config you can add more options to sit on! Custom block states are also supported.
|
Want to sit on _**EVERY**_ block? With the config you can add more options to sit on! Custom block states are also supported.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Customizable Config
|
### Customizable Config
|
||||||
Configure to your hearts desire with the in-game config with **[ModMenu](https://modrinth.com/mod/modmenu)** & **[YetAnotherConfigLib](https://modrinth.com/mod/yacl)**, or use the provided config file for servers!
|
Configure to your hearts desire with the in-game config with **[ModMenu](https://modrinth.com/mod/modmenu)** & **[YetAnotherConfigLib](https://modrinth.com/mod/yacl)**, or use the provided config file for servers!
|
||||||
|
|
||||||
|
@ -35,3 +42,5 @@ Configure to your hearts desire with the in-game config with **[ModMenu](https:/
|
||||||
## Future Goals
|
## Future Goals
|
||||||
* Forge Port (probably NeoForge 1.21)
|
* Forge Port (probably NeoForge 1.21)
|
||||||
* Custom dismounting logic
|
* Custom dismounting logic
|
||||||
|
* better config (coming soon!)
|
||||||
|
* keybindings (next update)
|
||||||
|
|
|
@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10
|
||||||
loader_version=0.14.24
|
loader_version=0.14.24
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.1.3+1.20-1.20.1
|
mod_version=1.1.4+1.20-1.20.1
|
||||||
maven_group=one.oth3r
|
maven_group=one.oth3r
|
||||||
archives_base_name=sit!
|
archives_base_name=sit!
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import one.oth3r.sit.Utl.HandType;
|
import one.oth3r.sit.Utl.HandSettings.HandType;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
@ -38,25 +39,25 @@ public class Events {
|
||||||
ArrayList<UseAction> notUsable = new ArrayList<>(food);
|
ArrayList<UseAction> notUsable = new ArrayList<>(food);
|
||||||
notUsable.add(UseAction.NONE);
|
notUsable.add(UseAction.NONE);
|
||||||
HashMap<HandType, ItemStack> itemMap = new HashMap<>();
|
HashMap<HandType, ItemStack> itemMap = new HashMap<>();
|
||||||
itemMap.put(HandType.main,player.getMainHandStack());
|
itemMap.put(Utl.HandSettings.HandType.main,player.getMainHandStack());
|
||||||
itemMap.put(HandType.off,player.getOffHandStack());
|
itemMap.put(Utl.HandSettings.HandType.off,player.getOffHandStack());
|
||||||
// if sneaking cant sit
|
// if sneaking cant sit
|
||||||
if (player.isSneaking()) return false;
|
if (player.isSneaking()) return false;
|
||||||
// for both hands
|
// for both hands
|
||||||
for (HandType type:HandType.values()) {
|
for (HandType type: Utl.HandSettings.HandType.values()) {
|
||||||
ItemStack targetStack = itemMap.get(type);
|
ItemStack targetStack = itemMap.get(type);
|
||||||
// if req is empty and the item isn't empty, false
|
// if req is empty and the item isn't empty, false
|
||||||
if (Utl.getReq(player,type).equals(config.HandRequirement.empty) && !targetStack.isEmpty()) return false;
|
if (Utl.HandSettings.getReq(player,type).equals(Config.HandRequirement.empty) && !targetStack.isEmpty()) return false;
|
||||||
// if req is restrictive
|
// if req is restrictive
|
||||||
if (Utl.getReq(player,type).equals(config.HandRequirement.restrictive)) {
|
if (Utl.HandSettings.getReq(player,type).equals(Config.HandRequirement.restrictive)) {
|
||||||
// if item is in blacklist, false
|
// if item is in blacklist, false
|
||||||
if (checkList(Utl.getList(player,type,"blacklist"),targetStack)) return false;
|
if (checkList(Utl.HandSettings.getList(player,type,"blacklist"),targetStack)) return false;
|
||||||
// if item is NOT in whitelist
|
// if item is NOT in whitelist
|
||||||
if (!checkList(Utl.getList(player,type,"whitelist"),targetStack)) {
|
if (!checkList(Utl.HandSettings.getList(player,type,"whitelist"),targetStack)) {
|
||||||
// if block is restricted and items is block, false, ect
|
// if block is restricted and items is block, false, ect
|
||||||
if (Utl.getBool(player,type,"block") && (targetStack.getItem() instanceof BlockItem)) return false;
|
if (Utl.HandSettings.getBool(player,type,"block") && (targetStack.getItem() instanceof BlockItem)) return false;
|
||||||
if (Utl.getBool(player,type,"food") && food.contains(targetStack.getUseAction())) return false;
|
if (Utl.HandSettings.getBool(player,type,"food") && food.contains(targetStack.getUseAction())) return false;
|
||||||
if (Utl.getBool(player,type,"usable") && !notUsable.contains(targetStack.getUseAction())) return false;
|
if (Utl.HandSettings.getBool(player,type,"usable") && !notUsable.contains(targetStack.getUseAction())) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ public class Events {
|
||||||
// get a hashmap of custom blocks
|
// get a hashmap of custom blocks
|
||||||
HashMap<String,HashMap<String,Object>> map = new HashMap<>();
|
HashMap<String,HashMap<String,Object>> map = new HashMap<>();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (String s:config.customBlocks) {
|
for (String s: Config.customBlocks) {
|
||||||
String[] split = s.split("\\|");
|
String[] split = s.split("\\|");
|
||||||
HashMap<String,Object> data = new HashMap<>();
|
HashMap<String,Object> data = new HashMap<>();
|
||||||
data.put("block",split[0]);
|
data.put("block",split[0]);
|
||||||
|
@ -100,12 +101,12 @@ public class Events {
|
||||||
for (Entity entity:entities.values()) if (entity.getBlockPos().equals(pos) || entity.getBlockPos().add(0,1,0).equals(pos)) return false;
|
for (Entity entity:entities.values()) if (entity.getBlockPos().equals(pos) || entity.getBlockPos().add(0,1,0).equals(pos)) return false;
|
||||||
|
|
||||||
// return for the 4 default types
|
// return for the 4 default types
|
||||||
if (block instanceof StairsBlock && config.stairsOn) return blockState.get(StairsBlock.HALF) == BlockHalf.BOTTOM;
|
if (block instanceof StairsBlock && Config.stairsOn) return blockState.get(StairsBlock.HALF) == BlockHalf.BOTTOM;
|
||||||
if (block instanceof SlabBlock && config.slabsOn) return blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM;
|
if (block instanceof SlabBlock && Config.slabsOn) return blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM;
|
||||||
if (block instanceof CarpetBlock && config.carpetsOn) return true;
|
if (block instanceof CarpetBlock && Config.carpetsOn) return true;
|
||||||
if (blockState.isFullCube(world,pos.add(0,1,0)) && config.fullBlocksOn) return true;
|
if (blockState.isFullCube(world,pos.add(0,1,0)) && Config.fullBlocksOn) return true;
|
||||||
// custom checker
|
// custom checker
|
||||||
if (config.customOn && config.customBlocks.size() != 0) {
|
if (Config.customOn && Config.customBlocks.size() != 0) {
|
||||||
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
||||||
String blockID = Registries.BLOCK.getId(block).toString();
|
String blockID = Registries.BLOCK.getId(block).toString();
|
||||||
if (map.get("block").equals(blockID)) {
|
if (map.get("block").equals(blockID)) {
|
||||||
|
@ -149,7 +150,7 @@ public class Events {
|
||||||
entity.updatePositionAndAngles(pos.getX() + 0.5, pos.getY()+.78, pos.getZ() + 0.5, 0, 0);
|
entity.updatePositionAndAngles(pos.getX() + 0.5, pos.getY()+.78, pos.getZ() + 0.5, 0, 0);
|
||||||
hitBoxY = 2;
|
hitBoxY = 2;
|
||||||
}
|
}
|
||||||
if (config.customOn && config.customBlocks.size() != 0) {
|
if (Config.customOn && !Config.customBlocks.isEmpty()) {
|
||||||
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
||||||
String blockID = Registries.BLOCK.getId(block).toString();
|
String blockID = Registries.BLOCK.getId(block).toString();
|
||||||
if (map.get("block").equals(blockID)) {
|
if (map.get("block").equals(blockID)) {
|
||||||
|
@ -165,6 +166,24 @@ public class Events {
|
||||||
if (entity.getY() <= pos.getY()+.35) entity.setPitch(90); // below
|
if (entity.getY() <= pos.getY()+.35) entity.setPitch(90); // below
|
||||||
else entity.setPitch(-90); // above
|
else entity.setPitch(-90); // above
|
||||||
}
|
}
|
||||||
|
public static boolean sit(ServerPlayerEntity player, BlockPos pos) {
|
||||||
|
// todo interactions entity to make the sitting hitbox?
|
||||||
|
World world = player.getWorld();
|
||||||
|
DisplayEntity.TextDisplayEntity entity = new DisplayEntity.TextDisplayEntity(EntityType.TEXT_DISPLAY,player.getServerWorld());
|
||||||
|
setEntity(pos,world,entity);
|
||||||
|
if (checkBlocks(pos,world,isAboveBlockheight(entity))) {
|
||||||
|
if (entities.containsKey(player)) {
|
||||||
|
if (!Config.sitWhileSeated) return false;
|
||||||
|
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
||||||
|
entities.remove(player);
|
||||||
|
}
|
||||||
|
player.getServerWorld().spawnEntity(entity);
|
||||||
|
player.startRiding(entity);
|
||||||
|
entities.put(player,entity);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
public static void register() {
|
public static void register() {
|
||||||
ServerTickEvents.END_SERVER_TICK.register(minecraftServer -> minecraftServer.execute(Events::cleanUp));
|
ServerTickEvents.END_SERVER_TICK.register(minecraftServer -> minecraftServer.execute(Events::cleanUp));
|
||||||
// PLAYER JOIN
|
// PLAYER JOIN
|
||||||
|
@ -172,12 +191,12 @@ public class Events {
|
||||||
ServerPlayerEntity player = handler.player;
|
ServerPlayerEntity player = handler.player;
|
||||||
checkPlayers.put(player,2);
|
checkPlayers.put(player,2);
|
||||||
// put server settings in the player settings
|
// put server settings in the player settings
|
||||||
Sit.playerSettings.put(player,Utl.getHandSettings());
|
Sit.playerSettings.put(player, Utl.HandSettings.getHandSettings());
|
||||||
});
|
});
|
||||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
ServerPlayerEntity player = handler.player;
|
ServerPlayerEntity player = handler.player;
|
||||||
if (entities.containsKey(player)) {
|
if (entities.containsKey(player)) {
|
||||||
if (!config.keepActive) {
|
if (!Config.keepActive) {
|
||||||
player.dismountVehicle();
|
player.dismountVehicle();
|
||||||
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
||||||
}
|
}
|
||||||
|
@ -194,22 +213,12 @@ public class Events {
|
||||||
if (player == null) return ActionResult.PASS;
|
if (player == null) return ActionResult.PASS;
|
||||||
if (hand == net.minecraft.util.Hand.MAIN_HAND && hitResult.getType() == HitResult.Type.BLOCK) {
|
if (hand == net.minecraft.util.Hand.MAIN_HAND && hitResult.getType() == HitResult.Type.BLOCK) {
|
||||||
BlockPos pos = hitResult.getBlockPos();
|
BlockPos pos = hitResult.getBlockPos();
|
||||||
|
// check the players hands
|
||||||
if (!checkLogic(player)) return ActionResult.PASS;
|
if (!checkLogic(player)) return ActionResult.PASS;
|
||||||
// todo interactions entity to make the hitbox?
|
// make the player sit
|
||||||
// make the entity first before checking to make sure the blocks around are fine
|
boolean status = sit(player,pos);
|
||||||
DisplayEntity.TextDisplayEntity entity = new DisplayEntity.TextDisplayEntity(EntityType.TEXT_DISPLAY,player.getServerWorld());
|
// if sat, cancel / FAIL the use block event
|
||||||
setEntity(pos,world,entity);
|
if (status) return ActionResult.FAIL;
|
||||||
if (checkBlocks(pos,world,isAboveBlockheight(entity))) {
|
|
||||||
if (entities.containsKey(player)) {
|
|
||||||
if (!config.sitWhileSeated) return ActionResult.PASS;
|
|
||||||
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
|
||||||
entities.remove(player);
|
|
||||||
}
|
|
||||||
player.getServerWorld().spawnEntity(entity);
|
|
||||||
player.startRiding(entity);
|
|
||||||
entities.put(player,entity);
|
|
||||||
return ActionResult.FAIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ActionResult.PASS;
|
return ActionResult.PASS;
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -77,10 +78,10 @@ public class LangReader {
|
||||||
public static void loadLanguageFile() {
|
public static void loadLanguageFile() {
|
||||||
try {
|
try {
|
||||||
ClassLoader classLoader = Sit.class.getClassLoader();
|
ClassLoader classLoader = Sit.class.getClassLoader();
|
||||||
InputStream inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+ config.lang+".json");
|
InputStream inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+ Config.lang+".json");
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+config.defaults.lang+".json");
|
inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+ Config.defaults.lang+".json");
|
||||||
config.lang = config.defaults.lang;
|
Config.lang = Config.defaults.lang;
|
||||||
}
|
}
|
||||||
if (inputStream == null) throw new IllegalArgumentException("CANT LOAD THE LANGUAGE FILE. DIRECTIONHUD WILL BREAK.");
|
if (inputStream == null) throw new IllegalArgumentException("CANT LOAD THE LANGUAGE FILE. DIRECTIONHUD WILL BREAK.");
|
||||||
Type type = new TypeToken<Map<String, String>>(){}.getType();
|
Type type = new TypeToken<Map<String, String>>(){}.getType();
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TextColor;
|
import net.minecraft.text.TextColor;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
public class ModMenu implements ModMenuApi {
|
public class ModMenu implements ModMenuApi {
|
||||||
private static MutableText lang(String key) {
|
private static MutableText lang(String key) {
|
||||||
|
@ -20,7 +21,9 @@ public class ModMenu implements ModMenuApi {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
return parent -> YetAnotherConfigLib.createBuilder().save(config::save)
|
// return null if YACL isn't installed to not throw an error
|
||||||
|
if (!yaclCheck()) return screen -> null;
|
||||||
|
return parent -> YetAnotherConfigLib.createBuilder().save(Config::save)
|
||||||
.title(Text.of("Sit!"))
|
.title(Text.of("Sit!"))
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
.name(lang("category.general"))
|
.name(lang("category.general"))
|
||||||
|
@ -28,13 +31,13 @@ public class ModMenu implements ModMenuApi {
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.keep_active"))
|
.name(lang("general.keep_active"))
|
||||||
.description(OptionDescription.of(lang("general.keep_active.description")))
|
.description(OptionDescription.of(lang("general.keep_active.description")))
|
||||||
.binding(config.defaults.keepActive, () -> config.keepActive, n -> config.keepActive = n)
|
.binding(Config.defaults.keepActive, () -> Config.keepActive, n -> Config.keepActive = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sit_while_seated"))
|
.name(lang("general.sit_while_seated"))
|
||||||
.description(OptionDescription.of(lang("general.sit_while_seated.description")))
|
.description(OptionDescription.of(lang("general.sit_while_seated.description")))
|
||||||
.binding(config.defaults.sitWhileSeated, () -> config.sitWhileSeated, n -> config.sitWhileSeated = n)
|
.binding(Config.defaults.sitWhileSeated, () -> Config.sitWhileSeated, n -> Config.sitWhileSeated = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.group(OptionGroup.createBuilder()
|
.group(OptionGroup.createBuilder()
|
||||||
|
@ -42,28 +45,28 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("general.sittable.description")))
|
.description(OptionDescription.of(lang("general.sittable.description")))
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.stairs"))
|
.name(lang("general.sittable.stairs"))
|
||||||
.binding(config.defaults.stairsOn, () -> config.stairsOn, n -> config.stairsOn = n)
|
.binding(Config.defaults.stairsOn, () -> Config.stairsOn, n -> Config.stairsOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.slabs"))
|
.name(lang("general.sittable.slabs"))
|
||||||
.binding(config.defaults.slabsOn, () -> config.slabsOn, n -> config.slabsOn = n)
|
.binding(Config.defaults.slabsOn, () -> Config.slabsOn, n -> Config.slabsOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.carpets"))
|
.name(lang("general.sittable.carpets"))
|
||||||
.binding(config.defaults.carpetsOn, () -> config.carpetsOn, n -> config.carpetsOn = n)
|
.binding(Config.defaults.carpetsOn, () -> Config.carpetsOn, n -> Config.carpetsOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.full_blocks"))
|
.name(lang("general.sittable.full_blocks"))
|
||||||
.binding(config.defaults.fullBlocksOn, () -> config.fullBlocksOn, n -> config.fullBlocksOn = n)
|
.binding(Config.defaults.fullBlocksOn, () -> Config.fullBlocksOn, n -> Config.fullBlocksOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.custom"))
|
.name(lang("general.sittable.custom"))
|
||||||
.description(OptionDescription.of(lang("general.sittable.custom.description")))
|
.description(OptionDescription.of(lang("general.sittable.custom.description")))
|
||||||
.binding(config.defaults.customOn, () -> config.customOn, n -> config.customOn = n)
|
.binding(Config.defaults.customOn, () -> Config.customOn, n -> Config.customOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
|
@ -86,7 +89,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.append("\n").append(lang("general.sittable_blocks.description_6").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
.append("\n").append(lang("general.sittable_blocks.description_6").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
||||||
.append("\n").append(lang("general.sittable_blocks.description_7").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GOLD))))
|
.append("\n").append(lang("general.sittable_blocks.description_7").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GOLD))))
|
||||||
.append("\n\n").append(lang("general.sittable_blocks.description_8").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.YELLOW))))))
|
.append("\n\n").append(lang("general.sittable_blocks.description_8").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.YELLOW))))))
|
||||||
.binding(config.defaults.customBlocks, () -> config.customBlocks, n -> config.customBlocks = n)
|
.binding(Config.defaults.customBlocks, () -> Config.customBlocks, n -> Config.customBlocks = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -94,14 +97,14 @@ public class ModMenu implements ModMenuApi {
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
.name(lang("category.main_hand"))
|
.name(lang("category.main_hand"))
|
||||||
.tooltip(lang("category.main_hand.tooltip"))
|
.tooltip(lang("category.main_hand.tooltip"))
|
||||||
.option(Option.<config.HandRequirement>createBuilder()
|
.option(Option.<Config.HandRequirement>createBuilder()
|
||||||
.name(lang("hand.requirements"))
|
.name(lang("hand.requirements"))
|
||||||
.description(OptionDescription.of(lang("hand.requirements.description")
|
.description(OptionDescription.of(lang("hand.requirements.description")
|
||||||
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
||||||
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
||||||
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
||||||
.binding(config.defaults.mainReq, () -> config.mainReq, n -> config.mainReq = n)
|
.binding(Config.defaults.mainReq, () -> Config.mainReq, n -> Config.mainReq = n)
|
||||||
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(config.HandRequirement.class)
|
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(Config.HandRequirement.class)
|
||||||
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
||||||
.build())
|
.build())
|
||||||
.group(OptionGroup.createBuilder()
|
.group(OptionGroup.createBuilder()
|
||||||
|
@ -109,18 +112,18 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.blocks"))
|
.name(lang("hand.restrictions.blocks"))
|
||||||
.binding(config.defaults.mainBlock,()-> config.mainBlock,n -> config.mainBlock = n)
|
.binding(Config.defaults.mainBlock,()-> Config.mainBlock, n -> Config.mainBlock = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.food"))
|
.name(lang("hand.restrictions.food"))
|
||||||
.binding(config.defaults.mainFood,()-> config.mainFood,n -> config.mainFood = n)
|
.binding(Config.defaults.mainFood,()-> Config.mainFood, n -> Config.mainFood = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.usable"))
|
.name(lang("hand.restrictions.usable"))
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
||||||
.binding(config.defaults.mainUsable,()-> config.mainUsable,n -> config.mainUsable = n)
|
.binding(Config.defaults.mainUsable,()-> Config.mainUsable, n -> Config.mainUsable = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
|
@ -129,7 +132,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.whitelist.description")
|
.description(OptionDescription.of(lang("hand.whitelist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.mainWhitelist, () -> config.mainWhitelist, n -> config.mainWhitelist = n)
|
.binding(Config.defaults.mainWhitelist, () -> Config.mainWhitelist, n -> Config.mainWhitelist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -138,7 +141,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.blacklist.description")
|
.description(OptionDescription.of(lang("hand.blacklist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.mainBlacklist, () -> config.mainBlacklist, n -> config.mainBlacklist = n)
|
.binding(Config.defaults.mainBlacklist, () -> Config.mainBlacklist, n -> Config.mainBlacklist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -146,14 +149,14 @@ public class ModMenu implements ModMenuApi {
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
.name(lang("category.off_hand"))
|
.name(lang("category.off_hand"))
|
||||||
.tooltip(lang("category.off_hand.tooltip"))
|
.tooltip(lang("category.off_hand.tooltip"))
|
||||||
.option(Option.<config.HandRequirement>createBuilder()
|
.option(Option.<Config.HandRequirement>createBuilder()
|
||||||
.name(lang("hand.requirements"))
|
.name(lang("hand.requirements"))
|
||||||
.description(OptionDescription.of(lang("hand.requirements.description")
|
.description(OptionDescription.of(lang("hand.requirements.description")
|
||||||
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
||||||
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
||||||
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
||||||
.binding(config.defaults.offReq, () -> config.offReq, n -> config.offReq = n)
|
.binding(Config.defaults.offReq, () -> Config.offReq, n -> Config.offReq = n)
|
||||||
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(config.HandRequirement.class)
|
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(Config.HandRequirement.class)
|
||||||
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
||||||
.build())
|
.build())
|
||||||
.group(OptionGroup.createBuilder()
|
.group(OptionGroup.createBuilder()
|
||||||
|
@ -161,18 +164,18 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.blocks"))
|
.name(lang("hand.restrictions.blocks"))
|
||||||
.binding(config.defaults.offBlock,()-> config.offBlock,n -> config.offBlock = n)
|
.binding(Config.defaults.offBlock,()-> Config.offBlock, n -> Config.offBlock = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.food"))
|
.name(lang("hand.restrictions.food"))
|
||||||
.binding(config.defaults.offFood,()-> config.offFood,n -> config.offFood = n)
|
.binding(Config.defaults.offFood,()-> Config.offFood, n -> Config.offFood = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.usable"))
|
.name(lang("hand.restrictions.usable"))
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
||||||
.binding(config.defaults.offUsable,()-> config.offUsable,n -> config.offUsable = n)
|
.binding(Config.defaults.offUsable,()-> Config.offUsable, n -> Config.offUsable = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
|
@ -181,7 +184,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.whitelist.description")
|
.description(OptionDescription.of(lang("hand.whitelist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.offWhitelist, () -> config.offWhitelist, n -> config.offWhitelist = n)
|
.binding(Config.defaults.offWhitelist, () -> Config.offWhitelist, n -> Config.offWhitelist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -190,11 +193,24 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.blacklist.description")
|
.description(OptionDescription.of(lang("hand.blacklist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.offBlacklist, () -> config.offBlacklist, n -> config.offBlacklist = n)
|
.binding(Config.defaults.offBlacklist, () -> Config.offBlacklist, n -> Config.offBlacklist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
.build().generateScreen(parent);
|
.build().generateScreen(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check if YACL is installed by getting a class and seeing if it throws
|
||||||
|
* @return if YACL is installed
|
||||||
|
*/
|
||||||
|
public static boolean yaclCheck() {
|
||||||
|
try {
|
||||||
|
Class.forName("dev.isxander.yacl3.platform.fabric.YACLPlatformImpl");
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,23 +3,19 @@ package one.oth3r.sit;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.util.ReferenceCountUtil;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Sit implements ModInitializer {
|
public class Sit implements ModInitializer {
|
||||||
|
@ -36,7 +32,7 @@ public class Sit implements ModInitializer {
|
||||||
//todo future:
|
//todo future:
|
||||||
// make it so it updates the sitting height and pos based on the block so if it changed while offline it still works (or if stair changes shape)
|
// make it so it updates the sitting height and pos based on the block so if it changed while offline it still works (or if stair changes shape)
|
||||||
// inner stair offset & custom support for that ig
|
// inner stair offset & custom support for that ig
|
||||||
config.load();
|
Config.load();
|
||||||
Events.register();
|
Events.register();
|
||||||
//PACKETS
|
//PACKETS
|
||||||
ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(),
|
ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(),
|
||||||
|
|
|
@ -20,6 +20,6 @@ public class SitClient implements ClientModInitializer {
|
||||||
}
|
}
|
||||||
public static void sendPackets() {
|
public static void sendPackets() {
|
||||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||||
new PacketBuilder(gson.toJson(Utl.getHandSettings())).send();
|
new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,15 +7,13 @@ import com.mojang.brigadier.context.CommandContext;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||||
import net.minecraft.entity.EntityType;
|
|
||||||
import net.minecraft.entity.decoration.DisplayEntity;
|
|
||||||
import net.minecraft.server.command.CommandManager;
|
import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.TextColor;
|
import net.minecraft.text.TextColor;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@ -48,31 +46,24 @@ public class SitCommand {
|
||||||
// if console
|
// if console
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
config.load();
|
Config.load();
|
||||||
Sit.LOGGER.info(Sit.lang("key.sit.command.reloaded").getString());
|
Sit.LOGGER.info(Sit.lang("key.sit.command.reloaded").getString());
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("sit")) {
|
if (args[0].equalsIgnoreCase("sit")) {
|
||||||
BlockPos pos = player.getBlockPos();
|
BlockPos pos = player.getBlockPos();
|
||||||
if (!(player.getY() -((int) player.getY()) > 0.00)) {
|
// get the block under the player if player on top of a solid
|
||||||
|
if (!(player.getY() - ((int) player.getY()) > 0.00)) {
|
||||||
pos = pos.add(0,-1,0);
|
pos = pos.add(0,-1,0);
|
||||||
}
|
}
|
||||||
World world = player.getWorld();
|
|
||||||
// if already sitting, ignore
|
// if already sitting, ignore
|
||||||
if (Events.entities.containsKey(player)) return 1;
|
if (Events.entities.containsKey(player)) return 1;
|
||||||
// make entity first to check the blocks
|
// sit
|
||||||
DisplayEntity.TextDisplayEntity entity = new DisplayEntity.TextDisplayEntity(EntityType.TEXT_DISPLAY,player.getServerWorld());
|
Events.sit(player,pos);
|
||||||
Events.setEntity(pos,world,entity);
|
|
||||||
if (Events.checkBlocks(pos,world,Events.isAboveBlockheight(entity))) {
|
|
||||||
player.getServerWorld().spawnEntity(entity);
|
|
||||||
player.startRiding(entity);
|
|
||||||
Events.entities.put(player,entity);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
config.load();
|
Config.load();
|
||||||
player.sendMessage(Sit.lang("key.sit.command.reloaded").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))));
|
player.sendMessage(Sit.lang("key.sit.command.reloaded").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))));
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("purgeChairEntities")) {
|
if (args[0].equalsIgnoreCase("purgeChairEntities")) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -11,35 +12,59 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Utl {
|
public class Utl {
|
||||||
enum HandType {
|
public static class HandSettings {
|
||||||
main,
|
public static HashMap<String,String> getHandSettings() {
|
||||||
off
|
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||||
|
HashMap<String,String> settings = new HashMap<>();
|
||||||
|
settings.put("hand.main.requirement",String.valueOf(Config.mainReq));
|
||||||
|
settings.put("hand.main.block",String.valueOf(Config.mainBlock));
|
||||||
|
settings.put("hand.main.food",String.valueOf(Config.mainFood));
|
||||||
|
settings.put("hand.main.usable",String.valueOf(Config.mainUsable));
|
||||||
|
settings.put("hand.main.whitelist",gson.toJson(Config.mainWhitelist));
|
||||||
|
settings.put("hand.main.blacklist",gson.toJson(Config.mainBlacklist));
|
||||||
|
settings.put("hand.off.requirement",String.valueOf(Config.offReq));
|
||||||
|
settings.put("hand.off.block",String.valueOf(Config.offBlock));
|
||||||
|
settings.put("hand.off.food",String.valueOf(Config.offFood));
|
||||||
|
settings.put("hand.off.usable",String.valueOf(Config.offUsable));
|
||||||
|
settings.put("hand.off.whitelist",gson.toJson(Config.offWhitelist));
|
||||||
|
settings.put("hand.off.blacklist",gson.toJson(Config.offBlacklist));
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Config.HandRequirement getReq(ServerPlayerEntity player, HandType type) {
|
||||||
|
return Config.HandRequirement.get(Sit.playerSettings.get(player).get("hand."+type+".requirement"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getList(ServerPlayerEntity player, HandType type, String setting) {
|
||||||
|
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
|
||||||
|
return new Gson().fromJson(Sit.playerSettings.get(player).get("hand."+type+"."+setting),listType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getBool(ServerPlayerEntity player, HandType type, String setting) {
|
||||||
|
return Boolean.parseBoolean(Sit.playerSettings.get(player).get("hand."+type+"."+setting));
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum HandType {
|
||||||
|
main,
|
||||||
|
off
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static HashMap<String,String> getHandSettings() {
|
public static class Num {
|
||||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
public static boolean isInt(String string) {
|
||||||
HashMap<String,String> settings = new HashMap<>();
|
try {
|
||||||
settings.put("hand.main.requirement",String.valueOf(config.mainReq));
|
Integer.parseInt(string);
|
||||||
settings.put("hand.main.block",String.valueOf(config.mainBlock));
|
} catch (NumberFormatException nfe) {
|
||||||
settings.put("hand.main.food",String.valueOf(config.mainFood));
|
return false;
|
||||||
settings.put("hand.main.usable",String.valueOf(config.mainUsable));
|
}
|
||||||
settings.put("hand.main.whitelist",gson.toJson(config.mainWhitelist));
|
return true;
|
||||||
settings.put("hand.main.blacklist",gson.toJson(config.mainBlacklist));
|
}
|
||||||
settings.put("hand.off.requirement",String.valueOf(config.offReq));
|
public static boolean isFloat(String string) {
|
||||||
settings.put("hand.off.block",String.valueOf(config.offBlock));
|
try {
|
||||||
settings.put("hand.off.food",String.valueOf(config.offFood));
|
Float.parseFloat(string);
|
||||||
settings.put("hand.off.usable",String.valueOf(config.offUsable));
|
} catch (NumberFormatException nfe) {
|
||||||
settings.put("hand.off.whitelist",gson.toJson(config.offWhitelist));
|
return false;
|
||||||
settings.put("hand.off.blacklist",gson.toJson(config.offBlacklist));
|
}
|
||||||
return settings;
|
return true;
|
||||||
}
|
}
|
||||||
public static config.HandRequirement getReq(ServerPlayerEntity player, HandType type) {
|
|
||||||
return config.HandRequirement.get(Sit.playerSettings.get(player).get("hand."+type+".requirement"));
|
|
||||||
}
|
|
||||||
public static List<String> getList(ServerPlayerEntity player, HandType type, String setting) {
|
|
||||||
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
|
|
||||||
return new Gson().fromJson(Sit.playerSettings.get(player).get("hand."+type+"."+setting),listType);
|
|
||||||
}
|
|
||||||
public static boolean getBool(ServerPlayerEntity player, HandType type, String setting) {
|
|
||||||
return Boolean.parseBoolean(Sit.playerSettings.get(player).get("hand."+type+"."+setting));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
package one.oth3r.sit;
|
package one.oth3r.sit.file;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import one.oth3r.sit.LangReader;
|
||||||
|
import one.oth3r.sit.Sit;
|
||||||
|
import one.oth3r.sit.SitClient;
|
||||||
|
import one.oth3r.sit.Utl.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -14,7 +19,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class config {
|
public class Config {
|
||||||
public static String lang = defaults.lang;
|
public static String lang = defaults.lang;
|
||||||
public static boolean keepActive = defaults.keepActive;
|
public static boolean keepActive = defaults.keepActive;
|
||||||
public static boolean sitWhileSeated = defaults.sitWhileSeated;
|
public static boolean sitWhileSeated = defaults.sitWhileSeated;
|
||||||
|
@ -24,7 +29,7 @@ public class config {
|
||||||
public static boolean fullBlocksOn = defaults.fullBlocksOn;
|
public static boolean fullBlocksOn = defaults.fullBlocksOn;
|
||||||
public static boolean customOn = defaults.customOn;
|
public static boolean customOn = defaults.customOn;
|
||||||
public static List<String> customBlocks = defaults.customBlocks;
|
public static List<String> customBlocks = defaults.customBlocks;
|
||||||
enum HandRequirement {
|
public enum HandRequirement {
|
||||||
empty,
|
empty,
|
||||||
restrictive,
|
restrictive,
|
||||||
none;
|
none;
|
||||||
|
@ -62,17 +67,35 @@ public class config {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.load(fileStream);
|
properties.load(fileStream);
|
||||||
String ver = (String) properties.computeIfAbsent("version", a -> String.valueOf(defaults.version));
|
String ver = (String) properties.computeIfAbsent("version", a -> String.valueOf(defaults.version));
|
||||||
// if the old version system (v1.0) remove "v:
|
|
||||||
|
// if the old version system (v1.0) remove "v"
|
||||||
if (ver.contains("v")) ver = ver.substring(1);
|
if (ver.contains("v")) ver = ver.substring(1);
|
||||||
|
|
||||||
loadVersion(properties,Double.parseDouble(ver));
|
loadVersion(properties,Double.parseDouble(ver));
|
||||||
LangReader.loadLanguageFile();
|
LangReader.loadLanguageFile();
|
||||||
|
|
||||||
save();
|
save();
|
||||||
} catch (Exception f) {
|
} catch (Exception e) {
|
||||||
//read fail
|
//read fail
|
||||||
f.printStackTrace();
|
e.printStackTrace();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static ArrayList<String> validateCustomBlocks(ArrayList<String> fix) {
|
||||||
|
ArrayList<String> out = new ArrayList<>();
|
||||||
|
for (String entry : fix) {
|
||||||
|
String[] split = entry.split("\\|");
|
||||||
|
// skip if not the right size
|
||||||
|
if (split.length < 3 || split.length > 4) continue;
|
||||||
|
// keep going if that block exists
|
||||||
|
// if (Registries.BLOCK.stream().anyMatch(match -> Registries.BLOCK.getId(match).toString().equals(split[0]))) {}
|
||||||
|
// if the other entries aren't correct, skip
|
||||||
|
if (!Num.isFloat(split[1]) || !Num.isInt(split[2])) continue;
|
||||||
|
// add if everything is a okay
|
||||||
|
out.add(entry);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
public static void loadVersion(Properties properties, double version) {
|
public static void loadVersion(Properties properties, double version) {
|
||||||
try {
|
try {
|
||||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||||
|
@ -86,17 +109,23 @@ public class config {
|
||||||
carpetsOn = Boolean.parseBoolean((String) properties.computeIfAbsent("carpets", a -> String.valueOf(defaults.carpetsOn)));
|
carpetsOn = Boolean.parseBoolean((String) properties.computeIfAbsent("carpets", a -> String.valueOf(defaults.carpetsOn)));
|
||||||
fullBlocksOn = Boolean.parseBoolean((String) properties.computeIfAbsent("full-blocks", a -> String.valueOf(defaults.fullBlocksOn)));
|
fullBlocksOn = Boolean.parseBoolean((String) properties.computeIfAbsent("full-blocks", a -> String.valueOf(defaults.fullBlocksOn)));
|
||||||
customOn = Boolean.parseBoolean((String) properties.computeIfAbsent("custom", a -> String.valueOf(defaults.customOn)));
|
customOn = Boolean.parseBoolean((String) properties.computeIfAbsent("custom", a -> String.valueOf(defaults.customOn)));
|
||||||
customBlocks = new Gson().fromJson((String)
|
try {
|
||||||
properties.computeIfAbsent("custom-blocks", a -> gson.toJson(defaults.customBlocks)), listType);
|
customBlocks = validateCustomBlocks(new Gson().fromJson((String)
|
||||||
mainReq = HandRequirement.valueOf((String) properties.computeIfAbsent("hand.main.requirement", a -> String.valueOf(defaults.mainReq)));
|
properties.computeIfAbsent("custom-blocks", a -> gson.toJson(defaults.customBlocks)), listType));
|
||||||
|
} catch (JsonSyntaxException ignore) {}
|
||||||
|
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)));
|
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)));
|
mainFood = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.main.food", a -> String.valueOf(defaults.mainFood)));
|
||||||
mainUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.main.usable", a -> String.valueOf(defaults.mainUsable)));
|
mainUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.main.usable", a -> String.valueOf(defaults.mainUsable)));
|
||||||
mainWhitelist = new Gson().fromJson((String)
|
try {
|
||||||
properties.computeIfAbsent("hand.main.whitelist", a -> gson.toJson(defaults.mainWhitelist)), listType);
|
mainWhitelist = new Gson().fromJson((String)
|
||||||
mainBlacklist = new Gson().fromJson((String)
|
properties.computeIfAbsent("hand.main.whitelist", a -> gson.toJson(defaults.mainWhitelist)), listType);
|
||||||
properties.computeIfAbsent("hand.main.blacklist", a -> gson.toJson(defaults.mainBlacklist)), listType);
|
} catch (JsonSyntaxException ignore) {}
|
||||||
offReq = HandRequirement.valueOf((String) properties.computeIfAbsent("hand.off.requirement", a -> String.valueOf(defaults.offReq)));
|
try {
|
||||||
|
mainBlacklist = new Gson().fromJson((String)
|
||||||
|
properties.computeIfAbsent("hand.main.blacklist", a -> gson.toJson(defaults.mainBlacklist)), listType);
|
||||||
|
} catch (JsonSyntaxException ignore) {}
|
||||||
|
offReq = HandRequirement.get((String) properties.computeIfAbsent("hand.off.requirement", a -> String.valueOf(defaults.offReq)));
|
||||||
offBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.off.block", a -> String.valueOf(defaults.offBlock)));
|
offBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.off.block", a -> String.valueOf(defaults.offBlock)));
|
||||||
offFood = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.off.food", a -> String.valueOf(defaults.offFood)));
|
offFood = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.off.food", a -> String.valueOf(defaults.offFood)));
|
||||||
offUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.off.usable", a -> String.valueOf(defaults.offUsable)));
|
offUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("hand.off.usable", a -> String.valueOf(defaults.offUsable)));
|
||||||
|
@ -105,22 +134,30 @@ public class config {
|
||||||
offBlacklist = new Gson().fromJson((String)
|
offBlacklist = new Gson().fromJson((String)
|
||||||
properties.computeIfAbsent("hand.off.blacklist", a -> gson.toJson(defaults.offBlacklist)), listType);
|
properties.computeIfAbsent("hand.off.blacklist", a -> gson.toJson(defaults.offBlacklist)), listType);
|
||||||
if (version == 1.0) {
|
if (version == 1.0) {
|
||||||
mainReq = HandRequirement.valueOf((String) properties.computeIfAbsent("main-hand-requirement", a -> String.valueOf(defaults.mainReq)));
|
mainReq = HandRequirement.get((String) properties.computeIfAbsent("main-hand-requirement", a -> String.valueOf(defaults.mainReq)));
|
||||||
mainBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("main-hand-block", a -> String.valueOf(defaults.mainBlock)));
|
mainBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("main-hand-block", a -> String.valueOf(defaults.mainBlock)));
|
||||||
mainFood = Boolean.parseBoolean((String) properties.computeIfAbsent("main-hand-food", a -> String.valueOf(defaults.mainFood)));
|
mainFood = Boolean.parseBoolean((String) properties.computeIfAbsent("main-hand-food", a -> String.valueOf(defaults.mainFood)));
|
||||||
mainUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("main-hand-usable", a -> String.valueOf(defaults.mainUsable)));
|
mainUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("main-hand-usable", a -> String.valueOf(defaults.mainUsable)));
|
||||||
mainWhitelist = new Gson().fromJson((String)
|
try {
|
||||||
properties.computeIfAbsent("main-hand-whitelist", a -> gson.toJson(defaults.mainWhitelist)), listType);
|
mainWhitelist = new Gson().fromJson((String)
|
||||||
mainBlacklist = new Gson().fromJson((String)
|
properties.computeIfAbsent("main-hand-whitelist", a -> gson.toJson(defaults.mainWhitelist)), listType);
|
||||||
properties.computeIfAbsent("main-hand-blacklist", a -> gson.toJson(defaults.mainBlacklist)), listType);
|
} catch (JsonSyntaxException ignore) {}
|
||||||
offReq = HandRequirement.valueOf((String) properties.computeIfAbsent("off-hand-requirement", a -> String.valueOf(defaults.offReq)));
|
try {
|
||||||
|
mainBlacklist = new Gson().fromJson((String)
|
||||||
|
properties.computeIfAbsent("main-hand-blacklist", a -> gson.toJson(defaults.mainBlacklist)), listType);
|
||||||
|
} catch (JsonSyntaxException ignore) {}
|
||||||
|
offReq = HandRequirement.get((String) properties.computeIfAbsent("off-hand-requirement", a -> String.valueOf(defaults.offReq)));
|
||||||
offBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("off-hand-block", a -> String.valueOf(defaults.offBlock)));
|
offBlock = Boolean.parseBoolean((String) properties.computeIfAbsent("off-hand-block", a -> String.valueOf(defaults.offBlock)));
|
||||||
offFood = Boolean.parseBoolean((String) properties.computeIfAbsent("off-hand-food", a -> String.valueOf(defaults.offFood)));
|
offFood = Boolean.parseBoolean((String) properties.computeIfAbsent("off-hand-food", a -> String.valueOf(defaults.offFood)));
|
||||||
offUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("off-hand-usable", a -> String.valueOf(defaults.offUsable)));
|
offUsable = Boolean.parseBoolean((String) properties.computeIfAbsent("off-hand-usable", a -> String.valueOf(defaults.offUsable)));
|
||||||
offWhitelist = new Gson().fromJson((String)
|
try {
|
||||||
properties.computeIfAbsent("off-hand-whitelist", a -> gson.toJson(defaults.offWhitelist)), listType);
|
offWhitelist = new Gson().fromJson((String)
|
||||||
offBlacklist = new Gson().fromJson((String)
|
properties.computeIfAbsent("off-hand-whitelist", a -> gson.toJson(defaults.offWhitelist)), listType);
|
||||||
properties.computeIfAbsent("off-hand-blacklist", a -> gson.toJson(defaults.offBlacklist)), listType);
|
} catch (JsonSyntaxException ignore) {}
|
||||||
|
try {
|
||||||
|
offBlacklist = new Gson().fromJson((String)
|
||||||
|
properties.computeIfAbsent("off-hand-blacklist", a -> gson.toJson(defaults.offBlacklist)), listType);
|
||||||
|
} catch (JsonSyntaxException ignore) {}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Sit.LOGGER.info("ERROR LOADING CONFIG - PLEASE REPORT WITH THE ERROR LOG");
|
Sit.LOGGER.info("ERROR LOADING CONFIG - PLEASE REPORT WITH THE ERROR LOG");
|
||||||
|
@ -191,7 +228,7 @@ public class config {
|
||||||
public static boolean carpetsOn = true;
|
public static boolean carpetsOn = true;
|
||||||
public static boolean fullBlocksOn = false;
|
public static boolean fullBlocksOn = false;
|
||||||
public static boolean customOn = 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");
|
public static List<String> customBlocks = List.of("minecraft:campfire|.46|1|lit=false","minecraft:soul_campfire|.46|1|lit=false,waterlogged=false");
|
||||||
public static HandRequirement mainReq = HandRequirement.empty;
|
public static HandRequirement mainReq = HandRequirement.empty;
|
||||||
public static boolean mainBlock = false;
|
public static boolean mainBlock = false;
|
||||||
public static boolean mainFood = false;
|
public static boolean mainFood = false;
|
Loading…
Add table
Add a link
Reference in a new issue