Selaa lähdekoodia

Merge pull request #1 from Krunch/1.16.1

Updated to 1.16.1
D4m0n 5 vuotta sitten
vanhempi
sitoutus
5317071f2f

+ 5 - 1
.gitignore

@@ -5,6 +5,10 @@ build/
 out/
 classes/
 
+# eclipse
+
+*.launch
+
 # idea
 
 .idea/
@@ -22,4 +26,4 @@ bin/
 
 # fabric
 
-run/
+run/

+ 1 - 4
build.gradle

@@ -1,5 +1,5 @@
 plugins {
-	id 'fabric-loom' version '0.2.7-SNAPSHOT'
+	id 'fabric-loom' version '0.4-SNAPSHOT'
 	id 'maven-publish'
 }
 
@@ -10,9 +10,6 @@ archivesBaseName = project.archives_base_name
 version = project.mod_version
 group = project.maven_group
 
-minecraft {
-}
-
 dependencies {
 	//to change the versions see the gradle.properties file
 	minecraft "com.mojang:minecraft:${project.minecraft_version}"

+ 9 - 12
gradle.properties

@@ -1,17 +1,14 @@
 # Done to increase the memory available to gradle.
 org.gradle.jvmargs=-Xmx1G
-
 # Fabric Properties
-	# check these on https://fabricmc.net/use
-	minecraft_version=1.16.1
-	yarn_mappings=1.16.1+build.19
-	loader_version=0.8.9+build.203
-
+# check these on https://fabricmc.net/use
+minecraft_version=1.16.1
+yarn_mappings=1.16.1+build.19
+loader_version=0.8.9+build.203
 # Mod Properties
-	mod_version = 1.0.5
-	maven_group = net.fabricmc
-	archives_base_name = horse-stats-vanilla
-
+mod_version=1.0.5
+maven_group=net.fabricmc
+archives_base_name=horse-stats-vanilla
 # Dependencies
-	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
-	fabric_version=0.14.1+build.372-1.16
+# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
+fabric_version=0.14.2+build.373-1.16

BIN
gradle/wrapper/gradle-wrapper.jar


+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists

+ 14 - 19
gradlew

@@ -125,8 +125,8 @@ if $darwin; then
     GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
 fi
 
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
     JAVACMD=`cygpath --unix "$JAVACMD"`
@@ -154,19 +154,19 @@ if $cygwin ; then
         else
             eval `echo args$i`="\"$arg\""
         fi
-        i=$((i+1))
+        i=`expr $i + 1`
     done
     case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+        0) set -- ;;
+        1) set -- "$args0" ;;
+        2) set -- "$args0" "$args1" ;;
+        3) set -- "$args0" "$args1" "$args2" ;;
+        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
     esac
 fi
 
@@ -175,14 +175,9 @@ save () {
     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
     echo " "
 }
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
 
 # Collect all arguments for the java command, following the shell quoting and substitution rules
 eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
 
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
-  cd "$(dirname "$0")"
-fi
-
 exec "$JAVACMD" "$@"

+ 103 - 0
gradlew.bat

@@ -0,0 +1,103 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem      https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 0 - 11
remappedSrc/net/horse/stats/vanilla/HorseStatsVanilla.java

@@ -1,11 +0,0 @@
-package net.horse.stats.vanilla;
-
-import net.fabricmc.api.ModInitializer;
-
-public class HorseStatsVanilla implements ModInitializer {
-    @Override
-    public void onInitialize() {
-
-    }
-    
-}

+ 0 - 63
remappedSrc/net/horse/stats/vanilla/mixin/HorseScreenMixin.java

