Browse Source

first update to Minecraft 1.16.4

Kajetan Johannes Hammerle 3 years ago
parent
commit
d1d6d5b5b5

+ 7 - 2
build.gradle

@@ -16,7 +16,7 @@ group = 'me.hammerle.kcm'
 archivesBaseName = 'kcm'
 
 minecraft {
-    mappings channel: 'snapshot', version: '20200514-1.15.1'
+    mappings channel: 'snapshot', version: '20201028-1.16.3'
 
     runs {
         client {
@@ -33,6 +33,11 @@ minecraft {
     }
 }
 
+apply plugin: 'java'
+compileJava {
+    options.compilerArgs << '--release' << '8'
+}
+
 dependencies {
-    minecraft 'net.minecraftforge:forge:1.15.2-31.2.21'
+    minecraft 'net.minecraftforge:forge:1.16.4-35.1.13'
 }

+ 19 - 8
src/main/java/me/kcm/BlockHarvest.java

@@ -14,24 +14,35 @@ import net.minecraft.server.dedicated.DedicatedPlayerList;
 import net.minecraft.server.dedicated.DedicatedServer;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.registry.DynamicRegistries;
 import net.minecraft.world.World;
 import net.minecraft.world.server.ServerWorld;
+import net.minecraft.world.storage.PlayerData;
 
 public class Hooks {
-    private static Consumer<DedicatedServer> playerListFunction = null;
+    @FunctionalInterface
+    public interface PlayerListFunction {
+        public void accept(DedicatedServer server, DynamicRegistries.Impl impl, PlayerData pd);
+    }
+
+    private static PlayerListFunction playerListFunction = null;
     private static BlockHarvest blockHarvest = (state, w, pos, tileEnt, ent, stack) -> Collections.EMPTY_LIST;
-    private static Craft craft = (id, w, p, cInv, slot) -> {};
+    private static Craft craft = (id, w, p, cInv, slot) -> {
+    };
 
-    public static void setPlayerListFunction(Consumer<DedicatedServer> c) {
+    public static void setPlayerListFunction(PlayerListFunction c) {
         playerListFunction = c;
     }
 
-    public static void setPlayerList(DedicatedServer server) {
+    public static void setPlayerList(DedicatedServer server, DynamicRegistries.Impl impl, PlayerData pd) {
+        System.out.println("trying to update player list ...");
         if(playerListFunction != null) {
-            playerListFunction.accept(server);
+            playerListFunction.accept(server, impl, pd);
+            System.out.println("succeeded with custom function");
         } else {
             try {
-                server.setPlayerList(new DedicatedPlayerList(server));
+                server.setPlayerList(new DedicatedPlayerList(server, impl, pd));
+                System.out.println("succeeded with vanilla function");
             } catch(Exception ex) {
                 // this is stupid and should not be needed
                 ex.printStackTrace();
@@ -42,7 +53,7 @@ public class Hooks {
     public static void setBlockHarvest(BlockHarvest c) {
         blockHarvest = c;
     }
-    
+
     public static void setCraft(Craft c) {
         craft = c;
     }
@@ -54,7 +65,7 @@ public class Hooks {
     public static List<ItemStack> getDropsB(BlockState state, ServerWorld w, BlockPos pos, @Nullable TileEntity tileEnt, @Nullable Entity ent, ItemStack stack) {
         return blockHarvest.onBlockHarvest(state, w, pos, tileEnt, ent, stack);
     }
-    
+
     public static void onCraft(int id, World w, PlayerEntity p, CraftingInventory cInv, CraftResultInventory slot) {
         craft.onCraft(id, w, p, cInv, slot);
     }

+ 3 - 2
src/main/resources/META-INF/coremods.json

@@ -1,8 +1,9 @@
 modLoader="javafml"
-loaderVersion="[31,)"
+loaderVersion="[35,)"
+license="All rights reserved"
 [[mods]]
 modId="kcm" #mandatory
-version="0.0.1"
+version="0.0.2"
 displayName="Kajetans Core Mod"
 credits="kajetanjohannes"
 authors="kajetanjohannes"

+ 7 - 11
src/main/resources/class_transformer/block.js

@@ -31,21 +31,17 @@ 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.getOpcode() == 183 && instr instanceof MethodInsnNode && instr.owner == "net/minecraft/server/dedicated/DedicatedPlayerList") {
-            instrList.remove(instrList.get(i - 4));
-            instrList.remove(instrList.get(i - 4));
-            instrList.remove(instrList.get(i - 4));
-            instrList.remove(instrList.get(i - 4));
-            instrList.remove(instrList.get(i - 4));
-            instrList.remove(instrList.get(i - 4));
-            instrList.insert(instrList.get(i - 5), new VarInsnNode(Opcodes.ALOAD, 0));
-            instrList.insert(instrList.get(i - 4), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/Hooks",
-                    "setPlayerList", "(Lnet/minecraft/server/dedicated/DedicatedServer;)V", false));
+            instrList.remove(instrList.get(i));
+            instrList.remove(instrList.get(i));
+            instrList.insert(instrList.get(i), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/Hooks",
+                    "setPlayerList",
+                    "(Lnet/minecraft/server/dedicated/DedicatedServer;Lnet/minecraft/util/registry/DynamicRegistries$Impl;Lnet/minecraft/world/storage/PlayerData;)V",
+                    false));
             break;
         }
     }

+ 1 - 2
src/main/resources/class_transformer/test.js

@@ -1,7 +1,6 @@
 {
     "pack": {
         "description": "kcm resources",
-        "pack_format": 5,
-        "_comment": "A pack_format of 5 requires json lang files and some texture changes from 1.15. Note: we require v5 pack meta for all mods."
+        "pack_format": 6
     }
 }