Merge branch 'master' into snapshot

# Conflicts:
#	gradle.properties
#	src/main/java/one/oth3r/sit/ModMenu.java
#	src/main/resources/fabric.mod.json
This commit is contained in:
Oth3r 2024-01-17 14:10:45 -06:00
commit 7365b31f66
11 changed files with 105 additions and 61 deletions

View file

@ -159,10 +159,12 @@ public class Events {
}
}
}
entity.updatePositionAndAngles(entity.getX(),entity.getY(),entity.getZ(),0,0);
//1.20.2 mounting pos change (shifts everything down by .25)
double oneTwentyTwo = .25;
entity.updatePositionAndAngles(entity.getX(),entity.getY()+oneTwentyTwo,entity.getZ(),0,0);
entity.setBoundingBox(Box.of(Vec3d.of(pos),1.5,hitBoxY,1.5));
//change pitch based on if player is sitting below block height or not
if (entity.getY() <= pos.getY()+.35) entity.setPitch(90); // below
if (entity.getY() <= pos.getY()+.35+oneTwentyTwo) entity.setPitch(90); // below
else entity.setPitch(-90); // above
}
public static void register() {

View file

View file

@ -1,5 +1,6 @@
package one.oth3r.sit;
import io.netty.buffer.ByteBuf;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.minecraft.network.PacketByteBuf;
@ -11,11 +12,11 @@ import java.nio.charset.StandardCharsets;
public class PacketBuilder {
public static final String SETTINGS = "settings_v1.0";
private final String message;
private PacketByteBuf packetByteBuf = PacketByteBufs.create();
public PacketBuilder(PacketByteBuf buf) {
private final PacketByteBuf packetByteBuf = PacketByteBufs.create();
public PacketBuilder(ByteBuf buf) {
// Read any data sent in the packet
message = buf.toString(StandardCharsets.UTF_8);
packetByteBuf = buf;
packetByteBuf.writeBytes(buf);
}
public PacketBuilder(String message) {
this.message = message;

View file

@ -41,7 +41,8 @@ public class Sit implements ModInitializer {
//PACKETS
ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(),
(server, player, handler, buf, responseSender) -> {
PacketBuilder packet = new PacketBuilder(buf);
// copy to not throw errors
PacketBuilder packet = new PacketBuilder(buf.copy());
server.execute(() -> {
Type hashMapToken = new TypeToken<HashMap<String, Object>>() {}.getType();
Gson gson = new GsonBuilder().disableHtmlEscaping().create();

View file

@ -134,51 +134,47 @@ public class config {
try (var file = Files.newBufferedWriter(configFile().toPath(), StandardCharsets.UTF_8)) {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
file.write("# Sit! Config\n");
file.write(("\nversion="+defaults.version));
file.write(("\n# all available languages: en_us, ru_ru"));
file.write(("\nlang=" + lang));
file.write(("\n\n# "+lang("general.keep_active.description")));
file.write(("\nkeep-active=" + keepActive));
file.write(("\n# "+lang("general.sit_while_seated.description")));
file.write(("\nsit-while-seated=" + sitWhileSeated));
file.write(("\n# "+lang("general.sittable.description")));
file.write(("\nstairs=" + stairsOn));
file.write(("\nslabs=" + slabsOn));
file.write(("\ncarpets=" + carpetsOn));
file.write(("\nfull-blocks=" + fullBlocksOn));
file.write(("\ncustom=" + customOn));
file.write(("\n# "+Sit.lang("config.sit."+
file.write("\nversion="+defaults.version);
file.write("\n# all available languages: en_us, ru_ru, es_es");
file.write("\nlang=" + lang);
file.write("\n\n# "+lang("general.keep_active.description"));
file.write("\nkeep-active=" + keepActive);
file.write("\n# "+lang("general.sit_while_seated.description"));
file.write("\nsit-while-seated=" + sitWhileSeated);
file.write("\n# "+lang("general.sittable.description"));
file.write("\nstairs=" + stairsOn);
file.write("\nslabs=" + slabsOn);
file.write("\ncarpets=" + carpetsOn);
file.write("\nfull-blocks=" + fullBlocksOn);
file.write("\ncustom=" + customOn);
file.write("\n# "+Sit.lang("config.sit."+
"general.sittable_blocks.description")
.append("\n# ").append(lang("general.sittable_blocks.description_2"))
.append(lang("general.sittable_blocks.description_3",
lang("general.sittable_blocks.description_3_2"),
lang("general.sittable_blocks.description_3_3"),
lang("general.sittable_blocks.description_3_4"),
lang("general.sittable_blocks.description_3_5")))
.append("\n# ").append(lang("general.sittable_blocks.description_2",
"\"minecraft:campfire|0.255|1|lit=false\""))
.append("\n# ").append(lang("general.sittable_blocks.description_4"))
.append("\n# ").append(lang("general.sittable_blocks.description_5"))
.append("\n# ").append(lang("general.sittable_blocks.description_6"))
.append("\n# ").append(lang("general.sittable_blocks.description_7"))
.append("\n# ").append(lang("general.sittable_blocks.description_8"))));
file.write(("\ncustom-blocks="+gson.toJson(customBlocks)));
file.write(("\n\n# "+lang("hand")));
file.write(("\n# "+Sit.lang("config.sit."+
.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("\n# "+Sit.lang("config.sit."+
"hand.requirements.description")
.append("\n# ").append(lang("hand.requirements.description_2"))
.append("\n# ").append(lang("hand.requirements.description_3"))
.append("\n# ").append(lang("hand.requirements.description_4"))));
file.write(("\nhand.main.requirement=" + mainReq));
file.write(("\nhand.main.block=" + mainBlock));
file.write(("\nhand.main.food=" + mainFood));
file.write(("\nhand.main.usable=" + mainUsable));
file.write(("\nhand.main.whitelist="+gson.toJson(mainWhitelist)));
file.write(("\nhand.main.blacklist="+gson.toJson(mainBlacklist)));
file.write(("\nhand.off.requirement=" + offReq));
file.write(("\nhand.off.block=" + offBlock));
file.write(("\nhand.off.food=" + offFood));
file.write(("\nhand.off.usable=" + offUsable));
file.write(("\nhand.off.whitelist="+gson.toJson(offWhitelist)));
file.write(("\nhand.off.blacklist="+gson.toJson(offBlacklist)));
.append("\n# ").append(lang("hand.requirements.description_4")).getString());
file.write("\nhand.main.requirement=" + mainReq);
file.write("\nhand.main.block=" + mainBlock);
file.write("\nhand.main.food=" + mainFood);
file.write("\nhand.main.usable=" + mainUsable);
file.write("\nhand.main.whitelist="+gson.toJson(mainWhitelist));
file.write("\nhand.main.blacklist="+gson.toJson(mainBlacklist));
file.write("\nhand.off.requirement=" + offReq);
file.write("\nhand.off.block=" + offBlock);
file.write("\nhand.off.food=" + offFood);
file.write("\nhand.off.usable=" + offUsable);
file.write("\nhand.off.whitelist="+gson.toJson(offWhitelist));
file.write("\nhand.off.blacklist="+gson.toJson(offBlacklist));
// send packets to update the settings on the server
if (SitClient.inGame) SitClient.sendPackets();
} catch (Exception e) {