@@ -1,63 +0,0 @@
-package net.horse.stats.vanilla.mixin;
-
-import java.text.DecimalFormat;
-
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
-import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen;
-import net.minecraft.client.gui.screen.ingame.HorseScreen;
-import net.minecraft.container.HorseContainer;
-import net.minecraft.entity.attribute.EntityAttributes;
-import net.minecraft.entity.passive.AbstractDonkeyEntity;
-import net.minecraft.entity.passive.HorseBaseEntity;
-import net.minecraft.entity.passive.LlamaEntity;
-import net.minecraft.entity.player.PlayerInventory;
-
-@Mixin(HorseScreen.class)
-public abstract class HorseScreenMixin extends AbstractContainerScreen<HorseContainer> {
-    public HorseScreenMixin(HorseContainer container_1, PlayerInventory playerInventory_1, HorseBaseEntity horseBaseEntity_1) {
-        super(container_1, playerInventory_1, horseBaseEntity_1.getDisplayName());
-    }
-
-    HorseBaseEntity horseBaseEntity;
-    @Inject(method = "<init>*", at = @At("RETURN"))
-    private void onConstructed(HorseContainer horseContainer_1, PlayerInventory playerInventory_1, HorseBaseEntity horseBaseEntity_1, CallbackInfo ci) {
-        horseBaseEntity = horseBaseEntity_1;
-    }
-
-    @Inject(method = "drawForeground", at = @At("RETURN"))
-    private void onDrawForeground(int int_1, int int_2, CallbackInfo ci) {
-        boolean hasChest = false;
-        if(AbstractDonkeyEntity.class.isAssignableFrom(horseBaseEntity.getClass())) {
-            if(((AbstractDonkeyEntity) horseBaseEntity).hasChest()) {
-                hasChest = true;
-            }
-        }
-        DecimalFormat df = new DecimalFormat("#.#"); 
-        String jumpstrength = df.format(horseBaseEntity.getJumpStrength() * 10);
-        String maxHealth = df.format(horseBaseEntity.getMaximumHealth());
-        String speed = df.format(horseBaseEntity.getAttributes().get(EntityAttributes.MOVEMENT_SPEED).getValue() * 100);
-        if(!hasChest) {
-            this.font.draw("➟ ", 89.0F, 26.0F, 4210752);
-            this.font.draw("" + speed, 100.0F, 26.0F, 4210752);
-            this.font.draw("⇮", 91.0F, 36.0F, 4210752);
-            this.font.draw("" + jumpstrength, 100.0F, 36.0F, 4210752);
-            this.font.draw("♥", 90.0F, 46.0F, 4210752);
-            this.font.draw("" + maxHealth, 100.0F, 46.0F, 4210752);
-        } else {
-            this.font.draw("➟ " + speed, 80.0F, 6.0F, 4210752);
-            this.font.draw("⇮ " + jumpstrength, 115.0F, 6.0F, 4210752);
-            this.font.draw("♥ " +  maxHealth, 140.0F, 6.0F, 4210752);
-        }
-        if(LlamaEntity.class.isAssignableFrom(horseBaseEntity.getClass())) {
-            int strength = 3 * ((LlamaEntity)horseBaseEntity).getStrength();
-            if(!hasChest) {
-                this.font.draw("▦", 91.0F, 56.0F, 4210752);
-                this.font.draw("" + strength, 100.0F, 56.0F, 4210752);
-            }
-        }
-    }
-}

+ 1 - 2
src/main/java/net/horse/stats/vanilla/HorseStatsVanilla.java

@@ -7,5 +7,4 @@ public class HorseStatsVanilla implements ModInitializer {
     public void onInitialize() {
 
     }
-    
-}
+}

+ 39 - 40
src/main/java/net/horse/stats/vanilla/mixin/HorseScreenMixin.java

@@ -1,64 +1,63 @@
 package net.horse.stats.vanilla.mixin;
 
-import java.text.DecimalFormat;
-
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-
 import net.minecraft.client.gui.screen.ingame.HandledScreen;
 import net.minecraft.client.gui.screen.ingame.HorseScreen;
+import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.entity.attribute.EntityAttributes;
 import net.minecraft.entity.passive.AbstractDonkeyEntity;
 import net.minecraft.entity.passive.HorseBaseEntity;
 import net.minecraft.entity.passive.LlamaEntity;
 import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.screen.HorseScreenHandler;
+import net.minecraft.text.Text;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
 
