Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoPresident committed Jun 18, 2024
1 parent c4e0f22 commit 568fe09
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 82 deletions.
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.1.+'
id 'fabric-loom' version '1.6.+'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version + "-" + project.minecraft_version + "+"
Expand All @@ -27,6 +27,8 @@ dependencies {
"fabric-api-base",
"fabric-key-binding-api-v1",
"fabric-lifecycle-events-v1",
"fabric-resource-loader-v0", // MidnightLib
"fabric-screen-api-v1"
]

apiModules.forEach {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
# Mod Properties
mod_version=1.8.6
mod_version=1.8.7
maven_group=us.potatoboy
archives_base_name=PetOwner
# Dependencies
# check this on https://fabricmc.net/develop/
fabric_version=0.89.1+1.20.2
modmenu_version=6.1.0-rc.4
midnightlib_version=1.5.0-fabric
fabric_version=0.100.3+1.21
modmenu_version=11.0.0-rc.4
midnightlib_version=1.5.7-fabric
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -62,6 +63,9 @@ public void onInitializeClient() {
"category.petowner.title"
));

var enabledText = Text.translatable("text.petowner.message.enabled").formatted(Formatting.BOLD, Formatting.GREEN);
var disabledText = Text.translatable("text.petowner.message.disabled").formatted(Formatting.BOLD, Formatting.RED);

