Prechádzať zdrojové kódy

Updated fabric version; Added: togglefps, togglecoords, toggledirection, alignash and resetash commands;

umollu 6 rokov pred
rodič
commit
c82ea4b987

+ 1 - 1
build.gradle

@@ -1,5 +1,5 @@
 plugins {
-	id 'fabric-loom' version '0.2.0-SNAPSHOT'
+	id 'fabric-loom' version '0.2.2-SNAPSHOT'
 	id 'maven-publish'
 }
 

+ 5 - 5
gradle.properties

@@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G
 
 # Fabric Properties
 	# check these on https://fabricmc.net/use
-	minecraft_version=19w09a
-	yarn_mappings=19w09a.5
-	loader_version=0.3.7.109
+	minecraft_version=1.14
+	yarn_mappings=1.14+build.3
+	loader_version=0.4.2+build.132
 
 # Mod Properties
-	mod_version = 1.1.0
+	mod_version = 1.1.1
 	maven_group = com.umollu
 	archives_base_name = ash
 
 # Dependencies
 	# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric
-	fabric_version=0.2.3.109
+	fabric_version=0.2.7+build.127

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

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

+ 8 - 0
src/main/java/com/umollu/ash/AshConfig.java

@@ -13,6 +13,14 @@ public class AshConfig {
 
     public int hudColor = 0xeeeeee;
 
+    public boolean showFps = true;
+
+    public boolean showCoords = true;
+
+    public boolean showDirection = true;
+
+    public int align = 0;
+
     public void saveConfig() {
         String configPath = FabricLoader.getInstance().getConfigDirectory() + "/" + AshMod.MOD_ID + ".json";
         File configFile = new File(configPath);

+ 64 - 6
src/main/java/com/umollu/ash/AshMod.java

@@ -5,7 +5,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
 import net.fabricmc.api.ModInitializer;
 import net.fabricmc.fabric.api.registry.CommandRegistry;
 import net.fabricmc.loader.api.FabricLoader;
-import net.minecraft.server.command.ServerCommandManager;
+import net.minecraft.server.command.CommandManager;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -53,7 +53,7 @@ public class AshMod implements ModInitializer {
 
 
         CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
-                ServerCommandManager.literal("toggleash")
+                CommandManager.literal("toggleash")
                         .executes(context -> {
                             config.showHud = !config.showHud;
                             config.saveConfig();
@@ -62,10 +62,37 @@ public class AshMod implements ModInitializer {
         ));
 
         CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
-                ServerCommandManager.literal("ashcolor")
-                        .then(ServerCommandManager.argument("r", IntegerArgumentType.integer())
-                                .then(ServerCommandManager.argument("g", IntegerArgumentType.integer())
-                                        .then(ServerCommandManager.argument("b", IntegerArgumentType.integer())
+                CommandManager.literal("togglefps")
+                        .executes(context -> {
+                            config.showFps = !config.showFps;
+                            config.saveConfig();
+                            return 1;
+                        })
+        ));
+
+        CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
+                CommandManager.literal("togglecoords")
+                        .executes(context -> {
+                            config.showCoords = !config.showCoords;
+                            config.saveConfig();
+                            return 1;
+                        })
+        ));
+
+        CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
+                CommandManager.literal("toggledirection")
+                        .executes(context -> {
+                            config.showDirection = !config.showDirection;
+                            config.saveConfig();
+                            return 1;
+                        })
+        ));
+
+        CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
+                CommandManager.literal("ashcolor")
+                        .then(CommandManager.argument("r", IntegerArgumentType.integer())
+                                .then(CommandManager.argument("g", IntegerArgumentType.integer())
+                                        .then(CommandManager.argument("b", IntegerArgumentType.integer())
                                             .executes(context -> {
                                                 int r = IntegerArgumentType.getInteger(context,"r");
                                                 int g = IntegerArgumentType.getInteger(context,"g");
@@ -76,5 +103,36 @@ public class AshMod implements ModInitializer {
                                                 return 1;
                                 }))))
         ));
+
+        CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
+                CommandManager.literal("resetash")
+                        .executes(context -> {
+                            config = new AshConfig();
+                            config.saveConfig();
+                            return 1;
+                        })
+        ));
+
+        CommandRegistry.INSTANCE.register(false, serverCommandSourceCommandDispatcher -> serverCommandSourceCommandDispatcher.register(
+                CommandManager.literal("alignash")
+                        .then(CommandManager.literal("left")
+                        .executes(context -> {
+                            config.align = 0;
+                            config.saveConfig();
+                            return 1;
+                        }))
+                        .then(CommandManager.literal("center")
+                        .executes(context -> {
+                            config.align = 1;
+                            config.saveConfig();
+                            return 1;
+                        }))
+                        .then(CommandManager.literal("right")
+                        .executes(context -> {
+                            config.align = 2;
+                            config.saveConfig();
+                            return 1;
+                        }))
+        ));
     }
 }

+ 27 - 2
src/main/java/com/umollu/ash/mixin/GameRendererMixin.java

@@ -3,10 +3,12 @@ package com.umollu.ash.mixin;
 import com.umollu.ash.AshMod;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.render.GameRenderer;
+import net.minecraft.entity.Entity;
 import net.minecraft.util.math.BlockPos;
 
 import com.mojang.blaze3d.platform.GlStateManager;
 
+import net.minecraft.util.math.Direction;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.injection.At;
 import org.spongepowered.asm.mixin.injection.Inject;
@@ -19,12 +21,35 @@ public class GameRendererMixin {
 	public void render(float float_1, long long_1, boolean boolean_1, CallbackInfo info) {
 
 		MinecraftClient client = MinecraftClient.getInstance();
+		Entity cameraEntity = client.getCameraEntity();
+
 		if(!client.options.debugEnabled && AshMod.config.showHud) {
-			BlockPos blockPos = new BlockPos(client.getCameraEntity().x, client.getCameraEntity().getBoundingBox().minY, client.getCameraEntity().z);
 			double scaleFactor = client.window.getScaleFactor();
 			GlStateManager.pushMatrix();
 			GlStateManager.scaled(1 * scaleFactor, 1 * scaleFactor, 1 * scaleFactor);
-			client.textRenderer.drawWithShadow(String.format("%d fps %d %d %d", MinecraftClient.getCurrentFps(), blockPos.getX(), blockPos.getY(), blockPos.getZ()), 5, 5, AshMod.config.hudColor);
+			String ashString = "";
+			if(AshMod.config.showFps) {
+				ashString += String.format("%d fps ", MinecraftClient.getCurrentFps());
+			}
+			if(AshMod.config.showCoords) {
+				BlockPos blockPos = new BlockPos(cameraEntity.x, cameraEntity.getBoundingBox().minY, cameraEntity.z);
+				ashString += String.format("%d %d %d ", blockPos.getX(), blockPos.getY(), blockPos.getZ());
+			}
+			if(AshMod.config.showDirection) {
+				Direction direction = cameraEntity.getHorizontalFacing();
+				ashString += String.format("%5s ", direction);
+			}
+
+			float textPosX = 5;
+
+			if (AshMod.config.align == 1) {
+				textPosX = (client.window.getScaledWidth() - client.textRenderer.getStringWidth(ashString)) / 2f - textPosX;
+			}
+			if (AshMod.config.align == 2) {
+				textPosX = client.window.getScaledWidth() - client.textRenderer.getStringWidth(ashString) - textPosX;
+			}
+
+			client.textRenderer.drawWithShadow(ashString, textPosX, 5, AshMod.config.hudColor);
 			GlStateManager.popMatrix();
 		}
 	}