Browse Source

new coding style

Kajetan Johannes Hammerle 3 years ago
parent
commit
269df9e051

+ 5 - 7
src/main/java/me/ktcm/KajetansTextCoreMod.java

@@ -7,14 +7,12 @@ import net.minecraftforge.fml.common.Mod;
 
 @Mod.EventBusSubscriber
 @Mod("ktcm")
-public class KajetansTextCoreMod
-{
+public class KajetansTextCoreMod {
     @SubscribeEvent
-    public static void beforeStart(ServerChatEvent e) 
-    {
+    public static void beforeStart(ServerChatEvent e) {
         e.setComponent(new StringTextComponent(
-            e.getMessage().replace("&", "§") + 
-            "§0█§1█§2█§3█§4█§5█§6█§7█§8█§9█§a█§b█§c█§d█§e█§f█" +
-            "§g█§h█§i█§j█§p█§q█§s█§t█§u█§v█§w█§x█§y█§z█"));
+                e.getMessage().replace("&", "§")
+                + "§0█§1█§2█§3█§4█§5█§6█§7█§8█§9█§a█§b█§c█§d█§e█§f█"
+                + "§g█§h█§i█§j█§p█§q█§s█§t█§u█§v█§w█§x█§y█§z█"));
     }
 }

+ 16 - 28
src/main/java/me/ktcm/ModTextFormatting.java

@@ -5,8 +5,7 @@ import javax.annotation.Nullable;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public enum ModTextFormatting
-{
+public enum ModTextFormatting {
     BLACK("BLACK", '0', 0, 0),
     DARK_BLUE("DARK_BLUE", '1', 1, 170),
     DARK_GREEN("DARK_GREEN", '2', 2, 43520),
@@ -46,9 +45,8 @@ public enum ModTextFormatting
     UNDERLINE("UNDERLINE", 'n', true),
     ITALIC("ITALIC", 'o', true),
     RESET("RESET", 'r', -1, null);
-    
-    private static int buildColor(float r, float g, float b)
-    {
+
+    private static int buildColor(float r, float g, float b) {
         int ir = (int) (255 * r);
         int ig = (int) (255 * g);
         int ib = (int) (255 * b);
@@ -63,18 +61,15 @@ public enum ModTextFormatting
     @Nullable
     private final Integer color;
 
-    private ModTextFormatting(String formattingName, char formattingCodeIn, int index, @Nullable Integer colorCode)
-    {
+    private ModTextFormatting(String formattingName, char formattingCodeIn, int index, @Nullable Integer colorCode) {
         this(formattingName, formattingCodeIn, false, index, colorCode);
     }
 
-    private ModTextFormatting(String formattingName, char formattingCodeIn, boolean fancyStylingIn)
-    {
+    private ModTextFormatting(String formattingName, char formattingCodeIn, boolean fancyStylingIn) {
         this(formattingName, formattingCodeIn, fancyStylingIn, -1, (Integer) null);
     }
 
-    private ModTextFormatting(String formattingName, char formattingCodeIn, boolean fancyStylingIn, int index, @Nullable Integer colorCode)
-    {
+    private ModTextFormatting(String formattingName, char formattingCodeIn, boolean fancyStylingIn, int index, @Nullable Integer colorCode) {
         this.name = formattingName;
         this.formattingCode = formattingCodeIn;
         this.fancyStyling = fancyStylingIn;
@@ -85,15 +80,13 @@ public enum ModTextFormatting
 
     @Nullable
     @OnlyIn(Dist.CLIENT)
-    public Integer func_211163_e()
-    {
+    public Integer func_211163_e() {
         return this.color;
     }
-    
+
     @Nullable
     @OnlyIn(Dist.CLIENT)
-    public Integer getColor()
-    {
+    public Integer getColor() {
         return this.color;
     }
 
@@ -102,30 +95,25 @@ public enum ModTextFormatting
     {
         return !this.fancyStyling;
     }
-    
+
     @OnlyIn(Dist.CLIENT)
-    public boolean isNormalStyle()
-    {
+    public boolean isNormalStyle() {
         return !this.fancyStyling;
     }
 
     @Nullable
     @OnlyIn(Dist.CLIENT)
-    public static ModTextFormatting fromFormattingCode(char formattingCodeIn)
-    {
+    public static ModTextFormatting fromFormattingCode(char formattingCodeIn) {
         return func_211165_a(formattingCodeIn);
     }
-    
+
     @Nullable
     @OnlyIn(Dist.CLIENT)
-    public static ModTextFormatting func_211165_a(char formattingCodeIn)
-    {
+    public static ModTextFormatting func_211165_a(char formattingCodeIn) {
         char c0 = Character.toString(formattingCodeIn).toLowerCase(Locale.ROOT).charAt(0);
 
-        for(ModTextFormatting textformatting : values())
-        {
-            if(textformatting.formattingCode == c0)
-            {
+        for(ModTextFormatting textformatting : values()) {
+            if(textformatting.formattingCode == c0) {
                 return textformatting;
             }
         }

+ 5 - 11
src/main/resources/class_transformer/font_renderer.js

@@ -17,11 +17,9 @@ function initializeCoreMod() {
                 var targetMethodName = ASMAPI.mapMethod("func_228081_c_"); // renderStringAtPos
                 var targetMethodDesc = "(Ljava/lang/String;FFIZLnet/minecraft/client/renderer/Matrix4f;Lnet/minecraft/client/renderer/IRenderTypeBuffer;ZII)F";                
 
-                for (var i in methods)
-                {
+                for (var i in methods) {
                     var method = methods[i];
-                    if (method.name.equals(targetMethodName) && method.desc.equals(targetMethodDesc))
-                    {
+                    if (method.name.equals(targetMethodName) && method.desc.equals(targetMethodDesc)) {
                         print(method.name + " " + method.desc);
                         transform(method);
                         break;
@@ -33,20 +31,16 @@ function initializeCoreMod() {
     };
 }
 
-function transform(method)
-{
+function transform(method) {
     var instrList = method.instructions;
     
     for (var i = 0; i < instrList.size(); ++i) {
         var instr = instrList.get(i);
-        if(instr instanceof MethodInsnNode && instr.owner.equals("net/minecraft/util/text/TextFormatting"))
-        {
+        if(instr instanceof MethodInsnNode && instr.owner.equals("net/minecraft/util/text/TextFormatting")) {
             instrList.remove(instr);
             instrList.insert(instrList.get(i - 1), new MethodInsnNode(instr.getOpcode(), "me/ktcm/ModTextFormatting", 
                 ASMAPI.mapMethod(instr.name), instr.desc.replace("net/minecraft/util/text/TextFormatting", "me/ktcm/ModTextFormatting"), false));
-        }
-        else if(instr instanceof FieldInsnNode && instr.owner.equals("net/minecraft/util/text/TextFormatting"))
-        {
+        } else if(instr instanceof FieldInsnNode && instr.owner.equals("net/minecraft/util/text/TextFormatting")) {
             instrList.remove(instr);
             instrList.insert(instrList.get(i - 1), new FieldInsnNode(instr.getOpcode(), "me/ktcm/ModTextFormatting", 
                 ASMAPI.mapField(instr.name), instr.desc.replace("net/minecraft/util/text/TextFormatting", "me/ktcm/ModTextFormatting")));