From 168fc853b1c9f3e23b9a8276a60db246c0c3a7a6 Mon Sep 17 00:00:00 2001 From: Creativious Date: Sat, 30 Sep 2023 11:18:34 -0400 Subject: [PATCH] Screen scaling hotfix & version bump --- .idea/modules.xml | 1 + .idea/modules/platform-fabric-1.20.1.main.iml | 5 + platform-fabric-1.19.4/gradle.properties | 2 +- .../client/screens/FakePlayerScreen.java | 122 ++++++++++-------- platform-fabric-1.20.1/gradle.properties | 2 +- .../client/screens/FakePlayerScreen.java | 52 +++++--- 6 files changed, 111 insertions(+), 73 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index c50fc3a..b972e53 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -8,6 +8,7 @@ + diff --git a/.idea/modules/platform-fabric-1.20.1.main.iml b/.idea/modules/platform-fabric-1.20.1.main.iml index 2e14514..04a67fa 100644 --- a/.idea/modules/platform-fabric-1.20.1.main.iml +++ b/.idea/modules/platform-fabric-1.20.1.main.iml @@ -1,5 +1,10 @@ + + + + + diff --git a/platform-fabric-1.19.4/gradle.properties b/platform-fabric-1.19.4/gradle.properties index f4ac4b3..d1c4475 100644 --- a/platform-fabric-1.19.4/gradle.properties +++ b/platform-fabric-1.19.4/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.19.4 yarn_mappings=1.19.4+build.2 loader_version=0.14.22 # Mod Properties -mod_version=1.1 +mod_version=1.1.1 maven_group=com.duzo archives_base_name=fakeplayers # Dependencies diff --git a/platform-fabric-1.19.4/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java b/platform-fabric-1.19.4/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java index 58850e2..a755420 100644 --- a/platform-fabric-1.19.4/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java +++ b/platform-fabric-1.19.4/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java @@ -40,37 +40,36 @@ public FakePlayerScreen(Text title, HumanoidEntity humanoid1, PlayerEntity playe @Override protected void init() { super.init(); - int l = this.height / 4 + 48; + int l = ((this.height - this.imageHeight) / 2) + (int) (this.imageHeight * 0.05); int i = (this.width - this.imageWidth) / 2; - int j = (this.height - this.imageWidth) / 2; + int j = this.imageWidth - (int) ( this.imageWidth * 0.1); + System.out.println(l); + System.out.println(i); + System.out.println(j); this.input = new EditBoxWidget(this.textRenderer, (i) + (this.imageWidth/2) - j + (j/2),l,j, 12, Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.skininput").toTranslationKey()), Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.skininputmessage").toTranslationKey())); this.input.setMaxLength(100); // @TODO: Remove the not implemented message when the feature is implemented - this.input.tooltip(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red")))); + this.input.tooltip((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red")))); addDrawableChild(this.input); + int after_input_edit_box_y = this.input.getY() + this.input.getHeight() + ((int) (this.height * 0.01)); - this.chatBox = new EditBoxWidget(this.textRenderer, (i) + (this.imageWidth/2) - j + (j/2),l + 20,j, 12, Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinput").toTranslationKey()), Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinputmessage").toTranslationKey())); + + this.chatBox = new EditBoxWidget(this.textRenderer, (i) + (this.imageWidth/2) - j + (j/2),after_input_edit_box_y,j, 12, Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinput").toTranslationKey()), Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinputmessage").toTranslationKey())); this.chatBox.setMaxLength(100); addDrawableChild(this.chatBox); + int after_chat_edit_box_y = this.chatBox.getY() + this.chatBox.getHeight() + ((int) (this.height * 0.02)); + this.send = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.send").toTranslationKey()), button -> { - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidChatPacket(this.chatBox.getText(), this.humanoid.getUuidAsString())); - this.close(); // Maybe change this out if this is annoying for players - }) - .dimensions((i) + (this.imageWidth/2) - (98/2),l + 40,98,20) + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidChatPacket(this.chatBox.getText(), this.humanoid.getUuidAsString())); + this.close(); // Maybe change this out if this is annoying for players + }) + .dimensions((i) + (this.imageWidth/2) - (98/2),after_chat_edit_box_y,98,20) .build(); addDrawableChild(this.send); - this.confirm = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.confirm").toTranslationKey()), button -> { - player.sendMessage(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), true); - player.sendMessage(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), false); - this.close(); - }) - .dimensions((i) + (this.imageWidth/2) - (98/2),l + (128),98,20) - // @TODO: Remove the not implemented message when the feature is implemented - .tooltip(Tooltip.of((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))))) - .build(); - addDrawableChild(this.confirm); + int after_send_button_y = this.send.getY() + this.send.getHeight() + ((int) (this.height * 0.05)); + this.sitting = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.sit").toTranslationKey()), button -> { MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).toggleSitting(); this.stayPut.active = !MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting(); @@ -79,52 +78,69 @@ protected void init() { Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(!this.stayPut.active, this.humanoid.getUuidAsString())); Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); this.close(); - this.close(); - }) - .dimensions((i) + (this.imageWidth/2) - (23), l + 80,46,20) + this.close(); + }) + .dimensions((i) + (this.imageWidth/2) - (23), after_send_button_y,46,20) .build(); addDrawableChild(this.sitting); + + int after_sitting_button_y = this.sitting.getY() + this.sitting.getHeight(); + this.stayPut = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.stayput").toTranslationKey()), button -> { - this.stayPut.active = false; - this.wander.active = true; - this.follow.active = true; - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(true, this.humanoid.getUuidAsString())); - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); - this.close(); - }) - .dimensions((i) + (this.imageWidth/2) - 23, l + 100,46,20) + this.stayPut.active = false; + this.wander.active = true; + this.follow.active = true; + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(true, this.humanoid.getUuidAsString())); + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); + this.close(); + }) + .dimensions((i) + (this.imageWidth/2) - 23, after_sitting_button_y,46,20) .build(); addDrawableChild(this.stayPut); this.wander = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.wander").toTranslationKey()), button -> { - this.wander.active = false; - this.stayPut.active = true; - if (MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting()) { - MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).toggleSitting(); - } - - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(false, this.humanoid.getUuidAsString())); // More or less setting to default state - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); - this.close(); - }) - .dimensions((i) + (this.imageWidth/2) - (23*3), l + 100,46,20) + this.wander.active = false; + this.stayPut.active = true; + if (MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting()) { + MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).toggleSitting(); + } + + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(false, this.humanoid.getUuidAsString())); // More or less setting to default state + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); + this.close(); + }) + .dimensions((i) + (this.imageWidth/2) - (23*3), after_sitting_button_y,46,20) .build(); addDrawableChild(this.wander); this.follow = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.follow").toTranslationKey()), button -> { - this.follow.active = false; - this.stayPut.active = true; - this.wander.active = true; - if (MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting()) { - MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).toggleSitting(); - } - if (this.humanoid.isAiDisabled()) { - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(false, this.humanoid.getUuidAsString())); - } - Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket(this.player.getUuidAsString(), this.humanoid.getUuidAsString())); - this.close(); - }) - .dimensions((i) + (this.imageWidth/2) + (23), l + 100,46,20) + this.follow.active = false; + this.stayPut.active = true; + this.wander.active = true; + if (MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting()) { + MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).toggleSitting(); + } + if (this.humanoid.isAiDisabled()) { + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidToggleAiPacket(false, this.humanoid.getUuidAsString())); + } + Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket(this.player.getUuidAsString(), this.humanoid.getUuidAsString())); + this.close(); + }) + .dimensions((i) + (this.imageWidth/2) + (23), after_sitting_button_y,46,20) .build(); addDrawableChild(this.follow); + + int after_other_buttons_y = this.follow.getY() + this.follow.getHeight() + ((int) (this.height * 0.02)); + + this.confirm = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.confirm").toTranslationKey()), button -> { + player.sendMessage((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), true); + player.sendMessage((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), false); + this.close(); + + }) + .dimensions((i) + (this.imageWidth/2) - (98/2),after_other_buttons_y,98,20) + // @TODO: Remove the not implemented message when the feature is implemented + .tooltip(Tooltip.of((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))))) + .build(); + addDrawableChild(this.confirm); assert this.player != null; assert this.humanoid != null; if (MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting()) { diff --git a/platform-fabric-1.20.1/gradle.properties b/platform-fabric-1.20.1/gradle.properties index 2d3ba85..edc8221 100644 --- a/platform-fabric-1.20.1/gradle.properties +++ b/platform-fabric-1.20.1/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.14.22 # Mod Properties -mod_version=1.1 +mod_version=1.1.1 maven_group=com.duzo archives_base_name=fakeplayers # Dependencies diff --git a/platform-fabric-1.20.1/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java b/platform-fabric-1.20.1/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java index a95845e..8a93e10 100644 --- a/platform-fabric-1.20.1/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java +++ b/platform-fabric-1.20.1/src/main/java/com/duzo/fakeplayers/client/screens/FakePlayerScreen.java @@ -44,37 +44,36 @@ public FakePlayerScreen(Text title, HumanoidEntity humanoid1, PlayerEntity playe @Override protected void init() { super.init(); - int l = this.height / 4 + 48; + int l = ((this.height - this.imageHeight) / 2) + (int) (this.imageHeight * 0.05); int i = (this.width - this.imageWidth) / 2; - int j = (this.height - this.imageWidth) / 2; + int j = this.imageWidth - (int) ( this.imageWidth * 0.1); + System.out.println(l); + System.out.println(i); + System.out.println(j); this.input = new EditBoxWidget(this.textRenderer, (i) + (this.imageWidth/2) - j + (j/2),l,j, 12, Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.skininput").toTranslationKey()), Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.skininputmessage").toTranslationKey())); this.input.setMaxLength(100); // @TODO: Remove the not implemented message when the feature is implemented this.input.tooltip((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red")))); addDrawableChild(this.input); + int after_input_edit_box_y = this.input.getY() + this.input.getHeight() + ((int) (this.height * 0.01)); - this.chatBox = new EditBoxWidget(this.textRenderer, (i) + (this.imageWidth/2) - j + (j/2),l + 20,j, 12, Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinput").toTranslationKey()), Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinputmessage").toTranslationKey())); + + this.chatBox = new EditBoxWidget(this.textRenderer, (i) + (this.imageWidth/2) - j + (j/2),after_input_edit_box_y,j, 12, Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinput").toTranslationKey()), Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.chatinputmessage").toTranslationKey())); this.chatBox.setMaxLength(100); addDrawableChild(this.chatBox); + int after_chat_edit_box_y = this.chatBox.getY() + this.chatBox.getHeight() + ((int) (this.height * 0.02)); + this.send = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.send").toTranslationKey()), button -> { Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidChatPacket(this.chatBox.getText(), this.humanoid.getUuidAsString())); this.close(); // Maybe change this out if this is annoying for players }) - .dimensions((i) + (this.imageWidth/2) - (98/2),l + 40,98,20) + .dimensions((i) + (this.imageWidth/2) - (98/2),after_chat_edit_box_y,98,20) .build(); addDrawableChild(this.send); - this.confirm = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.confirm").toTranslationKey()), button -> { - player.sendMessage((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), true); - player.sendMessage((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), false); - this.close(); - }) - .dimensions((i) + (this.imageWidth/2) - (98/2),l + (128),98,20) - // @TODO: Remove the not implemented message when the feature is implemented - .tooltip(Tooltip.of((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))))) - .build(); - addDrawableChild(this.confirm); + int after_send_button_y = this.send.getY() + this.send.getHeight() + ((int) (this.height * 0.05)); + this.sitting = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.sit").toTranslationKey()), button -> { MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).toggleSitting(); this.stayPut.active = !MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting(); @@ -85,9 +84,12 @@ protected void init() { this.close(); this.close(); }) - .dimensions((i) + (this.imageWidth/2) - (23), l + 80,46,20) + .dimensions((i) + (this.imageWidth/2) - (23), after_send_button_y,46,20) .build(); addDrawableChild(this.sitting); + + int after_sitting_button_y = this.sitting.getY() + this.sitting.getHeight(); + this.stayPut = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.stayput").toTranslationKey()), button -> { this.stayPut.active = false; this.wander.active = true; @@ -96,7 +98,7 @@ protected void init() { Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); this.close(); }) - .dimensions((i) + (this.imageWidth/2) - 23, l + 100,46,20) + .dimensions((i) + (this.imageWidth/2) - 23, after_sitting_button_y,46,20) .build(); addDrawableChild(this.stayPut); this.wander = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.wander").toTranslationKey()), button -> { @@ -110,7 +112,7 @@ protected void init() { Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket("", this.humanoid.getUuidAsString())); this.close(); }) - .dimensions((i) + (this.imageWidth/2) - (23*3), l + 100,46,20) + .dimensions((i) + (this.imageWidth/2) - (23*3), after_sitting_button_y,46,20) .build(); addDrawableChild(this.wander); this.follow = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.follow").toTranslationKey()), button -> { @@ -126,9 +128,23 @@ protected void init() { Fakeplayers.NETWORK.clientHandle().send(new C2SHumanoidFollowPlayerPacket(this.player.getUuidAsString(), this.humanoid.getUuidAsString())); this.close(); }) - .dimensions((i) + (this.imageWidth/2) + (23), l + 100,46,20) + .dimensions((i) + (this.imageWidth/2) + (23), after_sitting_button_y,46,20) .build(); addDrawableChild(this.follow); + + int after_other_buttons_y = this.follow.getY() + this.follow.getHeight() + ((int) (this.height * 0.02)); + + this.confirm = ButtonWidget.builder(Text.translatable(new Identifier(Fakeplayers.MOD_ID, "screen.fakeplayerscreen.confirm").toTranslationKey()), button -> { + player.sendMessage((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), true); + player.sendMessage((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))), false); + this.close(); + + }) + .dimensions((i) + (this.imageWidth/2) - (98/2),after_other_buttons_y,98,20) + // @TODO: Remove the not implemented message when the feature is implemented + .tooltip(Tooltip.of((Text) Text.translatable(new Identifier(Fakeplayers.MOD_ID, "not_implemented_message").toTranslationKey()).setStyle(Style.EMPTY.withColor(TextColor.parse("red"))))) + .build(); + addDrawableChild(this.confirm); assert this.player != null; assert this.humanoid != null; if (MyComponents.FAKE_PLAYER_SITTING_COMPONENT_COMPONENT.get(this.humanoid).isSitting()) {