ClientTickEvents.END_CLIENT_TICK.register(minecraftClient -> {
if (keyBinding.isUnbound()) return;

Expand All @@ -70,15 +74,15 @@ public void onInitializeClient() {

if (keyBinding.isPressed() || keyBinding.wasPressed()) {
if (minecraftClient.player != null && PetOwnerConfig.showKeybindMessage) {
minecraftClient.player.sendMessage(Text.translatable(enabled ? "text.petowner.message.enabled" : "text.petowner.message.disabled"), true);
minecraftClient.player.sendMessage((enabled ? enabledText : disabledText), true);
}
}
} else {
//Toggle mode
while (keyBinding.wasPressed()) {
enabled = !enabled;
if (minecraftClient.player != null && PetOwnerConfig.showKeybindMessage) {
minecraftClient.player.sendMessage(Text.translatable(enabled ? "text.petowner.message.enabled" : "text.petowner.message.disabled"), true);
minecraftClient.player.sendMessage((enabled ? enabledText : disabledText), true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package us.potatoboy.petowner.mixin;

import com.mojang.logging.LogUtils;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
Expand All @@ -9,7 +8,11 @@
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAttachmentType;
import net.minecraft.text.Text;
import net.minecraft.util.Colors;
import net.minecraft.util.Formatting;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -53,30 +56,32 @@ private void render(Entity entity, float yaw, float tickDelta, MatrixStack matri
Optional<String> usernameString = PetOwnerClient.getNameFromId(ownerId);

Text text = Text.translatable("text.petowner.message.owner", usernameString.isPresent() ?
usernameString.get() : Text.translatable("text.petowner.message.error"));
Text.literal(usernameString.get()).formatted(Formatting.WHITE) : Text.translatable("text.petowner.message.error").formatted(Formatting.RED)).formatted(Formatting.DARK_AQUA);
if (FabricLoader.getInstance().isDevelopmentEnvironment() && usernameString.isEmpty()) {
LogUtils.getLogger().error("If you're trying to figure out why the mod doesn't work, it's cause you're in a dev env");
PetOwnerClient.LOGGER.error("If you're trying to figure out why the mod doesn't work, it's cause you're in a dev env");
}

double d = this.dispatcher.getSquaredDistanceToCamera(entity);
if (d <= 4096.0D) {
float height = entity.getHeight() + 0.5F;
int y = 10 + (10 * i);
matrices.push();
matrices.translate(0.0D, height, 0.0D);
matrices.multiply(this.dispatcher.getRotation());
matrices.scale(-0.025F, -0.025F, 0.025F);
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
TextRenderer textRenderer = this.getTextRenderer();
float x = (float) (-textRenderer.getWidth(text) / 2);
Vec3d vec3d = entity.getAttachments().getPointNullable(EntityAttachmentType.NAME_TAG, 0, entity.getYaw(tickDelta));
if (vec3d != null) {
int y = 10 + (10 * i);
matrices.push();
matrices.translate(vec3d.x, vec3d.y + 0.5, vec3d.z);
matrices.multiply(this.dispatcher.getRotation());
matrices.scale(0.025F, -0.025F, 0.025F);
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
TextRenderer textRenderer = this.getTextRenderer();
float x = (float) (-textRenderer.getWidth(text) / 2);

float backgroundOpacity = MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F);
int backgroundColor = (int) (backgroundOpacity * 255.0F) << 24;
float backgroundOpacity = MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F);
int backgroundColor = (int) (backgroundOpacity * 255.0F) << 24;

textRenderer.draw(text, x, (float)y, 553648127, false, matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, backgroundColor, light);
textRenderer.draw(text, x, (float)y, -1, false, matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, 0, light);
textRenderer.draw(text, x, (float) y, 553648127, false, matrix4f, vertexConsumers, TextRenderer.TextLayerType.SEE_THROUGH, backgroundColor, light);
textRenderer.draw(text, x, (float) y, Colors.WHITE, false, matrix4f, vertexConsumers, TextRenderer.TextLayerType.NORMAL, 0, light);

matrices.pop();
matrices.pop();
}
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/assets/petowner/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"petowner.midnightconfig.enum.KeybindMode.TOGGLE": "Toggle",
"petowner.midnightconfig.enum.KeybindMode.HOLD": "Hold",

"text.petowner.message.owner": "§3Owner: %s",
"text.petowner.message.error": "§4Something went wrong",
"text.petowner.message.enabled": "§a§lShowing §rPet Names",
"text.petowner.message.disabled": "§c§lHiding §rPet Names",
"text.petowner.message.owner": "Owner: %s",
"text.petowner.message.error": "Something went wrong",
"text.petowner.message.enabled": "Showing Pet Names",
"text.petowner.message.disabled": "Hiding Pet Names",

"category.petowner.title": "Pet Owner",
"key.petowner.hide": "Hide Owner"
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_ar.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_cl.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_ec.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_es.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_mx.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_uy.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/es_ve.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Pertenece a: %s",
"text.petowner.message.error": "§4Algo salio mal"
"text.petowner.message.owner": "Pertenece a: %s",
"text.petowner.message.error": "Algo salio mal"
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/fi_fi.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3Omistaja: %s",
"text.petowner.message.error": "§4jokin meni pieleen"
"text.petowner.message.owner": "Omistaja: %s",
"text.petowner.message.error": "jokin meni pieleen"
}
8 changes: 4 additions & 4 deletions src/main/resources/assets/petowner/lang/id_id.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"petowner.midnightconfig.alwaysShow": "Selalu tampilkan pemilik, walaupun tidak melihat ke peliharaan",
"petowner.midnightconfig.showKeybindMessage": "Tampilkan pesan keybind",

"text.petowner.message.owner": "§3Pemilik: %s",
"text.petowner.message.error": "§4Ada yang salah",
"text.petowner.message.enabled": "§a§lMenampilkan §rNama Peliharaan",
"text.petowner.message.disabled": "§c§lMenampilkan §rNama Peliharaan",
"text.petowner.message.owner": "Pemilik: %s",
"text.petowner.message.error": "Ada yang salah",
"text.petowner.message.enabled": "Menampilkan Nama Peliharaan",
"text.petowner.message.disabled": "Menampilkan Nama Peliharaan",

"category.petowner.title": "Pemilik Peliharaan",
"key.petowner.hide": "Sembunyikan Pemilik"
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/ja_jp.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3飼い主: %s",
"text.petowner.message.error": "§4エラーが発生しました"
"text.petowner.message.owner": "飼い主: %s",
"text.petowner.message.error": "エラーが発生しました"
}
16 changes: 8 additions & 8 deletions src/main/resources/assets/petowner/lang/ru_ru.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"text.petowner.config.title": "Настройки Pet Owner",
"text.petowner.config.mode": "Режим клавиши (если установлена)",
"text.petowner.config.always_show": "Всегда показывать владельца, даже если не смотришь на питомца",
"text.petowner.config.show_keybind_message": "Показывать сообщения при нажатии клавиши",
"petowner.midnightconfig.title": "Настройки Pet Owner",
"petowner.midnightconfig.keybindMode": "Режим клавиши (если установлена)",
"petowner.midnightconfig.alwaysShow": "Всегда показывать владельца, даже если не смотришь на питомца",
"petowner.midnightconfig.showKeybindMessage": "Показывать сообщения при нажатии клавиши",

"text.petowner.message.owner": "§3Владелец: %s",
"text.petowner.message.error": "§4Что-то пошло не так",
"text.petowner.message.enabled": "Имена питомцев §a§lвидны",
"text.petowner.message.disabled": "Имена питомцев §c§lскрыты",
"text.petowner.message.owner": "Владелец: %s",
"text.petowner.message.error": "Что-то пошло не так",
"text.petowner.message.enabled": "Имена питомцев видны",
"text.petowner.message.disabled": "Имена питомцев скрыты",

"category.petowner.title": "Pet Owner",
"key.petowner.hide": "Скрыть владельцев"
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/assets/petowner/lang/tr_tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"petowner.midnightconfig.alwaysShow": "Bakmazken bile sahibi her zaman göster",
"petowner.midnightconfig.showKeybindMessage": "Tuş atama mesajlarını göster",

"text.petowner.message.owner": "§3Sahibi: %s",
"text.petowner.message.error": "§4Bir şey yanlış gitti",
"text.petowner.message.enabled": "§a§lGösteriliyor: §rEvcil Hayvan İsimleri",
"text.petowner.message.disabled": "§c§lGizleniyor: §rEvcil Hayvan İsimleri",
"text.petowner.message.owner": "Sahibi: %s",
"text.petowner.message.error": "Bir şey yanlış gitti",
"text.petowner.message.enabled": "Gösteriliyor: Evcil Hayvan İsimleri",
"text.petowner.message.disabled": "Gizleniyor: Evcil Hayvan İsimleri",

"category.petowner.title": "Pet Owner (Evcil Hayvan Sahibi)",
"key.petowner.hide": "Sahibi Gizle"
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/assets/petowner/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"petowner.midnightconfig.alwaysShow": "宠物在视线外时仍显示其拥有者",
"petowner.midnightconfig.showKeybindMessage": "显示快捷键信息",

"text.petowner.message.owner": "§3拥有者: %s",
"text.petowner.message.error": "§4出现了一点小问题",
"text.petowner.message.enabled": "§a§l已显示 §r宠物名称",
"text.petowner.message.disabled": "§c§l已隐藏 §r宠物名称",
"text.petowner.message.owner": "拥有者: %s",
"text.petowner.message.error": "出现了一点小问题",
"text.petowner.message.enabled": "已显示 宠物名称",
"text.petowner.message.disabled": "已隐藏 宠物名称",

"category.petowner.title": "宠物拥有者",
"key.petowner.hide": "隐藏宠物拥有者"
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/petowner/lang/zh_tw.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"text.petowner.message.owner": "§3該寵物歸屬於: %s",
"text.petowner.message.error": "§4出現了一點小問題"
"text.petowner.message.owner": "該寵物歸屬於: %s",
"text.petowner.message.error": "出現了一點小問題"
}
4 changes: 3 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"fabric-api-base": "*",
"fabric-key-binding-api-v1": "*",
"fabric-lifecycle-events-v1": "*",
"minecraft":">=1.20.2"
"fabric-resource-loader-v0": "*",
"fabric-screen-api-v1": "*",
"minecraft":">=1.21"
},
"mixins": [
"petowner.mixins.json"
Expand Down

0 comments on commit 568fe09

Please sign in to comment.