+import java.text.DecimalFormat;
 
 @Mixin(HorseScreen.class)
 public abstract class HorseScreenMixin extends HandledScreen<HorseScreenHandler> {
-    public HorseScreenMixin(HorseScreenHandler handler, PlayerInventory inventory, HorseBaseEntity entity) {
-        super(handler, inventory, entity.getDisplayName());
-    }
+    @Shadow
+    @Final
+    private HorseBaseEntity entity;
 
-    HorseBaseEntity horseBaseEntity;
-    @Inject(method = "<init>*", at = @At("RETURN"))
-    private void onConstructed(HorseScreenHandler handler, PlayerInventory playerInventory_1, HorseBaseEntity horseBaseEntity_1, CallbackInfo ci) {
-        horseBaseEntity = horseBaseEntity_1;
+    public HorseScreenMixin(HorseScreenHandler handler, PlayerInventory inventory, Text title) {
+        super(handler, inventory, title);
     }
 
-    @Inject(method = "drawForeground", at = @At("RETURN"))
-    private void onDrawForeground(int int_1, int int_2, CallbackInfo ci) {
+    protected void drawForeground(MatrixStack matrices, int mouseX, int mouseY) {
+        super.drawForeground(matrices, mouseX, mouseY);
+
         boolean hasChest = false;
-        if(AbstractDonkeyEntity.class.isAssignableFrom(horseBaseEntity.getClass())) {
-            if(((AbstractDonkeyEntity) horseBaseEntity).hasChest()) {
-                hasChest = true;
-            }
+        if (AbstractDonkeyEntity.class.isAssignableFrom(this.entity.getClass()) && ((AbstractDonkeyEntity) this.entity).hasChest()) {
+            hasChest = true;
         }
-        DecimalFormat df = new DecimalFormat("#.#"); 
-        String jumpstrength = df.format(horseBaseEntity.getJumpStrength() * 10);
-        String maxHealth = df.format(horseBaseEntity.getMaximumHealth());
-        String speed = df.format(horseBaseEntity.getAttributes().get(EntityAttributes.MOVEMENT_SPEED).getValue() * 100);
-        if(!hasChest) {
-            this.font.draw("➟ ", 89.0F, 26.0F, 4210752);
-            this.font.draw("" + speed, 100.0F, 26.0F, 4210752);
-            this.font.draw("⇮", 91.0F, 36.0F, 4210752);
-            this.font.draw("" + jumpstrength, 100.0F, 36.0F, 4210752);
-            this.font.draw("♥", 90.0F, 46.0F, 4210752);
-            this.font.draw("" + maxHealth, 100.0F, 46.0F, 4210752);
+
+        DecimalFormat df = new DecimalFormat("#.#");
+        String jumpstrength = df.format(this.entity.getJumpStrength() * 10);
+        String maxHealth = df.format(this.entity.getMaxHealth());
+        String speed = df.format(this.entity.getAttributes().getValue(EntityAttributes.GENERIC_MOVEMENT_SPEED) * 100);
+
+        if (!hasChest) {
+            this.textRenderer.draw(matrices, "➟ ", 89.0F, 26.0F, 4210752);
+            this.textRenderer.draw(matrices, "" + speed, 100.0F, 26.0F, 4210752);
+            this.textRenderer.draw(matrices, "⇮", 91.0F, 36.0F, 4210752);
+            this.textRenderer.draw(matrices, "" + jumpstrength, 100.0F, 36.0F, 4210752);
+            this.textRenderer.draw(matrices, "♥", 90.0F, 46.0F, 4210752);
+            this.textRenderer.draw(matrices, "" + maxHealth, 100.0F, 46.0F, 4210752);
         } else {
-            this.font.draw("➟ " + speed, 80.0F, 6.0F, 4210752);
-            this.font.draw("⇮ " + jumpstrength, 115.0F, 6.0F, 4210752);
-            this.font.draw("♥ " +  maxHealth, 140.0F, 6.0F, 4210752);
+            this.textRenderer.draw(matrices, "➟ " + speed, 80.0F, 6.0F, 4210752);
+            this.textRenderer.draw(matrices, "⇮ " + jumpstrength, 115.0F, 6.0F, 4210752);
+            this.textRenderer.draw(matrices, "♥ " + maxHealth, 140.0F, 6.0F, 4210752);
         }
-        if(LlamaEntity.class.isAssignableFrom(horseBaseEntity.getClass())) {
-            int strength = 3 * ((LlamaEntity)horseBaseEntity).getStrength();
-            if(!hasChest) {
-                this.font.draw("▦", 91.0F, 56.0F, 4210752);
-                this.font.draw("" + strength, 100.0F, 56.0F, 4210752);
+
+        if (LlamaEntity.class.isAssignableFrom(this.entity.getClass())) {
+            int strength = 3 * ((LlamaEntity) this.entity).getStrength();
+            if (!hasChest) {
+                this.textRenderer.draw(matrices, "▦", 91.0F, 56.0F, 4210752);
+                this.textRenderer.draw(matrices, "" + strength, 100.0F, 56.0F, 4210752);
             }
         }
     }
-}
+}

+ 0 - 3
src/main/resources/fabric.mod.json

@@ -2,7 +2,6 @@
   "schemaVersion": 1,
   "id": "horsestatsvanilla",
   "version": "${version}",
-
   "name": "Horse Stats Vanilla",
   "description": "Shows horse stats in the horse inventory. The style is fiting the vanilla game.",
   "authors": [
@@ -10,7 +9,6 @@
   ],
   "license": "CC0-1.0",
   "icon": "assets/horsestatsvanilla/icon.png",
-
   "environment": "*",
   "entrypoints": {
     "main": [
@@ -20,7 +18,6 @@
   "mixins": [
     "horsestatsvanilla.mixins.json"
   ],
-
   "depends": {
     "fabricloader": ">=0.7.4",
     "fabric": "*",

+ 3 - 4
src/main/resources/horsestatsvanilla.mixins.json

@@ -2,12 +2,11 @@
   "required": true,
   "package": "net.horse.stats.vanilla.mixin",
   "compatibilityLevel": "JAVA_8",
-  "mixins": [
-  ],
+  "mixins": [],
   "client": [
-      "HorseScreenMixin"
+    "HorseScreenMixin"
   ],
   "injectors": {
-      "defaultRequire": 1
+    "defaultRequire": 1
   }
 }