From a470896924bda96887f37cfbe59995a61d595ebf Mon Sep 17 00:00:00 2001 From: Oth3r Date: Tue, 5 Dec 2023 14:21:01 -0600 Subject: [PATCH 01/30] fix config not commenting correctly (cherry picked from commit 5cfa1069664d0f9ea6b07012a51c63cc336f5ed8) --- src/main/java/one/oth3r/sit/config.java | 62 ++++++++++++------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/one/oth3r/sit/config.java b/src/main/java/one/oth3r/sit/config.java index 2f67973..70410bb 100644 --- a/src/main/java/one/oth3r/sit/config.java +++ b/src/main/java/one/oth3r/sit/config.java @@ -134,20 +134,20 @@ 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"); + 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", @@ -159,26 +159,26 @@ public class config { .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) { From 4eef33e6aee35ab1fd29271aab3f5de9b62f8784 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Tue, 5 Dec 2023 14:55:17 -0600 Subject: [PATCH 02/30] v1.1.1+1.20-1.20.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index d90c86e..59959cf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10 loader_version=0.14.24 # Mod Properties -mod_version=1.1.0+1.20-1.20.1 +mod_version=1.1.1+1.20-1.20.1 maven_group=one.oth3r archives_base_name=sit! From 61940e95db7913bcc6f567652513b70f7d556834 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 8 Jan 2024 12:01:05 -0600 Subject: [PATCH 03/30] Revert "fixed sitting height update for 1.20.2+" This reverts commit 9b51b1c0ec46bfbca9a671f9f82f12751938a154. --- src/main/java/one/oth3r/sit/Events.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/one/oth3r/sit/Events.java b/src/main/java/one/oth3r/sit/Events.java index 9fd9ef8..444e023 100644 --- a/src/main/java/one/oth3r/sit/Events.java +++ b/src/main/java/one/oth3r/sit/Events.java @@ -159,12 +159,10 @@ public class Events { } } } - //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.updatePositionAndAngles(entity.getX(),entity.getY(),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+oneTwentyTwo) entity.setPitch(90); // below + if (entity.getY() <= pos.getY()+.35) entity.setPitch(90); // below else entity.setPitch(-90); // above } public static void register() { From 86676dd0a19a6bb965e0721c0de1b6cc45cb87f3 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 8 Jan 2024 12:04:33 -0600 Subject: [PATCH 04/30] v1.1.3+1.20-1.20.1 --- src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 773137f..9d6b837 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ }, "depends": { "fabricloader": ">=0.14.21", - "minecraft": ">=1.20.2 <=1.20.4", + "minecraft": ">=1.20 <=1.20.1", "java": ">=17", "fabric-api": "*" }, From df46547cbff496359b4e22b05c62011bfc01ecba Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 29 Apr 2024 12:28:30 -0500 Subject: [PATCH 05/30] Revert "updated packet system" This reverts commit 2e02d67c8e0409c4a63494065fdc5c4e858d1f9d. --- src/main/java/one/oth3r/sit/Sit.java | 30 +++++++++++++------ src/main/java/one/oth3r/sit/SitClient.java | 4 +-- .../one/oth3r/sit/packet/CustomPayloads.java | 27 ----------------- 3 files changed, 22 insertions(+), 39 deletions(-) delete mode 100644 src/main/java/one/oth3r/sit/packet/CustomPayloads.java diff --git a/src/main/java/one/oth3r/sit/Sit.java b/src/main/java/one/oth3r/sit/Sit.java index 268dfb1..7ba996d 100644 --- a/src/main/java/one/oth3r/sit/Sit.java +++ b/src/main/java/one/oth3r/sit/Sit.java @@ -7,13 +7,17 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.network.codec.PacketCodecs; +import net.minecraft.network.packet.CustomPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandManager; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.MutableText; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import one.oth3r.sit.file.Config; -import one.oth3r.sit.packet.CustomPayloads; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,15 +41,23 @@ public class Sit implements ModInitializer { Config.load(); Events.register(); //PACKETS - PayloadTypeRegistry.playC2S().register(CustomPayloads.SettingsPayload.ID, CustomPayloads.SettingsPayload.CODEC); - ServerPlayNetworking.registerGlobalReceiver(CustomPayloads.SettingsPayload.ID,((payload, context) -> server.execute(() -> { - Type hashMapToken = new TypeToken>() {}.getType(); - Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - - playerSettings.put(context.player(),gson.fromJson(payload.value(),hashMapToken)); - }))); + PayloadTypeRegistry.playC2S().register(SettingsPayload.ID, SettingsPayload.CODEC); + ServerPlayNetworking.registerGlobalReceiver(SettingsPayload.ID,((payload, context) -> { + server.execute(() -> { + Type hashMapToken = new TypeToken>() {}.getType(); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + playerSettings.put(context.player(),gson.fromJson(payload.value,hashMapToken)); + }); + })); + } + public record SettingsPayload(String value) implements CustomPayload { + public static final CustomPayload.Id ID = new CustomPayload.Id<>(new Identifier(MOD_ID,"settings_v1.1")); + public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); + @Override + public Id getId() { + return ID; + } } - public static MutableText lang(String key, Object... args) { if (isClient) return Text.translatable(key, args); else return LangReader.of(key, args).getTxT(); diff --git a/src/main/java/one/oth3r/sit/SitClient.java b/src/main/java/one/oth3r/sit/SitClient.java index fe6dbb3..555bd09 100644 --- a/src/main/java/one/oth3r/sit/SitClient.java +++ b/src/main/java/one/oth3r/sit/SitClient.java @@ -6,7 +6,6 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.network.packet.CustomPayload; -import one.oth3r.sit.packet.CustomPayloads; public class SitClient implements ClientModInitializer { public static boolean inGame = false; @@ -21,9 +20,8 @@ public class SitClient implements ClientModInitializer { // reset inGame ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false); } - public static CustomPayload sendPackets() { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - return new CustomPayloads.SettingsPayload(gson.toJson(Utl.HandSettings.getHandSettings())); + return new Sit.SettingsPayload(gson.toJson(Utl.getHandSettings())); } } diff --git a/src/main/java/one/oth3r/sit/packet/CustomPayloads.java b/src/main/java/one/oth3r/sit/packet/CustomPayloads.java deleted file mode 100644 index 9d6a57d..0000000 --- a/src/main/java/one/oth3r/sit/packet/CustomPayloads.java +++ /dev/null @@ -1,27 +0,0 @@ -package one.oth3r.sit.packet; - -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; -import one.oth3r.sit.Sit; - -public class CustomPayloads { - public record SettingsPayload(String value) implements CustomPayload { - - public static final Id ID = new Id<>(new Identifier(Sit.MOD_ID,"settings_v1.1")); - - public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); - - @Override - public Id getId() { - return ID; - } - - @Override - public String value() { - return value; - } - } -} From 648f20e5dbdc9670e06c0370ef93c5393158c809 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 29 Apr 2024 12:28:30 -0500 Subject: [PATCH 06/30] Revert "new packet system 1.20.5" This reverts commit fdd7aeaf4fb56464efab7987bf8d04680a5d42a3. --- .../java/one/oth3r/sit/PacketBuilder.java | 35 +++++++++++++++++++ src/main/java/one/oth3r/sit/Sit.java | 30 +++++----------- src/main/java/one/oth3r/sit/SitClient.java | 8 ++--- 3 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 src/main/java/one/oth3r/sit/PacketBuilder.java diff --git a/src/main/java/one/oth3r/sit/PacketBuilder.java b/src/main/java/one/oth3r/sit/PacketBuilder.java new file mode 100644 index 0000000..6afb6cf --- /dev/null +++ b/src/main/java/one/oth3r/sit/PacketBuilder.java @@ -0,0 +1,35 @@ +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; +import net.minecraft.util.Identifier; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + +public class PacketBuilder { + public static final String SETTINGS = "settings_v1.0"; + private final String message; + private final PacketByteBuf packetByteBuf = PacketByteBufs.create(); + public PacketBuilder(ByteBuf buf) { + // Read any data sent in the packet + message = buf.toString(StandardCharsets.UTF_8); + packetByteBuf.writeBytes(buf); + } + public PacketBuilder(String message) { + this.message = message; + packetByteBuf.writeBytes(ByteBuffer.wrap(message.getBytes(StandardCharsets.UTF_8)).array()); + } + public static Identifier getIdentifier() { + // only 1 packet rn + return new Identifier(Sit.MOD_ID, SETTINGS); + } + public void send() { + ClientPlayNetworking.send(getIdentifier(), packetByteBuf); + } + public String getMessage() { + return this.message; + } +} diff --git a/src/main/java/one/oth3r/sit/Sit.java b/src/main/java/one/oth3r/sit/Sit.java index 7ba996d..8b1f44a 100644 --- a/src/main/java/one/oth3r/sit/Sit.java +++ b/src/main/java/one/oth3r/sit/Sit.java @@ -5,18 +5,12 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandManager; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; import one.oth3r.sit.file.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,22 +35,16 @@ public class Sit implements ModInitializer { Config.load(); Events.register(); //PACKETS - PayloadTypeRegistry.playC2S().register(SettingsPayload.ID, SettingsPayload.CODEC); - ServerPlayNetworking.registerGlobalReceiver(SettingsPayload.ID,((payload, context) -> { + ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(), + (server, player, handler, buf, responseSender) -> { + // copy to not throw errors + PacketBuilder packet = new PacketBuilder(buf.copy()); server.execute(() -> { - Type hashMapToken = new TypeToken>() {}.getType(); - Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - playerSettings.put(context.player(),gson.fromJson(payload.value,hashMapToken)); - }); - })); - } - public record SettingsPayload(String value) implements CustomPayload { - public static final CustomPayload.Id ID = new CustomPayload.Id<>(new Identifier(MOD_ID,"settings_v1.1")); - public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); - @Override - public Id getId() { - return ID; - } + Type hashMapToken = new TypeToken>() {}.getType(); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + playerSettings.put(player,gson.fromJson(packet.getMessage(),hashMapToken)); + }); + }); } public static MutableText lang(String key, Object... args) { if (isClient) return Text.translatable(key, args); diff --git a/src/main/java/one/oth3r/sit/SitClient.java b/src/main/java/one/oth3r/sit/SitClient.java index 555bd09..d8285fb 100644 --- a/src/main/java/one/oth3r/sit/SitClient.java +++ b/src/main/java/one/oth3r/sit/SitClient.java @@ -4,8 +4,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.minecraft.network.packet.CustomPayload; public class SitClient implements ClientModInitializer { public static boolean inGame = false; @@ -15,13 +13,13 @@ public class SitClient implements ClientModInitializer { ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { inGame = true; // send a data packet whenever joining a server - ClientPlayNetworking.send(sendPackets()); + client.execute(SitClient::sendPackets); }); // reset inGame ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false); } - public static CustomPayload sendPackets() { + public static void sendPackets() { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - return new Sit.SettingsPayload(gson.toJson(Utl.getHandSettings())); + new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send(); } } From 322b663358d48048245e5aad48e3ef85eded89e0 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 29 Apr 2024 12:36:44 -0500 Subject: [PATCH 07/30] 1.1.5+1.20.2-1.20.4 --- gradle.properties | 12 ++++++------ src/main/resources/fabric.mod.json | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 63e430d..dca65e0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,16 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.1 +minecraft_version=1.20.4 +yarn_mappings=1.20.4+build.3 loader_version=0.15.10 # Mod Properties -mod_version=1.1.5+1.20.6 +mod_version=1.1.5+1.20.2-1.20.4 maven_group=one.oth3r archives_base_name=sit! # Dependencies -fabric_version=0.97.8+1.20.6 -modmenu_version=10.0.0-beta.1 -yacl_version=3.4.1+1.20.5-fabric +fabric_version=0.97.0+1.20.4 +modmenu_version=9.0.0 +yacl_version=3.4.1+1.20.4-fabric diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 89b9ac9..773137f 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ }, "depends": { "fabricloader": ">=0.14.21", - "minecraft": ">=1.20.6 <=1.20.6", + "minecraft": ">=1.20.2 <=1.20.4", "java": ">=17", "fabric-api": "*" }, From be158c66ed81b8d4c3349b14cab007e41ffb5233 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 29 Apr 2024 12:38:32 -0500 Subject: [PATCH 08/30] Revert "updated packet system" This reverts commit 2e02d67c8e0409c4a63494065fdc5c4e858d1f9d. --- src/main/java/one/oth3r/sit/Sit.java | 30 +++++++++++++------ src/main/java/one/oth3r/sit/SitClient.java | 4 +-- .../one/oth3r/sit/packet/CustomPayloads.java | 27 ----------------- 3 files changed, 22 insertions(+), 39 deletions(-) delete mode 100644 src/main/java/one/oth3r/sit/packet/CustomPayloads.java diff --git a/src/main/java/one/oth3r/sit/Sit.java b/src/main/java/one/oth3r/sit/Sit.java index 268dfb1..7ba996d 100644 --- a/src/main/java/one/oth3r/sit/Sit.java +++ b/src/main/java/one/oth3r/sit/Sit.java @@ -7,13 +7,17 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.network.codec.PacketCodecs; +import net.minecraft.network.packet.CustomPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandManager; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.MutableText; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import one.oth3r.sit.file.Config; -import one.oth3r.sit.packet.CustomPayloads; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,15 +41,23 @@ public class Sit implements ModInitializer { Config.load(); Events.register(); //PACKETS - PayloadTypeRegistry.playC2S().register(CustomPayloads.SettingsPayload.ID, CustomPayloads.SettingsPayload.CODEC); - ServerPlayNetworking.registerGlobalReceiver(CustomPayloads.SettingsPayload.ID,((payload, context) -> server.execute(() -> { - Type hashMapToken = new TypeToken>() {}.getType(); - Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - - playerSettings.put(context.player(),gson.fromJson(payload.value(),hashMapToken)); - }))); + PayloadTypeRegistry.playC2S().register(SettingsPayload.ID, SettingsPayload.CODEC); + ServerPlayNetworking.registerGlobalReceiver(SettingsPayload.ID,((payload, context) -> { + server.execute(() -> { + Type hashMapToken = new TypeToken>() {}.getType(); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + playerSettings.put(context.player(),gson.fromJson(payload.value,hashMapToken)); + }); + })); + } + public record SettingsPayload(String value) implements CustomPayload { + public static final CustomPayload.Id ID = new CustomPayload.Id<>(new Identifier(MOD_ID,"settings_v1.1")); + public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); + @Override + public Id getId() { + return ID; + } } - public static MutableText lang(String key, Object... args) { if (isClient) return Text.translatable(key, args); else return LangReader.of(key, args).getTxT(); diff --git a/src/main/java/one/oth3r/sit/SitClient.java b/src/main/java/one/oth3r/sit/SitClient.java index fe6dbb3..555bd09 100644 --- a/src/main/java/one/oth3r/sit/SitClient.java +++ b/src/main/java/one/oth3r/sit/SitClient.java @@ -6,7 +6,6 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.network.packet.CustomPayload; -import one.oth3r.sit.packet.CustomPayloads; public class SitClient implements ClientModInitializer { public static boolean inGame = false; @@ -21,9 +20,8 @@ public class SitClient implements ClientModInitializer { // reset inGame ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false); } - public static CustomPayload sendPackets() { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - return new CustomPayloads.SettingsPayload(gson.toJson(Utl.HandSettings.getHandSettings())); + return new Sit.SettingsPayload(gson.toJson(Utl.getHandSettings())); } } diff --git a/src/main/java/one/oth3r/sit/packet/CustomPayloads.java b/src/main/java/one/oth3r/sit/packet/CustomPayloads.java deleted file mode 100644 index 9d6a57d..0000000 --- a/src/main/java/one/oth3r/sit/packet/CustomPayloads.java +++ /dev/null @@ -1,27 +0,0 @@ -package one.oth3r.sit.packet; - -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; -import one.oth3r.sit.Sit; - -public class CustomPayloads { - public record SettingsPayload(String value) implements CustomPayload { - - public static final Id ID = new Id<>(new Identifier(Sit.MOD_ID,"settings_v1.1")); - - public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); - - @Override - public Id getId() { - return ID; - } - - @Override - public String value() { - return value; - } - } -} From 4ec37db7b0dc5f71fc93e97c5a7107f27c3fd8b1 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 29 Apr 2024 12:38:33 -0500 Subject: [PATCH 09/30] Revert "new packet system 1.20.5" This reverts commit fdd7aeaf4fb56464efab7987bf8d04680a5d42a3. --- .../java/one/oth3r/sit/PacketBuilder.java | 35 +++++++++++++++++++ src/main/java/one/oth3r/sit/Sit.java | 30 +++++----------- src/main/java/one/oth3r/sit/SitClient.java | 8 ++--- 3 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 src/main/java/one/oth3r/sit/PacketBuilder.java diff --git a/src/main/java/one/oth3r/sit/PacketBuilder.java b/src/main/java/one/oth3r/sit/PacketBuilder.java new file mode 100644 index 0000000..6afb6cf --- /dev/null +++ b/src/main/java/one/oth3r/sit/PacketBuilder.java @@ -0,0 +1,35 @@ +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; +import net.minecraft.util.Identifier; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + +public class PacketBuilder { + public static final String SETTINGS = "settings_v1.0"; + private final String message; + private final PacketByteBuf packetByteBuf = PacketByteBufs.create(); + public PacketBuilder(ByteBuf buf) { + // Read any data sent in the packet + message = buf.toString(StandardCharsets.UTF_8); + packetByteBuf.writeBytes(buf); + } + public PacketBuilder(String message) { + this.message = message; + packetByteBuf.writeBytes(ByteBuffer.wrap(message.getBytes(StandardCharsets.UTF_8)).array()); + } + public static Identifier getIdentifier() { + // only 1 packet rn + return new Identifier(Sit.MOD_ID, SETTINGS); + } + public void send() { + ClientPlayNetworking.send(getIdentifier(), packetByteBuf); + } + public String getMessage() { + return this.message; + } +} diff --git a/src/main/java/one/oth3r/sit/Sit.java b/src/main/java/one/oth3r/sit/Sit.java index 7ba996d..8b1f44a 100644 --- a/src/main/java/one/oth3r/sit/Sit.java +++ b/src/main/java/one/oth3r/sit/Sit.java @@ -5,18 +5,12 @@ import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.CommandManager; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.MutableText; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; import one.oth3r.sit.file.Config; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,22 +35,16 @@ public class Sit implements ModInitializer { Config.load(); Events.register(); //PACKETS - PayloadTypeRegistry.playC2S().register(SettingsPayload.ID, SettingsPayload.CODEC); - ServerPlayNetworking.registerGlobalReceiver(SettingsPayload.ID,((payload, context) -> { + ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(), + (server, player, handler, buf, responseSender) -> { + // copy to not throw errors + PacketBuilder packet = new PacketBuilder(buf.copy()); server.execute(() -> { - Type hashMapToken = new TypeToken>() {}.getType(); - Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - playerSettings.put(context.player(),gson.fromJson(payload.value,hashMapToken)); - }); - })); - } - public record SettingsPayload(String value) implements CustomPayload { - public static final CustomPayload.Id ID = new CustomPayload.Id<>(new Identifier(MOD_ID,"settings_v1.1")); - public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); - @Override - public Id getId() { - return ID; - } + Type hashMapToken = new TypeToken>() {}.getType(); + Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + playerSettings.put(player,gson.fromJson(packet.getMessage(),hashMapToken)); + }); + }); } public static MutableText lang(String key, Object... args) { if (isClient) return Text.translatable(key, args); diff --git a/src/main/java/one/oth3r/sit/SitClient.java b/src/main/java/one/oth3r/sit/SitClient.java index 555bd09..d8285fb 100644 --- a/src/main/java/one/oth3r/sit/SitClient.java +++ b/src/main/java/one/oth3r/sit/SitClient.java @@ -4,8 +4,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; -import net.minecraft.network.packet.CustomPayload; public class SitClient implements ClientModInitializer { public static boolean inGame = false; @@ -15,13 +13,13 @@ public class SitClient implements ClientModInitializer { ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { inGame = true; // send a data packet whenever joining a server - ClientPlayNetworking.send(sendPackets()); + client.execute(SitClient::sendPackets); }); // reset inGame ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false); } - public static CustomPayload sendPackets() { + public static void sendPackets() { Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - return new Sit.SettingsPayload(gson.toJson(Utl.getHandSettings())); + new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send(); } } From 7eaf280a88a47e60bf39afeeef5b18fbdf28a525 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 29 Apr 2024 12:44:55 -0500 Subject: [PATCH 10/30] 1.1.5+1.20.1 --- gradle.properties | 2 +- src/main/resources/fabric.mod.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 5500d66..4fb2266 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10 loader_version=0.14.24 # Mod Properties -mod_version=1.1.4+1.20-1.20.1 +mod_version=1.1.5+1.20.1 maven_group=one.oth3r archives_base_name=sit! diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9d6b837..9e88f89 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ }, "depends": { "fabricloader": ">=0.14.21", - "minecraft": ">=1.20 <=1.20.1", + "minecraft": "=1.20.1", "java": ">=17", "fabric-api": "*" }, From f98436a9173e072b81e61e8fa4ca8e2776f14a6c Mon Sep 17 00:00:00 2001 From: Oth3r Date: Thu, 13 Jun 2024 11:05:10 -0500 Subject: [PATCH 11/30] Revert "1.21 changes" This reverts commit ca865974 --- src/main/java/one/oth3r/sit/Events.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/one/oth3r/sit/Events.java b/src/main/java/one/oth3r/sit/Events.java index fa5d50c..61a4c39 100644 --- a/src/main/java/one/oth3r/sit/Events.java +++ b/src/main/java/one/oth3r/sit/Events.java @@ -247,7 +247,7 @@ public class Events { BlockState blockState = player.getWorld().getBlockState(pos); // check if said block is still there if (blockState.isAir()) { - player.teleport(player.getX(),player.getBlockY()+1,player.getZ(),false); + player.teleport(player.getX(),player.getBlockY()+1,player.getZ()); entity.setRemoved(Entity.RemovalReason.DISCARDED); entityLoop.remove(); } From fa968f17c296aeaee6683fe74f4c461d6de62e08 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Thu, 13 Jun 2024 11:09:49 -0500 Subject: [PATCH 12/30] v1.1.6+1.20.4 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 479dcc0..03cd4be 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.parallel=true # check these on https://fabricmc.net/develop minecraft_version=1.20.4 yarn_mappings=1.20.4+build.3 -loader_version=0.15.10 +loader_version=0.15.11 # Mod Properties mod_version=1.1.6+1.20.4 @@ -14,6 +14,6 @@ maven_group=one.oth3r archives_base_name=sit! # Dependencies -fabric_version=0.97.0+1.20.4 +fabric_version=0.97.1+1.20.4 modmenu_version=9.0.0 yacl_version=3.4.1+1.20.4-fabric From af4ca45788fde4acc7b37a2fc977eabcf1fc2a5c Mon Sep 17 00:00:00 2001 From: Oth3r Date: Thu, 13 Jun 2024 14:28:25 -0500 Subject: [PATCH 13/30] v1.1.6+1.20.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4fb2266..abbfd30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10 loader_version=0.14.24 # Mod Properties -mod_version=1.1.5+1.20.1 +mod_version=1.1.6+1.20.1 maven_group=one.oth3r archives_base_name=sit! From a7b70323e48c6a94ad1303d1de6d44b7b1ff7423 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 22 Jul 2024 10:34:21 -0500 Subject: [PATCH 14/30] Revert "1.21 changes" This reverts commit ca86597498f4b1c128b0bacb4dce8bf36474ef36. --- src/main/java/one/oth3r/sit/Events.java | 2 +- src/main/java/one/oth3r/sit/packet/CustomPayloads.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/one/oth3r/sit/Events.java b/src/main/java/one/oth3r/sit/Events.java index a604bab..7371e3b 100644 --- a/src/main/java/one/oth3r/sit/Events.java +++ b/src/main/java/one/oth3r/sit/Events.java @@ -248,7 +248,7 @@ public class Events { BlockState blockState = player.getWorld().getBlockState(pos); // check if said block is still there if (blockState.isAir()) { - player.teleport(player.getX(),player.getBlockY()+1,player.getZ(),false); + player.teleport(player.getX(),player.getBlockY()+1,player.getZ()); entity.setRemoved(Entity.RemovalReason.DISCARDED); entityLoop.remove(); } diff --git a/src/main/java/one/oth3r/sit/packet/CustomPayloads.java b/src/main/java/one/oth3r/sit/packet/CustomPayloads.java index 7d1fea9..9d6a57d 100644 --- a/src/main/java/one/oth3r/sit/packet/CustomPayloads.java +++ b/src/main/java/one/oth3r/sit/packet/CustomPayloads.java @@ -10,7 +10,7 @@ import one.oth3r.sit.Sit; public class CustomPayloads { public record SettingsPayload(String value) implements CustomPayload { - public static final Id ID = new Id<>(Identifier.of(Sit.MOD_ID,"settings_v1.1")); + public static final Id ID = new Id<>(new Identifier(Sit.MOD_ID,"settings_v1.1")); public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); From ada03ba40e3c2a0e511bea1cbf1c0b03159fbe56 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 22 Jul 2024 10:39:47 -0500 Subject: [PATCH 15/30] v1.1.8+1.20.6 --- gradle.properties | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 294ae81..832f796 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,16 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.21 -yarn_mappings=1.21+build.1 +minecraft_version=1.20.6 +yarn_mappings=1.20.6+build.3 loader_version=0.15.11 # Mod Properties -mod_version=1.1.8+1.21 +mod_version=1.1.8+1.20.6 maven_group=one.oth3r archives_base_name=sit! # Dependencies -fabric_version=0.100.1+1.21 -modmenu_version=11.0.0-beta.1 -yacl_version=3.5.0+1.21-fabric +fabric_version=0.100.4+1.20.6 +modmenu_version=10.0.0-beta.1 +yacl_version=3.5.0+1.20.6-fabric From 1368650a49d6ba7dc39d7ccebaa3fb30fb841d24 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 22 Jul 2024 10:45:37 -0500 Subject: [PATCH 16/30] v1.1.8+1.20.4 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 03cd4be..445061d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.4+build.3 loader_version=0.15.11 # Mod Properties -mod_version=1.1.6+1.20.4 +mod_version=1.1.8+1.20.4 maven_group=one.oth3r archives_base_name=sit! From 7bf178a1d254b006536db0501a38fa26d69fb1fb Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sat, 24 Aug 2024 17:09:10 -0500 Subject: [PATCH 17/30] fix multi version fabric json --- src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b311131..95deb70 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -27,7 +27,7 @@ }, "depends": { "fabricloader": ">=0.14.21", - "minecraft": ">=1.21 <=${minecraft_version}", + "minecraft": "=${minecraft_version}", "java": ">=17", "fabric-api": "*" }, From 77f59e7b6a7fb3da8faae8de14b2c4876008203e Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 25 Nov 2024 13:16:24 -0600 Subject: [PATCH 18/30] 1.21.1 port --- .../java/one/oth3r/sit/screen/ClickableImageWidget.java | 5 +++-- src/main/java/one/oth3r/sit/screen/ConfigScreen.java | 6 ++---- src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java | 3 +-- src/main/java/one/oth3r/sit/utl/Utl.java | 1 - 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java b/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java index fb14e4f..375c367 100644 --- a/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java +++ b/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java @@ -4,7 +4,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.render.RenderLayer; import net.minecraft.text.Text; import net.minecraft.util.Identifier; @@ -21,10 +20,12 @@ public class ClickableImageWidget extends ButtonWidget { @Override protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + context.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha); RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); - context.drawTexture(RenderLayer::getGuiTextured, image, + context.drawTexture(image, this.getX(), this.getY(), 0.0f, 0.0f, this.getWidth(), this.getHeight(), this.getWidth(), this.getHeight()); + context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); } } diff --git a/src/main/java/one/oth3r/sit/screen/ConfigScreen.java b/src/main/java/one/oth3r/sit/screen/ConfigScreen.java index b64eb60..4f058d1 100644 --- a/src/main/java/one/oth3r/sit/screen/ConfigScreen.java +++ b/src/main/java/one/oth3r/sit/screen/ConfigScreen.java @@ -5,10 +5,8 @@ import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.render.RenderLayer; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -import net.minecraft.util.math.ColorHelper; import one.oth3r.sit.file.FileData; import one.oth3r.sit.utl.Data; @@ -73,8 +71,8 @@ public class ConfigScreen extends Screen { private void renderBanner(DrawContext context, int x, int y, float alpha) { RenderSystem.enableBlend(); - context.drawTexture(RenderLayer::getGuiTextured,Identifier.of(Data.MOD_ID, "textures/gui/banner.png"), - x, y, 0.0f, 0.0f, 128, 72, 128, 72, ColorHelper.getWhite(alpha)); + context.drawTexture(Identifier.of(Data.MOD_ID, "textures/gui/banner.png"), + x, y, 0.0f, 0.0f, 128, 72, 128, 72); RenderSystem.disableBlend(); } diff --git a/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java b/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java index 6a13691..122137b 100644 --- a/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java +++ b/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java @@ -4,7 +4,6 @@ import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.render.RenderLayer; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import org.jetbrains.annotations.Nullable; @@ -30,7 +29,7 @@ public class TextureButtonWidget extends ButtonWidget { super.renderWidget(context, mouseX, mouseY, delta); int x = this.getX() + this.getWidth() / 2 - this.textureWidth / 2; int y = this.getY() + this.getHeight() / 2 - this.textureHeight / 2; - context.drawGuiTexture(RenderLayer::getGuiTextured, this.texture, x, y, this.textureWidth, this.textureHeight); + context.drawGuiTexture(this.texture, x, y, this.textureWidth, this.textureHeight); } @Override diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 7be286e..561b5f4 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -15,7 +15,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.item.consume.UseAction; import net.minecraft.registry.Registries; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; From 78f7d81d938d641ea306d419e8be6ec6bfc3a3bf Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 25 Nov 2024 13:16:45 -0600 Subject: [PATCH 19/30] 1.2.0+1.21-1.21.1 --- gradle.properties | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 90f6f01..1720dc0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,16 +4,16 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -min_minecraft_version=1.21.3 -minecraft_version=1.21.3 -yarn_mappings=1.21.3+build.2 -loader_version=0.16.7 +min_minecraft_version=1.21 +minecraft_version=1.21.1 +yarn_mappings=1.21.1+build.3 +loader_version=0.16.9 # Mod Properties -mod_version=1.2.0+1.21.3 +mod_version=1.2.0+1.21-1.21.1 maven_group=one.oth3r file_name=sit! # Dependencies -fabric_version=0.107.0+1.21.3 -modmenu_version=12.0.0-beta.1 +fabric_version=0.109.0+1.21.1 +modmenu_version=11.0.0-beta.1 From 32a4b0006a53976059f5dbf97f5e659f0705fde5 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Wed, 27 Nov 2024 10:42:50 -0600 Subject: [PATCH 20/30] 1.20.6 port --- src/main/java/one/oth3r/sit/file/CustomBlock.java | 2 +- src/main/java/one/oth3r/sit/file/CustomItem.java | 4 ++-- src/main/java/one/oth3r/sit/screen/ConfigScreen.java | 8 +++----- .../one/oth3r/sit/screen/UnderConstructionScreen.java | 4 ++-- src/main/java/one/oth3r/sit/utl/Utl.java | 2 +- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/one/oth3r/sit/file/CustomBlock.java b/src/main/java/one/oth3r/sit/file/CustomBlock.java index 0c4f5e7..2bd4c04 100644 --- a/src/main/java/one/oth3r/sit/file/CustomBlock.java +++ b/src/main/java/one/oth3r/sit/file/CustomBlock.java @@ -89,7 +89,7 @@ public class CustomBlock { for (String tag : blockTags) { // substring to remove # and if needed, ! // if there is a math for the NOT(!) tag, return false - if (tag.startsWith("!") && blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), Identifier.of(tag.substring(2))))) return false; + if (tag.startsWith("!") && blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), new Identifier(tag.substring(2))))) return false; // if there is a match, return true if (blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), Identifier.tryParse(tag.substring(1))))) tagCheck = true; } diff --git a/src/main/java/one/oth3r/sit/file/CustomItem.java b/src/main/java/one/oth3r/sit/file/CustomItem.java index ec1ef5f..05515f6 100644 --- a/src/main/java/one/oth3r/sit/file/CustomItem.java +++ b/src/main/java/one/oth3r/sit/file/CustomItem.java @@ -53,10 +53,10 @@ public class CustomItem { // if a NOT tag if (tag.startsWith("!")) { // if there is a math for the NOT(!) tag, return false - if (itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), Identifier.of(tag.substring(2))))) return false; + if (itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), new Identifier(tag.substring(2))))) return false; } // else (normal tag), if there is a match, set tagCheck to true - else if (itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), Identifier.of(tag.substring(1))))) tagCheck = true; + else if (itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), new Identifier(tag.substring(1))))) tagCheck = true; } // not returning true in the loop because there might be a (!) not tag that the item might fall into, after the item was already in another tag diff --git a/src/main/java/one/oth3r/sit/screen/ConfigScreen.java b/src/main/java/one/oth3r/sit/screen/ConfigScreen.java index 4f058d1..637bd6a 100644 --- a/src/main/java/one/oth3r/sit/screen/ConfigScreen.java +++ b/src/main/java/one/oth3r/sit/screen/ConfigScreen.java @@ -10,8 +10,6 @@ import net.minecraft.util.Identifier; import one.oth3r.sit.file.FileData; import one.oth3r.sit.utl.Data; -import java.net.URI; - public class ConfigScreen extends Screen { protected final Screen parent; @@ -36,13 +34,13 @@ public class ConfigScreen extends Screen { TextureButtonWidget issuesButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.issues"), - ConfirmLinkScreen.opening(this, URI.create("https://github.com/Oth3r/Sit/issues")), true) + ConfirmLinkScreen.opening(this, "https://github.com/Oth3r/Sit/issues"), true) .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "issues"), 15, 15).build()); issuesButton.setPosition(this.width / 2 - 125, startY + 72 + 12); this.addDrawableChild(ButtonWidget.builder(Text.translatable("sit!.gui.button.website"), - ConfirmLinkScreen.opening(this, URI.create("https://modrinth.com/mod/sit!")) + ConfirmLinkScreen.opening(this, "https://modrinth.com/mod/sit!") ).dimensions(this.width / 2 - 100, startY + 72 + 12, 98, 20).build()); this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.done"), (button) -> { @@ -50,7 +48,7 @@ public class ConfigScreen extends Screen { }).dimensions(this.width / 2 + 2, startY + 72 + 12, 98, 20).build()); TextureButtonWidget donateButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.donate"), - ConfirmLinkScreen.opening(this, URI.create("https://Ko-fi.com/oth3r")), true) + ConfirmLinkScreen.opening(this, "https://Ko-fi.com/oth3r"), true) .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "donate"), 15, 15).build()); donateButton.setPosition(this.width / 2 + 105, startY + 72 + 12); } diff --git a/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java b/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java index 8395f35..ba418fc 100644 --- a/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java +++ b/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java @@ -29,7 +29,7 @@ public class UnderConstructionScreen> extends Screen { protected void init() { int startY = this.height / 5-4; ButtonWidget foxPNG = this.addDrawableChild(new ClickableImageWidget(70,70,140,140, Tooltip.of(Text.of("Art by @bunnestbun")), - Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening(this, URI.create("https://www.instagram.com/bunnestbun/")))); + Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening(this, "https://www.instagram.com/bunnestbun/"))); foxPNG.setPosition(this.width / 2 - (foxPNG.getWidth()/2), startY-35); ButtonWidget openFileButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.file"), @@ -38,7 +38,7 @@ public class UnderConstructionScreen> extends Screen { openFileButton.setPosition(this.width / 2 - 70, startY+110); TextureButtonWidget folderButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.folder"), - (button) -> Util.getOperatingSystem().open(Paths.get(this.file.getFile().getParent())), true) + (button) -> Util.getOperatingSystem().open(this.file.getFile().getParent()), true) .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "folder"), 15, 15).build()); folderButton.setPosition(this.width / 2 + 50, startY + 110); diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 561b5f4..03e6cd1 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -366,7 +366,7 @@ public class Utl { player.sendMessage(messageTag().append(Utl.lang("sit!.chat.purged",Utl.lang("sit!.chat.purged.total",count).styled( style -> style.withColor(Colors.LIGHT_GRAY).withItalic(true) )).styled( - style -> style.withColor(Colors.GREEN) + style -> style.withColor(Formatting.GREEN) ))); } } From 9d6cc9b785ad7e86aac59e2ff709af1fde78381b Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sun, 1 Dec 2024 12:11:34 -0600 Subject: [PATCH 21/30] 1.20.4 packet fix --- .../java/one/oth3r/sit/PacketBuilder.java | 35 -------------- .../one/oth3r/sit/packet/PacketSender.java | 39 ++++++++++++++++ .../java/one/oth3r/sit/packet/PacketType.java | 16 +++++++ .../one/oth3r/sit/packet/SitPayloads.java | 43 ----------------- src/main/java/one/oth3r/sit/utl/Events.java | 46 ++++++++++--------- src/main/java/one/oth3r/sit/utl/Utl.java | 6 +-- 6 files changed, 82 insertions(+), 103 deletions(-) delete mode 100644 src/main/java/one/oth3r/sit/PacketBuilder.java create mode 100644 src/main/java/one/oth3r/sit/packet/PacketSender.java create mode 100644 src/main/java/one/oth3r/sit/packet/PacketType.java delete mode 100644 src/main/java/one/oth3r/sit/packet/SitPayloads.java diff --git a/src/main/java/one/oth3r/sit/PacketBuilder.java b/src/main/java/one/oth3r/sit/PacketBuilder.java deleted file mode 100644 index 6afb6cf..0000000 --- a/src/main/java/one/oth3r/sit/PacketBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -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; -import net.minecraft.util.Identifier; - -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; - -public class PacketBuilder { - public static final String SETTINGS = "settings_v1.0"; - private final String message; - private final PacketByteBuf packetByteBuf = PacketByteBufs.create(); - public PacketBuilder(ByteBuf buf) { - // Read any data sent in the packet - message = buf.toString(StandardCharsets.UTF_8); - packetByteBuf.writeBytes(buf); - } - public PacketBuilder(String message) { - this.message = message; - packetByteBuf.writeBytes(ByteBuffer.wrap(message.getBytes(StandardCharsets.UTF_8)).array()); - } - public static Identifier getIdentifier() { - // only 1 packet rn - return new Identifier(Sit.MOD_ID, SETTINGS); - } - public void send() { - ClientPlayNetworking.send(getIdentifier(), packetByteBuf); - } - public String getMessage() { - return this.message; - } -} diff --git a/src/main/java/one/oth3r/sit/packet/PacketSender.java b/src/main/java/one/oth3r/sit/packet/PacketSender.java new file mode 100644 index 0000000..ff624bb --- /dev/null +++ b/src/main/java/one/oth3r/sit/packet/PacketSender.java @@ -0,0 +1,39 @@ +package one.oth3r.sit.packet; + +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import one.oth3r.sit.utl.Data; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + +public class PacketSender { + private final PacketByteBuf data; + private final PacketType type; + + public PacketSender(PacketType type, String data) { + this.type = type; + this.data = PacketByteBufs.create() + .writeBytes(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8))); + } + + public void sendToPlayer(ServerPlayerEntity player) { + ServerPlayNetworking.send(player,getIdentifier(type),data); + } + + public void sendToServer() { + ClientPlayNetworking.send(getIdentifier(type),data); + } + + public static Identifier getIdentifier(PacketType packetType) { + return new Identifier(Data.MOD_ID, packetType.getId()); + } + + public static String getPacketData(PacketByteBuf buf) { + return buf.toString(StandardCharsets.UTF_8); + } +} diff --git a/src/main/java/one/oth3r/sit/packet/PacketType.java b/src/main/java/one/oth3r/sit/packet/PacketType.java new file mode 100644 index 0000000..28b351c --- /dev/null +++ b/src/main/java/one/oth3r/sit/packet/PacketType.java @@ -0,0 +1,16 @@ +package one.oth3r.sit.packet; + +public enum PacketType { + RESPONSE("response_v1.0"), + SETTINGS("settings_v2.0"); + + final String id; + + PacketType(String id) { + this.id = id; + } + + public String getId() { + return id; + } +} diff --git a/src/main/java/one/oth3r/sit/packet/SitPayloads.java b/src/main/java/one/oth3r/sit/packet/SitPayloads.java deleted file mode 100644 index e1aaba9..0000000 --- a/src/main/java/one/oth3r/sit/packet/SitPayloads.java +++ /dev/null @@ -1,43 +0,0 @@ -package one.oth3r.sit.packet; - -import net.minecraft.network.RegistryByteBuf; -import net.minecraft.network.codec.PacketCodec; -import net.minecraft.network.codec.PacketCodecs; -import net.minecraft.network.packet.CustomPayload; -import net.minecraft.util.Identifier; -import one.oth3r.sit.utl.Data; - -public class SitPayloads { - /** - * the packet that the client sends to the server - * @param value the sitting settings for the client - */ - public record SettingsPayload(String value) implements CustomPayload { - - public static final Id ID = new Id<>(Identifier.of(Data.MOD_ID,"settings_v2.0")); - - public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(SettingsPayload::new, SettingsPayload::value).cast(); - - @Override - public Id getId() { - return ID; - } - } - - /** - * the packet that the server sends to the client when responding to the settings payload - */ - public record ResponsePayload(String value) implements CustomPayload { - - public static final String VERSION = "response_v1.0"; - - public static final Id ID = new Id<>(Identifier.of(Data.MOD_ID,VERSION)); - - public static final PacketCodec CODEC = PacketCodecs.STRING.xmap(ResponsePayload::new, ResponsePayload::value).cast(); - - @Override - public Id getId() { - return ID; - } - } -} diff --git a/src/main/java/one/oth3r/sit/utl/Events.java b/src/main/java/one/oth3r/sit/utl/Events.java index f06a485..fbc2241 100644 --- a/src/main/java/one/oth3r/sit/utl/Events.java +++ b/src/main/java/one/oth3r/sit/utl/Events.java @@ -8,7 +8,6 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.fabricmc.fabric.api.event.player.UseBlockCallback; -import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.client.MinecraftClient; @@ -21,7 +20,8 @@ import one.oth3r.sit.command.SitCommand; import one.oth3r.sit.file.FileData; import one.oth3r.sit.file.LangReader; import one.oth3r.sit.file.SittingConfig; -import one.oth3r.sit.packet.SitPayloads; +import one.oth3r.sit.packet.PacketSender; +import one.oth3r.sit.packet.PacketType; import one.oth3r.sit.screen.ConfigScreen; import org.lwjgl.glfw.GLFW; @@ -83,35 +83,37 @@ public class Events { private static class Packet { private static void common() { - // register the data - PayloadTypeRegistry.playC2S().register(SitPayloads.SettingsPayload.ID, SitPayloads.SettingsPayload.CODEC); - - PayloadTypeRegistry.playS2C().register(SitPayloads.ResponsePayload.ID, SitPayloads.ResponsePayload.CODEC); - // server receiver is common /// receiving the sitting setting payload - ServerPlayNetworking.registerGlobalReceiver(SitPayloads.SettingsPayload.ID,((payload, context) -> Data.getServer().execute(() -> { - // save the setting on the server for that player - FileData.setPlayerSetting(context.player(),Utl.getGson().fromJson(payload.value(), SittingConfig.class)); + ServerPlayNetworking.registerGlobalReceiver(PacketSender.getIdentifier(PacketType.SETTINGS), + ((server, player, handler, buf, responseSender) -> { + String packetData = PacketSender.getPacketData(buf); + server.execute(() -> { + // save the setting on the server for that player + FileData.setPlayerSetting(player,Utl.getGson().fromJson(packetData, SittingConfig.class)); - // send the player back a response packet for confirmation - ServerPlayNetworking.send(context.player(),new SitPayloads.ResponsePayload(SitPayloads.ResponsePayload.VERSION)); + // send the player back a response packet for confirmation + new PacketSender(PacketType.RESPONSE,PacketType.RESPONSE.getId()).sendToPlayer(player); - // log the receiving of the packet from the player - Data.LOGGER.info(Utl.lang("sit!.console.player_settings",context.player().getName().getString()).getString()); - }))); + // log the receiving of the packet from the player + Data.LOGGER.info(Utl.lang("sit!.console.player_settings",player.getName().getString()).getString()); + }); + })); } private static void client() { /// receiving the response packet from the server - ClientPlayNetworking.registerGlobalReceiver(SitPayloads.ResponsePayload.ID, ((payload, context) -> { - // only update when needed - if (!Data.isSupportedServer()) { - Data.setSupportedServer(true); - Data.LOGGER.info(Utl.lang("sit!.console.connected",payload.value()).getString()); - } - })); + ClientPlayNetworking.registerGlobalReceiver(PacketSender.getIdentifier(PacketType.RESPONSE), + ((client, handler, buf, responseSender) -> { + String packetData = PacketSender.getPacketData(buf); + client.execute(() -> { + if (!Data.isSupportedServer()) { + Data.setSupportedServer(true); + Data.LOGGER.info(Utl.lang("sit!.console.connected",packetData).getString()); + } + }); + })); } } diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 03e6cd1..49c144c 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -5,7 +5,6 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; import com.google.gson.stream.MalformedJsonException; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.minecraft.block.*; import net.minecraft.block.enums.BlockHalf; import net.minecraft.block.enums.SlabType; @@ -29,7 +28,8 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.RaycastContext; import net.minecraft.world.World; import one.oth3r.sit.file.*; -import one.oth3r.sit.packet.SitPayloads; +import one.oth3r.sit.packet.PacketSender; +import one.oth3r.sit.packet.PacketType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -414,7 +414,7 @@ public class Utl { */ public static void sendSettingsPackets() { if (Data.isClient() && Data.isInGame()) { - ClientPlayNetworking.send(new SitPayloads.SettingsPayload(Utl.getGson().toJson(FileData.getSittingConfig()))); + new PacketSender(PacketType.SETTINGS, Utl.getGson().toJson(FileData.getSittingConfig())).sendToServer(); } } From aa59c9cdfd06b467b10c913d32312467f40d2521 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sun, 1 Dec 2024 12:11:41 -0600 Subject: [PATCH 22/30] 1.20.4 min version --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index ccc95e5..c06b2df 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,7 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop +min_minecraft_version=1.20.4 minecraft_version=1.20.4 yarn_mappings=1.20.4+build.3 loader_version=0.15.11 From de1e7d8d65331a3733db1dbdc7d690ef708cf99b Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sun, 22 Dec 2024 17:58:25 -0600 Subject: [PATCH 23/30] 1.20.1 port --- .../one/oth3r/sit/packet/PacketSender.java | 5 +- .../sit/screen/ClickableImageWidget.java | 2 +- .../one/oth3r/sit/screen/ConfigScreen.java | 23 +++++---- .../oth3r/sit/screen/TextureButtonWidget.java | 6 +-- .../sit/screen/UnderConstructionScreen.java | 16 ++++-- src/main/java/one/oth3r/sit/utl/Utl.java | 23 ++++++--- src/main/resources/assets/sit/lang/zh_tw.json | 51 ------------------- 7 files changed, 48 insertions(+), 78 deletions(-) delete mode 100644 src/main/resources/assets/sit/lang/zh_tw.json diff --git a/src/main/java/one/oth3r/sit/packet/PacketSender.java b/src/main/java/one/oth3r/sit/packet/PacketSender.java index ff624bb..2a29dc1 100644 --- a/src/main/java/one/oth3r/sit/packet/PacketSender.java +++ b/src/main/java/one/oth3r/sit/packet/PacketSender.java @@ -12,13 +12,12 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; public class PacketSender { - private final PacketByteBuf data; + private final PacketByteBuf data = PacketByteBufs.create(); private final PacketType type; public PacketSender(PacketType type, String data) { this.type = type; - this.data = PacketByteBufs.create() - .writeBytes(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8))); + this.data.writeBytes(ByteBuffer.wrap(data.getBytes(StandardCharsets.UTF_8))); } public void sendToPlayer(ServerPlayerEntity player) { diff --git a/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java b/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java index 375c367..b417287 100644 --- a/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java +++ b/src/main/java/one/oth3r/sit/screen/ClickableImageWidget.java @@ -19,7 +19,7 @@ public class ClickableImageWidget extends ButtonWidget { } @Override - protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { + protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) { context.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha); RenderSystem.enableBlend(); RenderSystem.enableDepthTest(); diff --git a/src/main/java/one/oth3r/sit/screen/ConfigScreen.java b/src/main/java/one/oth3r/sit/screen/ConfigScreen.java index 637bd6a..f0ddfd1 100644 --- a/src/main/java/one/oth3r/sit/screen/ConfigScreen.java +++ b/src/main/java/one/oth3r/sit/screen/ConfigScreen.java @@ -1,6 +1,7 @@ package one.oth3r.sit.screen; import com.mojang.blaze3d.systems.RenderSystem; +import com.terraformersmc.modmenu.gui.ModMenuOptionsScreen; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen; @@ -24,23 +25,23 @@ public class ConfigScreen extends Screen { int spacing = 36; TextureButtonWidget serverConfigButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("config.server"), (button) -> client.setScreen(new UnderConstructionScreen(this, FileData.getServerConfig())), false) - .dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "server_button"), 246, 26).build()); + .dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/server_button.png"), 246, 26).build()); serverConfigButton.setPosition(this.width / 2 - (serverConfigButton.getWidth()/2), startY); TextureButtonWidget sittingConfigButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("config.sitting"), (button) -> client.setScreen(new UnderConstructionScreen(this, FileData.getSittingConfig())), false) - .dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "sitting_button"), 246, 26).build()); + .dimensions(250,30).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/sitting_button.png"), 246, 26).build()); sittingConfigButton.setPosition(this.width / 2 - (sittingConfigButton.getWidth()/2), startY+36); TextureButtonWidget issuesButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.issues"), - ConfirmLinkScreen.opening(this, "https://github.com/Oth3r/Sit/issues"), true) - .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "issues"), 15, 15).build()); + ConfirmLinkScreen.opening("https://github.com/Oth3r/Sit/issues",this,true), true) + .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/issues.png"), 15, 15).build()); issuesButton.setPosition(this.width / 2 - 125, startY + 72 + 12); this.addDrawableChild(ButtonWidget.builder(Text.translatable("sit!.gui.button.website"), - ConfirmLinkScreen.opening(this, "https://modrinth.com/mod/sit!") + ConfirmLinkScreen.opening("https://modrinth.com/mod/sit!",this,true) ).dimensions(this.width / 2 - 100, startY + 72 + 12, 98, 20).build()); this.addDrawableChild(ButtonWidget.builder(Text.translatable("gui.done"), (button) -> { @@ -48,17 +49,21 @@ public class ConfigScreen extends Screen { }).dimensions(this.width / 2 + 2, startY + 72 + 12, 98, 20).build()); TextureButtonWidget donateButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.donate"), - ConfirmLinkScreen.opening(this, "https://Ko-fi.com/oth3r"), true) - .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "donate"), 15, 15).build()); + ConfirmLinkScreen.opening("https://Ko-fi.com/oth3r",this,true), true) + .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/donate.png"), 15, 15).build()); donateButton.setPosition(this.width / 2 + 105, startY + 72 + 12); } @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { - super.render(context, mouseX, mouseY, delta); - + // render the background because you have to in this version + this.renderBackground(context); // todo fade in like the title screen on first load? renderBanner(context,width/2 - 64,this.height / 4 -38,1); + + super.render(context, mouseX, mouseY, delta); + + } @Override diff --git a/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java b/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java index 122137b..c49b8f5 100644 --- a/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java +++ b/src/main/java/one/oth3r/sit/screen/TextureButtonWidget.java @@ -25,11 +25,11 @@ public class TextureButtonWidget extends ButtonWidget { } @Override - public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) { - super.renderWidget(context, mouseX, mouseY, delta); + protected void renderButton(DrawContext context, int mouseX, int mouseY, float delta) { + super.renderButton(context, mouseX, mouseY, delta); int x = this.getX() + this.getWidth() / 2 - this.textureWidth / 2; int y = this.getY() + this.getHeight() / 2 - this.textureHeight / 2; - context.drawGuiTexture(this.texture, x, y, this.textureWidth, this.textureHeight); + context.drawTexture(this.texture, x, y, 0, 0, this.textureWidth, this.textureHeight, this.textureWidth, this.textureHeight); } @Override diff --git a/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java b/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java index ba418fc..971c4a4 100644 --- a/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java +++ b/src/main/java/one/oth3r/sit/screen/UnderConstructionScreen.java @@ -1,5 +1,6 @@ package one.oth3r.sit.screen; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.tooltip.Tooltip; @@ -29,7 +30,7 @@ public class UnderConstructionScreen> extends Screen { protected void init() { int startY = this.height / 5-4; ButtonWidget foxPNG = this.addDrawableChild(new ClickableImageWidget(70,70,140,140, Tooltip.of(Text.of("Art by @bunnestbun")), - Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening(this, "https://www.instagram.com/bunnestbun/"))); + Identifier.of(Data.MOD_ID, "textures/gui/fox.png"), ConfirmLinkScreen.opening("https://www.instagram.com/bunnestbun/",this, true))); foxPNG.setPosition(this.width / 2 - (foxPNG.getWidth()/2), startY-35); ButtonWidget openFileButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.file"), @@ -38,8 +39,8 @@ public class UnderConstructionScreen> extends Screen { openFileButton.setPosition(this.width / 2 - 70, startY+110); TextureButtonWidget folderButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.folder"), - (button) -> Util.getOperatingSystem().open(this.file.getFile().getParent()), true) - .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "folder"), 15, 15).build()); + (button) -> Util.getOperatingSystem().open(this.file.getFile().getParentFile().toURI()), true) + .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/folder.png"), 15, 15).build()); folderButton.setPosition(this.width / 2 + 50, startY + 110); TextureButtonWidget resetButton = this.addDrawableChild(new TextureButtonWidget.Builder(Text.translatable("sit!.gui.button.reset"), @@ -47,7 +48,7 @@ public class UnderConstructionScreen> extends Screen { this.file.reset(); this.file.save(); }, true) - .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "reset_file"), 15, 15).build()); + .dimensions(20,20).texture(Identifier.of(Data.MOD_ID, "textures/gui/sprites/reset_file.png"), 15, 15).build()); resetButton.setPosition(this.width / 2 -70, startY + 135); ButtonWidget revertButton = this.addDrawableChild(new ButtonWidget.Builder(Text.translatable("sit!.gui.button.revert"), @@ -72,6 +73,13 @@ public class UnderConstructionScreen> extends Screen { saveExitButton.setPosition(this.width / 2 - 70, startY+168); } + @Override + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + // render the background because you have to in this version + this.renderBackground(context); + super.render(context, mouseX, mouseY, delta); + } + @Override public void close() { this.client.setScreen(parent); diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 1242235..e21ecf1 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -220,8 +220,13 @@ public class Utl { * gets the bound block pos of the sit entity */ public static BlockPos getBlockPos(DisplayEntity.TextDisplayEntity entity) { + // adjustment, the opposite of the offset in Entity.create() + /// ADD .2 AS 1.20.1 is offset by .2 + double adjustmentY = 0.2; + + double entityY = entity.getY() + adjustmentY; // get the block pos - BlockPos pos = new BlockPos(entity.getBlockX(),entity.getBlockY(),entity.getBlockZ()); + BlockPos pos = new BlockPos(entity.getBlockX(),(int)entityY,entity.getBlockZ()); // if above the block, subtract 1 if (isAboveBlockHeight(entity)) { pos = pos.add(0,-1,0); @@ -253,12 +258,10 @@ public class Utl { entity.setInvulnerable(true); entity.setInvisible(true); - /// make a double for adjusting the entity height if some versions change the player sit height on entities again - double adjustmentY = 0; // get the entities y level double entityY = blockPos.getY(); - entityY += sitHeight + adjustmentY; + entityY += sitHeight; // set the entities position entity.updatePositionAndAngles(blockPos.getX()+.5, entityY, blockPos.getZ()+.5, 0, 0); @@ -267,6 +270,12 @@ public class Utl { if (entity.getY() == blockPos.getY() + 1) entity.setPitch(90); // below else entity.setPitch(-90); // above + + // make a double for adjusting the entity height if some versions change the player sit height on entities again + /// 1.20.1 SITTING OFF BY -0.2 + double adjustmentY = -0.2; + entity.updatePosition(entity.getX(),entity.getY()+adjustmentY,entity.getZ()); + return entity; } @@ -312,7 +321,7 @@ public class Utl { // send a message if needed if (message) { player.sendMessage(messageTag().append(Utl.lang("sit!.chat.purged",Utl.lang("sit!.chat.purged.total",count).styled( - style -> style.withColor(Colors.LIGHT_GRAY).withItalic(true) + style -> style.withColor(Formatting.GRAY).withItalic(true) )).styled( style -> style.withColor(Formatting.GREEN) ))); @@ -322,7 +331,7 @@ public class Utl { public static MutableText messageTag() { return Text.literal("[").append(Text.literal("Sit!").styled( - style -> style.withColor(TextColor.parse("#c400ff").result().orElse(TextColor.fromFormatting(Formatting.DARK_PURPLE)))) + style -> style.withColor(TextColor.parse("#c400ff"))) ).append("] "); } @@ -458,7 +467,7 @@ public class Utl { // extend ray by the range Vec3d rayEnd = rayStart.add(player.getRotationVector().multiply(range)); - BlockHitResult hitResult = world.raycast(new RaycastContext(rayStart, rayEnd, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, ShapeContext.absent())); + BlockHitResult hitResult = world.raycast(new RaycastContext(rayStart, rayEnd, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, player)); if (hitResult.getType() == HitResult.Type.BLOCK) { return hitResult.getBlockPos(); diff --git a/src/main/resources/assets/sit/lang/zh_tw.json b/src/main/resources/assets/sit/lang/zh_tw.json deleted file mode 100644 index 391b9cf..0000000 --- a/src/main/resources/assets/sit/lang/zh_tw.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "config.sit.empty": "空", - "config.sit.restrictive": "限制", - "config.sit.none": "無", - "config.sit.category.general": "一般", - "config.sit.category.general.tooltip": "一般設定", - "config.sit.category.main_hand": "慣用手", - "config.sit.category.main_hand.tooltip": "慣用手設定", - "config.sit.category.off_hand": "非慣用手", - "config.sit.category.off_hand.tooltip": "非慣用手設定", - "config.sit.general.keep_active": "保持活躍", - "config.sit.general.keep_active.description": "即使在登出/關閉時,也保持實體處於活躍狀態", - "config.sit.general.sittable": "可坐的方塊", - "config.sit.general.sittable.description": "切換坐在不同方塊類型上的能力。", - "config.sit.general.sit_while_seated": "坐下時坐下", - "config.sit.general.sit_while_seated.description": "切換已經坐在一個方塊上時,坐在其他方塊上的能力。", - "config.sit.general.sittable.stairs": "階梯", - "config.sit.general.sittable.slabs": "半磚", - "config.sit.general.sittable.carpets": "地毯", - "config.sit.general.sittable.full_blocks": "完整方塊", - "config.sit.general.sittable.custom": "自訂", - "config.sit.general.sittable.custom.description": "啟用新增自訂方塊以供坐下。", - "config.sit.general.sittable_blocks": "自訂可坐方塊", - "config.sit.general.sittable_blocks.description": "新增自訂可坐方塊!", - "config.sit.general.sittable_blocks.description_2": "範例:%s", - "config.sit.general.sittable_blocks.description_4": "第一個條目:自訂方塊", - "config.sit.general.sittable_blocks.description_5": "第二個條目:坐姿高度(0-1 之間的數字,例如 0.52)", - "config.sit.general.sittable_blocks.description_6": "第三個條目:碰撞箱大小(玩家下馬時在實體上方生成的位置)", - "config.sit.general.sittable_blocks.description_7": "第四個條目(可選):坐下的必要方塊狀態(輸入「!」排除方塊狀態)", - "config.sit.general.sittable_blocks.description_8": "使用「|」分隔不同的條目!", - "config.sit.hand": "手部設定", - "config.sit.hand.requirements": "需求", - "config.sit.hand.requirements.description": "坐下的手部需求。", - "config.sit.hand.requirements.description_2": "空 = 手必須是空的", - "config.sit.hand.requirements.description_3": "限制 = 為手部狀態設定限制", - "config.sit.hand.requirements.description_4": "無 = 隨時可以坐下", - "config.sit.hand.restrictions": "限制", - "config.sit.hand.restrictions.description": "切換預設的手部限制以供坐下。", - "config.sit.hand.restrictions.blocks": "方塊", - "config.sit.hand.restrictions.food": "食物", - "config.sit.hand.restrictions.usable": "可使用的", - "config.sit.hand.restrictions.usable.description": "例如:弓、三叉戟、盾牌", - "config.sit.hand.whitelist": "白名單", - "config.sit.hand.whitelist.description": "為玩家可以用來坐下的物品建立自訂白名單。", - "config.sit.hand.blacklist": "黑名單", - "config.sit.hand.blacklist.description": "為玩家無法用來坐下的物品建立自訂黑名單。", - "config.sit.hand.list.description": "範例:", - "config.sit.hand.list.description_2": "「minecraft:torch」", - "key.sit.command.reloaded": "已重新載入設定!", - "key.sit.command.purged": "已清除所有活躍的椅子實體!" -} From 08788456b2034c6bc00560e23a53c6b0251c04bb Mon Sep 17 00:00:00 2001 From: Oth3r Date: Mon, 17 Feb 2025 16:05:18 -0600 Subject: [PATCH 24/30] 1.21.3 --- gradle.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9047fb5..08df4aa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,9 +4,9 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -min_minecraft_version=1.21.4 -minecraft_version=1.21.4 -yarn_mappings=1.21.4+build.8 +min_minecraft_version=1.21.3 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 loader_version=0.16.10 # Mod Properties @@ -15,5 +15,5 @@ maven_group=one.oth3r file_name=sit! # Dependencies -fabric_version=0.116.1+1.21.4 -modmenu_version=13.0.0-beta.1 +fabric_version=0.114.0+1.21.3 +modmenu_version=12.0.0-beta.1 From a9399fcbf9117733795da47e1bc8686ebd5fbd0e Mon Sep 17 00:00:00 2001 From: Oth3r Date: Tue, 18 Feb 2025 12:07:14 -0600 Subject: [PATCH 25/30] 1.21.3 number fix --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 08df4aa..67f1082 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ yarn_mappings=1.21.3+build.2 loader_version=0.16.10 # Mod Properties -mod_version=1.2.2+1.21.4 +mod_version=1.2.2+1.21.3 maven_group=one.oth3r file_name=sit! From b5eaf3df7ad1ced18691b34b1865c6463be0b02a Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sun, 23 Feb 2025 15:06:21 -0600 Subject: [PATCH 26/30] 1.21-1.21.1 version fix --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5934e3a..fbe92d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ yarn_mappings=1.21.1+build.3 loader_version=0.16.9 # Mod Properties -mod_version=1.2.1+1.21-1.21.1 +mod_version=1.2.2+1.21-1.21.1 maven_group=one.oth3r file_name=sit! From e11b4acd35428c978c7f24e23949b4a17d0c4777 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Sun, 23 Feb 2025 15:47:58 -0600 Subject: [PATCH 27/30] 1.20.1 height adjustment --- src/main/java/one/oth3r/sit/utl/Utl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 0924ce2..f65cb33 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -207,7 +207,7 @@ public class Utl { /** * the customizable y height of the entity, as some versions have different sitting heights on the entity */ - private static final double Y_ADJUSTMENT = 0.2; + private static final double Y_ADJUSTMENT = -0.2; /** * checks if the entity's block is still there, & is valid From 65431280a3baff9f9bcb89f46f5a3377d5c122ef Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Thu, 13 Mar 2025 17:47:43 -0500 Subject: [PATCH 28/30] update loom and gradle statements --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 44ebae0..c23d6f0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.8-SNAPSHOT' + id 'fabric-loom' version '1.10-SNAPSHOT' id 'maven-publish' id 'com.modrinth.minotaur' version '2.+' id 'net.darkhax.curseforgegradle' version '1.1.+' @@ -14,8 +14,8 @@ base { } repositories { - maven { url "https://maven.terraformersmc.com/releases/" } - maven { url "https://maven.isxander.dev/releases" } + maven { url = "https://maven.terraformersmc.com/releases/" } + maven { url = "https://maven.isxander.dev/releases" } } loom { @@ -33,7 +33,7 @@ dependencies { } processResources { - filteringCharset "UTF-8" + filteringCharset = "UTF-8" var replaceProperties = [ version : project.version, From ebe2f66ff2eae7fd8db07dee201a2b40e62a7d53 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Fri, 14 Mar 2025 14:10:12 -0500 Subject: [PATCH 29/30] real fix for #17 --- src/main/java/one/oth3r/sit/utl/Utl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index db9b637..154a6d6 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -226,9 +226,9 @@ public class Utl { public static BlockPos getBlockPos(DisplayEntity.TextDisplayEntity entity) { // the entity Y level, adjusted // the adjustment - is the opposite of the offset applied in Entity.create() - double entityY = entity.getBlockY() + (Y_ADJUSTMENT*-1); + int entityBlockY = (int) (Math.floor(entity.getY() + (Y_ADJUSTMENT*-1))); // get the block pos - BlockPos pos = new BlockPos(entity.getBlockX(),(int)entityY,entity.getBlockZ()); + BlockPos pos = new BlockPos(entity.getBlockX(),entityBlockY,entity.getBlockZ()); // if above the block, subtract 1 if (isAboveBlockHeight(entity)) { pos = pos.add(0,-1,0); From b7094bb437ba217f6876921bc58afe871c9e7822 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Fri, 14 Mar 2025 14:22:28 -0500 Subject: [PATCH 30/30] update checkPlayerSitAbility() with the entity Y-adjustment in mind --- src/main/java/one/oth3r/sit/utl/Logic.java | 2 +- src/main/java/one/oth3r/sit/utl/Utl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/one/oth3r/sit/utl/Logic.java b/src/main/java/one/oth3r/sit/utl/Logic.java index 2708393..874dc38 100644 --- a/src/main/java/one/oth3r/sit/utl/Logic.java +++ b/src/main/java/one/oth3r/sit/utl/Logic.java @@ -155,7 +155,7 @@ public class Logic { // get the poses to check above the block BlockPos pos1 = new BlockPos(pos).add(0,1,0), pos2 = new BlockPos(pos).add(0,2,0), posBelow = new BlockPos(pos); // doesn't check 2 blocks above if not sitting above .80 of the block - if (pos.getY() > entity.getY() - .80) { + if (pos.getY() > (entity.getY()-Utl.Entity.Y_ADJUSTMENT) - .80) { pos2 = pos2.add(0,-1,0); posBelow = posBelow.add(0,-1,0); } diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 154a6d6..b0ca2a6 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -207,7 +207,7 @@ public class Utl { /** * the customizable y height of the entity, as some versions have different sitting heights on the entity */ - private static final double Y_ADJUSTMENT = -0.2; + public static final double Y_ADJUSTMENT = -0.2; /** * checks if the entity's block is still there, & is valid