Browse Source

update to 1.14

Kajetan Johannes Hammerle 4 years ago
parent
commit
a55fd90b29

+ 27 - 68
build.gradle

@@ -1,83 +1,42 @@
 buildscript {
     repositories {
+        maven { url = 'https://files.minecraftforge.net/maven' }
         jcenter()
-        maven { url = "http://files.minecraftforge.net/maven" }
+        mavenCentral()
     }
     dependencies {
-        classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
+        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
     }
 }
-apply plugin: 'net.minecraftforge.gradle.forge'
-//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
+apply plugin: 'net.minecraftforge.gradle'
+// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
+apply plugin: 'eclipse'
+apply plugin: 'maven-publish'
 
-version = "1.0"
-group = "me.hammerle.kcm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
-archivesBaseName = "kcm"
+version = '1.0'
+group = 'me.hammerle.kcm'
+archivesBaseName = 'kcm'
 
-sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
-compileJava {
-    sourceCompatibility = targetCompatibility = '1.8'
-}
+sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
 
 minecraft {
-    version = "1.12.2-14.23.0.2537"
-    runDir = "run"
-    
-    // the mappings can be changed at any time, and must be in the following format.
-    // snapshot_YYYYMMDD   snapshot are built nightly.
-    // stable_#            stables are built at the discretion of the MCP team.
-    // Use non-default mappings at your own risk. they may not always work.
-    // simply re-run your setup task after changing the mappings to update your workspace.
-    mappings = "snapshot_20171003"
-    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
-}
-
-dependencies {
-    // you may put jars on which you depend on in ./libs
-    // or you may define them like so..
-    //compile "some.group:artifact:version:classifier"
-    //compile "some.group:artifact:version"
-      
-    // real examples
-    //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev'  // adds buildcraft to the dev env
-    //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
-
-    // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
-    //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
-
-    // the deobf configurations:  'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
-    // except that these dependencies get remapped to your current MCP mappings
-    //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
-    //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
-
-    // for more info...
-    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
-    // http://www.gradle.org/docs/current/userguide/dependency_management.html
-}
-
-processResources {
-    // this will ensure that this task is redone when the versions change.
-    inputs.property "version", project.version
-    inputs.property "mcversion", project.minecraft.version
-
-    // replace stuff in mcmod.info, nothing else
-    from(sourceSets.main.resources.srcDirs) {
-        include 'mcmod.info'
-                
-        // replace version and mcversion
-        expand 'version':project.version, 'mcversion':project.minecraft.version
-    }
-        
-    // copy everything else except the mcmod.info
-    from(sourceSets.main.resources.srcDirs) {
-        exclude 'mcmod.info'
+    mappings channel: 'snapshot', version: '20190621-1.14.2'
+
+    runs {
+        client {
+            workingDirectory project.file('run')
+            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
+            property 'forge.logging.console.level', 'warn'
+        }
+
+        server {
+            workingDirectory project.file('run')
+            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
+            property 'forge.logging.console.level', 'info'
+        }
     }
 }
 
-jar 
-{
-    manifest 
-    {
-        attributes("FMLCorePlugin": "me.kcm.KajetansLoadingPlugin")
-    }
+dependencies {
+    minecraft 'net.minecraftforge:forge:1.14.2-26.0.55'
 }

+ 2 - 1
gradle.properties

@@ -1,3 +1,4 @@
 # Sets default memory used for gradle commands. Can be overridden by user or command line properties.
 # This is required to provide enough memory for the Minecraft decompilation process.
-org.gradle.jvmargs = -Xmx3G
+org.gradle.jvmargs=-Xmx3G
+org.gradle.daemon=false

+ 43 - 35
gradlew

@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
 
 ##############################################################################
 ##
@@ -6,20 +6,38 @@
 ##
 ##############################################################################
 
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
 
 APP_NAME="Gradle"
 APP_BASE_NAME=`basename "$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=""
+
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"
 
-warn ( ) {
+warn () {
     echo "$*"
 }
 
-die ( ) {
+die () {
     echo
     echo "$*"
     echo
@@ -30,6 +48,7 @@ die ( ) {
 cygwin=false
 msys=false
 darwin=false
+nonstop=false
 case "`uname`" in
   CYGWIN* )
     cygwin=true
@@ -40,31 +59,11 @@ case "`uname`" in
   MINGW* )
     msys=true
     ;;
+  NONSTOP* )
+    nonstop=true
+    ;;
 esac
 
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
-    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
-    ls=`ls -ld "$PRG"`
-    link=`expr "$ls" : '.*-> \(.*\)$'`
-    if expr "$link" : '/.*' > /dev/null; then
-        PRG="$link"
-    else
-        PRG=`dirname "$PRG"`"/$link"
-    fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
 # Determine the Java command to use to start the JVM.
@@ -90,7 +89,7 @@ location of your Java installation."
 fi
 
 # Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
     MAX_FD_LIMIT=`ulimit -H -n`
     if [ $? -eq 0 ] ; then
         if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -114,6 +113,7 @@ fi
 if $cygwin ; then
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+    JAVACMD=`cygpath --unix "$JAVACMD"`
 
     # We build the pattern for arguments to be converted via cygpath
     ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +154,19 @@ if $cygwin ; then
     esac
 fi
 
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
-    JVM_OPTS=("$@")
+# Escape application args
+save () {
+    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+    echo " "
 }
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+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" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"

+ 28 - 0
info

@@ -0,0 +1,28 @@
+* 683: aload_0
+* 684: new           net/minecraft/server/dedicated/DedicatedPlayerList
+* 687: dup
+* 688: aload_0
+* 689: invokespecial net/minecraft/server/dedicated/DedicatedPlayerList."<init>":(Lnet/minecraft/server/dedicated/DedicatedServer;)V
+* 692: invokevirtual net/minecraft/server/dedicated/DedicatedServer.setPlayerList:(Lnet/minecraft/server/management/PlayerList;)V
+
+1 -> [this]
+2 -> [playerlist, this]
+3 -> [playerlist, playerlist, this]
+4 -> [this, playerlist, playerlist, this]
+5 -> [playerlist, this]
+6 -> []
+
+this.setPlayerList(new DedicatedPlayerList(this));
+
+* 683: aload_0
+* 688: aload_0
+* 689: invokestatic me/kcm/events/Hooks.newPlayerList:()Lnet/minecraft/server/dedicated/DedicatedPlayerList;
+* 692: invokevirtual net/minecraft/server/dedicated/DedicatedServer.setPlayerList:(Lnet/minecraft/server/management/PlayerList;)V
+
+1 -> [this]
+2 -> [this, this]
+3 -> [playerlist, this]
+4 -> []
+
+this.setPlayerList(hook(this));
+

+ 20 - 0
runClient.launch

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+  <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="KajetansCoreMod"/>
+  <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.minecraftforge.userdev.LaunchTesting"/>
+  <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dforge.logging.console.level=debug -Dforge.logging.markers=SCAN,REGISTRIES,REGISTRYDUMP"/>
+  <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""/>
+  <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/run"/>
+  <mapAttribute key="org.eclipse.debug.core.environmentVariables">
+    <mapEntry key="MOD_CLASSES" value="examplemod%%/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/bin/main:examplemod%%/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/bin/main"/>
+    <mapEntry key="MCP_MAPPINGS" value="snapshot_20180921-1.13"/>
+    <mapEntry key="MCP_VERSION" value="20190213.203750"/>
+    <mapEntry key="FORGE_VERSION" value="25.0.219"/>
+    <mapEntry key="assetIndex" value="1.13.1"/>
+    <mapEntry key="assetDirectory" value="/home/kajetan/.gradle/caches/forge_gradle/assets"/>
+    <mapEntry key="nativesDirectory" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/build/natives"/>
+    <mapEntry key="FORGE_GROUP" value="net.minecraftforge"/>
+    <mapEntry key="target" value="fmluserdevclient"/>
+    <mapEntry key="MC_VERSION" value="1.13.2"/>
+  </mapAttribute>
+</launchConfiguration>

+ 17 - 0
runServer.launch

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+  <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="KajetansCoreMod"/>
+  <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.minecraftforge.userdev.LaunchTesting"/>
+  <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dforge.logging.console.level=debug -Dforge.logging.markers=SCAN,REGISTRIES,REGISTRYDUMP"/>
+  <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""/>
+  <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/run"/>
+  <mapAttribute key="org.eclipse.debug.core.environmentVariables">
+    <mapEntry key="MOD_CLASSES" value="examplemod%%/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/bin/main:examplemod%%/home/kajetan/Dropbox/Projekte/Informatik/Java/Minecraft/KajetansCoreMod/bin/main"/>
+    <mapEntry key="MCP_MAPPINGS" value="snapshot_20180921-1.13"/>
+    <mapEntry key="MCP_VERSION" value="20190213.203750"/>
+    <mapEntry key="FORGE_VERSION" value="25.0.219"/>
+    <mapEntry key="FORGE_GROUP" value="net.minecraftforge"/>
+    <mapEntry key="target" value="fmluserdevserver"/>
+    <mapEntry key="MC_VERSION" value="1.13.2"/>
+  </mapAttribute>
+</launchConfiguration>

+ 3 - 28
src/main/java/me/kcm/KajetansCoreMod.java

@@ -1,33 +1,8 @@
 package me.kcm;
 
 import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
 
-@Mod(modid = KajetansCoreMod.MODID, version = KajetansCoreMod.VERSION, name = KajetansCoreMod.NAME, acceptableRemoteVersions = "*")
-public class KajetansCoreMod 
+@Mod("kcm")
+public class KajetansCoreMod
 {
-    public static final String MODID = "kcm";
-    public static final String NAME = "Kajetans Core Mod";
-    public static final String VERSION = "0.0.1";
-    
-    @Mod.EventHandler
-    public void preInit(FMLPreInitializationEvent e) 
-    {
-        System.out.println(NAME + " is loading!");
-        /*net.minecraftforge.common.MinecraftForge.EVENT_BUS.register(new Object()
-            {
-                @net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-                public void wusi2(FarmlandTrampleEvent e) 
-                {
-                    e.setCanceled(true);
-                    System.out.println("Trample");
-                }
-                
-                @net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-                public void wusi3(PlayerTabListNameEvent e) 
-                {
-                    e.setName(new TextComponentString("§6[]§r" + e.getEntityPlayer().getName()));
-                }
-            });*/
-    }
-}
+}

+ 0 - 36
src/main/java/me/kcm/KajetansLoadingPlugin.java

@@ -1,36 +0,0 @@
-package me.kcm;
-
-import java.util.Map;
-import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
-
-public class KajetansLoadingPlugin implements IFMLLoadingPlugin
-{        
-    @Override
-    public String[] getASMTransformerClass() 
-    {
-        return new String[] {KajetansTransformer.class.getName()};
-    }
-
-    @Override
-    public String getModContainerClass() 
-    {
-        return null; //KajetansModContainer.class.getName();
-    }
-
-    @Override
-    public String getSetupClass() 
-    {
-        return null;//KajetansHooks.class.getName();
-    }
-
-    @Override
-    public void injectData(Map<String, Object> data) 
-    {
-    }
-
-    @Override
-    public String getAccessTransformerClass() 
-    {
-        return null;
-    }
-}

+ 0 - 669
src/main/java/me/kcm/KajetansTransformer.java

@@ -1,669 +0,0 @@
-package me.kcm;
-
-import me.kcm.events.*;
-import net.minecraft.launchwrapper.IClassTransformer;
-import net.minecraft.launchwrapper.Launch;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassWriter;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.FieldInsnNode;
-import org.objectweb.asm.tree.FrameNode;
-import org.objectweb.asm.tree.InsnList;
-import org.objectweb.asm.tree.InsnNode;
-import org.objectweb.asm.tree.JumpInsnNode;
-import org.objectweb.asm.tree.LabelNode;
-import org.objectweb.asm.tree.LineNumberNode;
-import org.objectweb.asm.tree.MethodInsnNode;
-import org.objectweb.asm.tree.MethodNode;
-import org.objectweb.asm.tree.VarInsnNode;
-
-public class KajetansTransformer implements IClassTransformer
-{
-    private final boolean obfuscated;
-    
-    public KajetansTransformer() 
-    {
-        Boolean ldev = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
-        if(ldev == null)
-        {
-            obfuscated = true;
-        }
-        else
-        {
-            obfuscated = !ldev;
-        }
-        //System.out.println(obfuscated);
-    }
-    
-    private void printPatch(String s)
-    {
-        System.out.println("|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾");
-        System.out.println("| Patching " + s);
-        System.out.println("|___________________________________________________");
-    }
-    
-    @Override
-    public byte[] transform(String old, String searge, byte[] bytes)
-    {
-        switch(searge)
-        {
-            /*case "net.minecraft.entity.EntityLivingBase":
-                printPatch(LivingDamageCalculationEvent.class.getSimpleName());
-                return patchDamageHook(old, bytes);*/
-            case "net.minecraft.entity.player.EntityPlayerMP":
-                printPatch(PlayerTabListNameEvent.class.getSimpleName());
-                return patchTabList(old, bytes);
-            case "net.minecraft.entity.Entity":
-                printPatch(FarmlandTrampleEvent.class.getSimpleName());
-                return patchEntityCanTrample(old, bytes);
-            case "net.minecraft.server.management.PlayerList":
-                printPatch("PlayerList");
-                return patchPlayerList(old, bytes);
-            case "net.minecraft.server.MinecraftServer":
-                printPatch("MinecraftServer");
-                return patchMinecraftServer(old, bytes);
-            case "net.minecraft.network.NetHandlerPlayServer":
-                printPatch("NetHandlerPlayServer");
-                return patchNetHandlerPlayServer(old, bytes);
-            /*case "net.minecraft.item.crafting.CraftingManager":
-                printPatch("CraftingManager");
-                return patchCraftingManager(old, bytes);*/
-        }
-        return bytes;
-    }
-    
-    /*ListIterator<AbstractInsnNode> list = ins.iterator();
-    while(list.hasNext())
-    {
-        AbstractInsnNode next = list.next();
-        System.out.println(getString(next));
-    }*/
-    
-    public byte[] patchDamageHook(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            // EntityLivingBase <--> vp
-            // damageEntity <--> func_70665_d <--> d
-            MethodNode mn;
-            if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("d")).filter(me -> "(Lur;F)V".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("damageEntity")).findAny().get();
-            }
-            
-            InsnList ins = mn.instructions;
-            ins.insert(ins.get(3), new VarInsnNode(Opcodes.FLOAD, 2));
-            if(obfuscated)
-            {
-                ins.insert(ins.get(4), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onDamageCalculation", "(Lvp;Lur;F)V", false));
-            }
-            else
-            {
-                ins.insert(ins.get(4), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onDamageCalculation", "(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/util/DamageSource;F)V", false));
-            }
-                       
-            while(ins.size() > 8)
-            {
-                ins.remove(ins.get(6));
-            }
-
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public byte[] patchTabList(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            // EntityPlayerMP <--> oq
-            // getTabListDisplayName <--> func_175396_E <--> K
-            // MD: oq/K ()Lhh; net/minecraft/entity/player/EntityPlayerMP/func_175396_E ()Lnet/minecraft/util/text/ITextComponent;
-            MethodNode mn;
-            if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("K")).filter(me -> "()Lhh;".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("getTabListDisplayName")).findAny().get();
-            }
-
-            InsnList ins = mn.instructions;
-            ins.remove(ins.get(2));
-            ins.insert(ins.get(1), new VarInsnNode(Opcodes.ALOAD, 0));
-            if(obfuscated)
-            {
-                ins.insert(ins.get(2), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onGetTabListDisplayName", "(Loq;)Lhh;", false));
-            }
-            else
-            {
-                ins.insert(ins.get(2), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onGetTabListDisplayName", "(Lnet/minecraft/entity/player/EntityPlayerMP;)Lnet/minecraft/util/text/ITextComponent;", false));
-            }
-            
-            
-            // patching setEntityActionState
-            // MD: net/minecraft/entity/player/EntityPlayerMP/setEntityActionState (FFZZ)V oq/a (FFZZ)V
-            /*if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("a")).filter(me -> "(FFZZ)V".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("setEntityActionState")).findAny().get();
-            }
-            ins = mn.instructions;
-            
-            if(obfuscated)
-            {
-                ins.insert(ins.get(1), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onSetEntityActionState", "(Loq;FFZZ)V", false));
-            }
-            else
-            {
-                ins.insert(ins.get(1), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onSetEntityActionState", "(Lnet/minecraft/entity/player/EntityPlayerMP;FFZZ)V", false));
-            }
-            ins.insert(ins.get(1), new VarInsnNode(Opcodes.ILOAD, 4));
-            ins.insert(ins.get(1), new VarInsnNode(Opcodes.ILOAD, 3));
-            ins.insert(ins.get(1), new VarInsnNode(Opcodes.FLOAD, 2));
-            ins.insert(ins.get(1), new VarInsnNode(Opcodes.FLOAD, 1));
-            ins.insert(ins.get(1), new VarInsnNode(Opcodes.ALOAD, 0));
-            
-            java.util.ListIterator<AbstractInsnNode> list = ins.iterator();
-            while(list.hasNext())
-            {
-                System.out.println(getString(list.next()));
-            }*/
-            
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public byte[] patchEntityCanTrample(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            // CL: vg net/minecraft/entity/Entity
-            // Entity <--> vg
-            // canTrample is forge function
-            // Lnet/minecraft/world/World;Lnet/minecraft/block/Block;Lnet/minecraft/util/math/BlockPos;F
-            // World <--> amu
-            // Block <--> aow
-            // BlockPos <--> et
-            MethodNode mn = classNode.methods.stream().filter(me -> me.name.equals("canTrample")).findAny().get();
-
-            InsnList ins = mn.instructions;
-
-            int i = ins.size();
-            LabelNode label = null;
-            int counter = 0;
-            while(counter < 3)
-            {
-                i--;
-                if(ins.get(i) instanceof LabelNode)
-                {
-                    counter++;
-                    label = (LabelNode) ins.get(i);
-                }
-            }
-            
-            while(ins.get(i).getOpcode() != Opcodes.IFLE)
-            {
-                i--;
-            }
-            
-            ins.insert(ins.get(i), new JumpInsnNode(Opcodes.IFEQ, label));
-            if(obfuscated)
-            {
-                ins.insert(ins.get(i), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onEntityCanTrample", "(Lvg;Lamu;Laow;Let;F)Z", false));
-            }
-            else
-            {
-                ins.insert(ins.get(i), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onEntityCanTrample", "(Lnet/minecraft/entity/Entity;Lnet/minecraft/world/World;"
-                            + "Lnet/minecraft/block/Block;Lnet/minecraft/util/math/BlockPos;F)Z", false));
-            }
-            ins.insert(ins.get(i), new VarInsnNode(Opcodes.FLOAD, 4));
-            ins.insert(ins.get(i), new VarInsnNode(Opcodes.ALOAD, 3));
-            ins.insert(ins.get(i), new VarInsnNode(Opcodes.ALOAD, 2));
-            ins.insert(ins.get(i), new VarInsnNode(Opcodes.ALOAD, 1));      
-            ins.insert(ins.get(i), new VarInsnNode(Opcodes.ALOAD, 0));    
-            
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public byte[] patchPlayerList(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            int index = 0;
-            AbstractInsnNode node;
-            // -----------------------------------------------------------------
-            // first part - inserting PlayerConnectionEvent hook
-            // -----------------------------------------------------------------
-            // EntityPlayerMP <--> oq
-            // initializeConnectionToPlayer <--> func_72355_a <--> a
-            //MD: pl/a (Lgw;Loq;)V net/minecraft/server/management/PlayerList/func_72355_a 
-            // (Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;)V
-            // CL: pa net/minecraft/network/NetHandlerPlayServer
-            // public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP playerIn, NetHandlerPlayServer nethandlerplayserver)
-            // its something else: (Lgw;Loq;Lpa;)V
-            // it seems forge is already overwriting this method
-            MethodNode mn = classNode.methods.stream().filter(me -> me.name.equals("initializeConnectionToPlayer")).findAny().get();
-            InsnList ins = mn.instructions;
-            // connection <--> field_71135_a <--> a
-            // FD: oq/a net/minecraft/entity/player/EntityPlayerMP/field_71135_a
-            // searching for line: p.connection = nethandlerplayserver;
-            String search = obfuscated ? "a" : "connection";
-            String playerOwner = obfuscated ? "oq" : "net/minecraft/entity/player/EntityPlayerMP";
-            boolean found = false;
-            while(index < ins.size())
-            {
-                node = ins.get(index);
-                if(node instanceof FieldInsnNode)
-                {
-                    FieldInsnNode field = (FieldInsnNode) node;
-                    if(field.name.equals(search) && field.owner.equals(playerOwner))
-                    {
-                        found = true;
-                        break;
-                    }
-                }
-                index++;
-            }
-            
-            if(!found)
-            {
-                System.out.println("Start of player connection was not found");
-                return bytes;
-            }
-            
-            node = ins.get(index);
-            if(obfuscated)
-            {
-                ins.insert(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onPlayerConnection", "(Loq;)V", false));
-            }
-            else
-            {
-                ins.insert(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onPlayerConnection", "(Lnet/minecraft/entity/player/EntityPlayerMP;)V", false));
-            }
-            ins.insert(node, new VarInsnNode(Opcodes.ALOAD, 2));
-            // -----------------------------------------------------------------
-            // end of first part - inserting PlayerConnectionEvent hook
-            // second part - removing join message
-            // -----------------------------------------------------------------
-            // func_70005_c_
-            // MD: aed/h_ ()Ljava/lang/String; net/minecraft/entity/player/EntityPlayer/func_70005_c_ ()Ljava/lang/String;
-            // Searching for: if (playerIn.getName().equalsIgnoreCase(s))
-            String start = "equalsIgnoreCase";
-            String startDesc = "(Ljava/lang/String;)Z";
-            
-            // func_148539_a
-            // MD: pl/a (Lhh;)V net/minecraft/server/management/PlayerList/func_148539_a (Lnet/minecraft/util/text/ITextComponent;)V
-            String end = obfuscated ? "a" : "sendMessage";
-            String endDesc = obfuscated ? "(Lhh;)V" : "(Lnet/minecraft/util/text/ITextComponent;)V";
-            
-            found = false;
-            while(index < ins.size())
-            {
-                node = ins.get(index);
-                if(node instanceof MethodInsnNode)
-                {
-                    MethodInsnNode mnode = (MethodInsnNode) node;
-                    if(mnode.name.equals(start) && mnode.desc.equals(startDesc))
-                    {
-                        found = true;
-                        break;
-                    }
-                }
-                index++;
-            }
-            
-            if(!found)
-            {
-                System.out.println("Start of player join message was not found");
-                return bytes;
-            }
-            
-            // moving to real start of the block "p.getName()..."
-            index -= 3;
-            while(true)
-            {
-                node = ins.get(index);
-                if(node instanceof MethodInsnNode)
-                {
-                    MethodInsnNode mnode = (MethodInsnNode) node;
-                    if(mnode.name.equals(end) && mnode.desc.equals(endDesc))
-                    {
-                        ins.remove(node);
-                        break;
-                    }
-                }
-                ins.remove(node);
-            }
-            
-            // -----------------------------------------------------------------
-            // end of second part - removing join message
-            // third part - inserting PlayerPreRespawnEvent hook
-            // -----------------------------------------------------------------
-            // recreatePlayerEntity <--> func_72368_a <--> a
-            // MD: pl/a (Loq;IZ)Loq; net/minecraft/server/management/PlayerList/func_72368_a 
-            // (Lnet/minecraft/entity/player/EntityPlayerMP;IZ)Lnet/minecraft/entity/player/EntityPlayerMP;
-            if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("a")).filter(me -> "(Loq;IZ)Loq;".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("recreatePlayerEntity")).findAny().get();
-            }
-            ins = mn.instructions;
-            node = ins.get(1);
-            if(obfuscated)
-            {
-                ins.insert(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onPlayerPreRespawn", "(Loq;IZ)V", false));
-            }
-            else
-            {
-                ins.insert(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onPlayerPreRespawn", "(Lnet/minecraft/entity/player/EntityPlayerMP;IZ)V", false));
-            }
-            ins.insert(node, new VarInsnNode(Opcodes.ILOAD, 3));
-            ins.insert(node, new VarInsnNode(Opcodes.ILOAD, 2));
-            ins.insert(node, new VarInsnNode(Opcodes.ALOAD, 1));
-            
-            // -----------------------------------------------------------------
-            // end of third part - inserting PlayerPreRespawnEvent hook
-            // -----------------------------------------------------------------
-            
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public byte[] patchMinecraftServer(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            // createCommandManager <--> func_175582_h <--> i
-            // MD: net/minecraft/server/MinecraftServer/i ()Ldh; 
-            // MD: chd/i ()Ldh; net/minecraft/server/integrated/IntegratedServer/func_175582_h
-            // ()Lnet/minecraft/command/ServerCommandManager;
-            MethodNode mn;
-            if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("i")).filter(me -> "()Ldh;".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("createCommandManager")).findAny().get();
-            }
-            
-            InsnList ins = mn.instructions;
-            
-            ins.remove(ins.get(2));
-            ins.remove(ins.get(2));
-            ins.remove(ins.get(3));
-            /*if(obfuscated)
-            {
-                ins.insert(ins.get(2), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onCreateCommandManager", "(Ldh;)Lme/kcm/command/ModServerCommandManager;", false));        
-            }
-            else
-            {*/
-                ins.insert(ins.get(2), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
-                    "onCreateCommandManager", "(Lnet/minecraft/server/MinecraftServer;)Lme/kcm/command/ModServerCommandManager;", false));     
-            //}
-            
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public byte[] patchNetHandlerPlayServer(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            // public void onDisconnect(ITextComponent reason)
-            // onDisconnect <--> func_147231_a <--> a
-            // MD: pa/a (Lhh;)V net/minecraft/network/NetHandlerPlayServer/func_147231_a (Lnet/minecraft/util/text/ITextComponent;)V
-            MethodNode mn;
-            if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("a")).filter(me -> "(Lhh;)V".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("onDisconnect")).findAny().get();
-            }
-            
-            InsnList ins = mn.instructions;
-            
-            // VarInsnNode  25  2  0
-            // FieldInsnNode  180  4  Lnet/minecraft/server/MinecraftServer; serverController net/minecraft/network/NetHandlerPlayServer
-            // MethodInsnNode  182  5  ()Lnet/minecraft/server/management/PlayerList; false getPlayerList net/minecraft/server/MinecraftServer
-            // VarInsnNode  25  2  2
-            // MethodInsnNode  182  5  (Lnet/minecraft/util/text/ITextComponent;)V false sendMessage net/minecraft/server/management/PlayerList
-            
-            // sendMessage <--> func_148539_a <--> a
-            // MD: pl/a (Lhh;)V net/minecraft/server/management/PlayerList/func_148539_a (Lnet/minecraft/util/text/ITextComponent;)V
-            
-            int index = 0;
-            AbstractInsnNode node;
-            String search = obfuscated ? "a" : "sendMessage";
-            String owner = obfuscated ? "pl" : "net/minecraft/server/management/PlayerList";
-            boolean found = false;
-            while(index < ins.size())
-            {
-                node = ins.get(index);
-                if(node instanceof MethodInsnNode)
-                {
-                    MethodInsnNode field = (MethodInsnNode) node;
-                    if(field.name.equals(search) && field.owner.equals(owner))
-                    {
-                        found = true;
-                        break;
-                    }
-                }
-                index++;
-            }
-            
-            if(!found)
-            {
-                System.out.println("Start of sendMessage was not found");
-                return bytes;
-            }
-            
-            index -= 4;
-            
-            for(int i = 0; i < 5; i++)
-            {
-                ins.remove(ins.get(index));
-            }
-            
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public byte[] patchCraftingManager(String c, byte[] bytes)
-    {
-        try
-        {
-            ClassNode classNode = new ClassNode();
-            ClassReader classReader = new ClassReader(bytes);
-            classReader.accept(classNode, 0);
-            
-            MethodNode mn;
-            if(obfuscated)
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("b")).filter(me -> "(Lafy;Lamu;)Lakt;".equals(me.desc)).findAny().get();
-            }
-            else
-            {
-                mn = classNode.methods.stream().filter(me -> me.name.equals("findMatchingRecipe")).findAny().get();
-            }
-            
-            InsnList ins = mn.instructions;
-
-            // sendMessage <--> func_148539_a <--> a
-            // MD: aku/b (Lafy;Lamu;)Lakt; net/minecraft/item/crafting/CraftingManager/func_192413_b
-            // (Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Lnet/minecraft/item/crafting/IRecipe;
-            
-            AbstractInsnNode node = ins.get(1);
-            ins.insert(node, new InsnNode(Opcodes.ARETURN));
-            if(obfuscated)
-            {
-                ins.insert(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onfindMatchingRecipe", "(Lafy;Lamu;)Lakt;", false));
-            }
-            else
-            {
-                ins.insert(node, new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", "onfindMatchingRecipe", 
-                    "(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Lnet/minecraft/item/crafting/IRecipe;", false));
-            }
-            ins.insert(node, new VarInsnNode(Opcodes.ALOAD, 1));
-            ins.insert(node, new VarInsnNode(Opcodes.ALOAD, 0));
-            
-            ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
-            classNode.accept(writer);
-            return writer.toByteArray();
-        }
-        catch(Exception ex)
-        {
-            ex.printStackTrace();
-        }       
-        return bytes;
-    }
-    
-    public String getString(AbstractInsnNode node)
-    {
-        StringBuilder sb = new StringBuilder();
-        sb.append(node.getClass().getSimpleName());
-        sb.append("  ");
-        sb.append(node.getOpcode());
-        sb.append("  ");
-        sb.append(node.getType());
-        sb.append("  ");
-        if(node instanceof LineNumberNode)
-        {
-            LineNumberNode n = (LineNumberNode) node;
-            sb.append(n.line);
-            sb.append(" ");
-            sb.append(n.start);
-        }
-        else if(node instanceof VarInsnNode)
-        {
-            VarInsnNode n = (VarInsnNode) node;
-            sb.append(n.var);
-        }
-        else if(node instanceof MethodInsnNode)
-        {
-            MethodInsnNode n = (MethodInsnNode) node;
-            sb.append(n.desc);
-            sb.append(" ");
-            sb.append(n.itf);
-            sb.append(" ");
-            sb.append(n.name);
-            sb.append(" ");
-            sb.append(n.owner);
-        }
-        else if(node instanceof FrameNode)
-        {
-            FrameNode n = (FrameNode) node;
-            if(n.local != null)
-            {
-                n.local.forEach(s -> {sb.append(s); sb.append(" ");});
-            }
-            if(n.stack != null)
-            {
-                n.stack.forEach(s -> {sb.append(s); sb.append(" ");});
-            }
-        }
-        else if(node instanceof InsnNode)
-        {
-        }
-        else if(node instanceof FieldInsnNode)
-        {
-            FieldInsnNode n = (FieldInsnNode) node;
-            sb.append(n.desc);
-            sb.append(" ");
-            sb.append(n.name);
-            sb.append(" ");
-            sb.append(n.owner);
-        }
-        return sb.toString();
-    }
-}

+ 0 - 47
src/main/java/me/kcm/command/ICommandManager.java

@@ -1,47 +0,0 @@
-package me.kcm.command;
-
-import net.minecraft.command.ICommand;
-import net.minecraft.command.ICommandSender;
-
-public interface ICommandManager 
-{
-    /** Called to check, if a command sender should be allowed to use a normal command
-     *
-     * @param cs the sender of the command
-     * @param perm the name of the permission, for commands this is their name
-     * @return true to allow the command, false to call {@link ICommandManager#printMissingPermission(ICommandSender, ICommand)}
-     */
-    public boolean hasPermission(ICommandSender cs, String perm);
-
-    /** This method is called, if there is no vanilla command available for the
-     * given name
-     * 
-     * @param cs the sender of the command
-     * @param command the command
-     * @param args arguments of the command, splitted at spaces
-     * @return true on success, false to call {@link ICommandManager#printMissingCommand(ICommandSender, String)}
-     */
-    public boolean executeCustomCommand(ICommandSender cs, String command, String[] args);
-    
-    /** Called, if there is no normal or custom command available
-     *
-     * @param cs the sender of the command
-     * @param command the command
-     */
-    public void printMissingCommand(ICommandSender cs, String command);
-    
-    /** Called if there is a normal command available but {@link ICommandManager#hasPermission(ICommandSender, String)}
-     * returned false
-     * 
-     * @param cs the sender of the command
-     * @param command the command
-     */
-    public void printMissingPermission(ICommandSender cs, ICommand command);
-    
-    /** Called if a command is registered from a registered domain.
-     * 
-     * @param command the command
-     * @param domain a registered command domain
-     */
-    public void onRegisterCommand(ICommand command, String domain);
-}

+ 0 - 198
src/main/java/me/kcm/command/ModServerCommandManager.java

@@ -1,198 +0,0 @@
-package me.kcm.command;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import javax.annotation.Nullable;
-import net.minecraft.command.ICommand;
-import net.minecraft.command.ICommandSender;
-import net.minecraft.command.ServerCommandManager;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.util.text.TextComponentTranslation;
-import net.minecraft.util.text.TextFormatting;
-import net.minecraftforge.event.CommandEvent;
-
-public class ModServerCommandManager extends ServerCommandManager
-{
-    private LinkedList<String> events = new LinkedList<>();
-    private ICommandManager manager;
-    
-    public ModServerCommandManager(MinecraftServer serverIn) 
-    {
-        super(serverIn);
-        // the manager must not be null
-        this.manager = new ICommandManager() 
-        {
-            @Override
-            public boolean hasPermission(ICommandSender cs, String perm) 
-            {
-                return true;
-            }
-
-            @Override
-            public boolean executeCustomCommand(ICommandSender cs, String command, String[] args) 
-            {
-                return false;
-            }
-
-            @Override
-            public void printMissingCommand(ICommandSender cs, String command) 
-            {
-            }
-
-            @Override
-            public void printMissingPermission(ICommandSender cs, ICommand command) 
-            {
-            }
-
-            @Override
-            public void onRegisterCommand(ICommand command, String domain)
-            {
-            }
-        };
-    }
-    
-    public void setPermissionManager(ICommandManager manager)
-    {
-        // the manager must not be null
-        if(manager == null)
-        {
-            throw new NullPointerException();
-        }
-        this.manager = manager;
-    }
-    
-    public void registerRegistryEvent(String s)
-    {
-        events.add(s);
-    }
-    
-    @Override
-    public void notifyListener(ICommandSender cs, ICommand command, int flags, String key, Object... args)
-    {
-        ITextComponent text = new TextComponentTranslation("chat.type.admin", new Object[] {cs.getName(), new TextComponentTranslation(key, args)});
-        text.getStyle().setColor(TextFormatting.GRAY);
-        text.getStyle().setItalic(true);
-        cs.sendMessage(text);
-    }
-    
-    private String[] dropFirstString(String[] input)
-    {
-        String[] astring = new String[input.length - 1];
-        System.arraycopy(input, 1, astring, 0, input.length - 1);
-        return astring;
-    }
-    
-    @Override
-    public int executeCommand(ICommandSender sender, String rawCommand)
-    {
-        rawCommand = rawCommand.trim();
-        if(rawCommand.startsWith("/"))
-        {
-            rawCommand = rawCommand.substring(1);
-        }
-
-        String[] args = rawCommand.split(" ");
-        String command = args[0].toLowerCase();
-        args = dropFirstString(args);
-        
-        if(manager.executeCustomCommand(sender, command, args))
-        {
-            return 1;
-        }
-        
-        ICommand icommand = this.getCommands().get(command);
-        if(icommand == null)
-        {
-            manager.printMissingCommand(sender, command);
-            return 0;
-        }
-        
-        if(manager.hasPermission(sender, icommand.getName()))
-        {
-            CommandEvent e = new CommandEvent(icommand, sender, args);
-            if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(e))
-            {
-                if(e.getException() != null)
-                {
-                    com.google.common.base.Throwables.propagateIfPossible(e.getException());
-                }
-                return 1;
-            }
-            if(e.getParameters() != null)
-            {
-                args = e.getParameters();
-            }
-            this.tryExecute(sender, args, icommand, rawCommand);
-        }
-        else
-        {
-            manager.printMissingPermission(sender, icommand);
-        }
-        return 1;
-    }
-
-    @Override
-    public List<String> getTabCompletions(ICommandSender sender, String input, @Nullable BlockPos pos)
-    {
-        String[] astring = input.split(" ", -1);
-        String command = astring[0];
-        if(astring.length == 1)
-        {
-            return Collections.<String>emptyList();
-            /*return this.getCommands().entrySet().stream()
-                    .filter(e -> (CommandBase.doesStringStartWith(command, e.getKey()) && 
-                            manager.hasPermission(sender, e.getKey())))
-                    .map(e -> e.getKey())
-                    .collect(Collectors.toList());*/
-        }
-        else if(astring.length > 1)
-        {
-            ICommand icommand = this.getCommands().get(command);
-            if(icommand != null && manager.hasPermission(sender, icommand.getName()))
-            {
-                return icommand.getTabCompletions(this.getServer(), sender, dropFirstString(astring), pos);
-            }
-        }
-        return Collections.<String>emptyList();
-    }
-
-    @Override
-    public List<ICommand> getPossibleCommands(ICommandSender sender)
-    {
-        return Collections.<ICommand>emptyList();
-        /*return this.getCommands().entrySet().stream()
-                    .filter(e -> manager.hasPermission(sender, e.getKey()))
-                    .map(e -> e.getValue())
-                    .collect(Collectors.toList());*/
-    }
-
-    @Override
-    public ICommand registerCommand(ICommand command)
-    {
-        String s = null;
-        out: for(StackTraceElement e : Thread.currentThread().getStackTrace())
-        {
-            String name = e.getClassName();
-            if(events == null)
-            {
-                events = new LinkedList<>();
-            }
-            for(String start : events)
-            {
-                if(name.startsWith(start))
-                {
-                    s = name;
-                    break out;
-                }
-            }
-        }
-        if(s != null)
-        {
-            manager.onRegisterCommand(command, s);
-        }
-        return super.registerCommand(command);
-    }
-}

+ 0 - 32
src/main/java/me/kcm/events/FarmlandTrampleEvent.java

@@ -1,32 +0,0 @@
-package me.kcm.events;
-
-import net.minecraft.block.state.IBlockState;
-import net.minecraft.entity.Entity;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.world.World;
-import net.minecraftforge.event.world.BlockEvent;
-import net.minecraftforge.fml.common.eventhandler.Cancelable;
-
-@Cancelable
-public class FarmlandTrampleEvent extends BlockEvent
-{
-    private final float fallDistance;
-    private final Entity ent;
-    
-    public FarmlandTrampleEvent(World world, BlockPos pos, IBlockState state, float fallDistance, Entity ent) 
-    {
-        super(world, pos, state);
-        this.fallDistance = fallDistance;
-        this.ent = ent;
-    }
-
-    public float getFallDistance() 
-    {
-        return fallDistance;
-    }
-
-    public Entity getEntity() 
-    {
-        return ent;
-    }
-}

+ 22 - 133
src/main/java/me/kcm/events/Hooks.java

@@ -1,146 +1,35 @@
 package me.kcm.events;
 
-import java.lang.reflect.Field;
-import me.kcm.command.ModServerCommandManager;
-import net.minecraft.block.Block;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.inventory.Container;
-import net.minecraft.inventory.ContainerPlayer;
-import net.minecraft.inventory.ContainerWorkbench;
-import net.minecraft.inventory.InventoryCrafting;
-import net.minecraft.item.crafting.CraftingManager;
-import net.minecraft.item.crafting.IRecipe;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.world.World;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.relauncher.ReflectionHelper;
+import java.util.function.Consumer;
+import net.minecraft.server.dedicated.DedicatedPlayerList;
+import net.minecraft.server.dedicated.DedicatedServer;
 
-public class Hooks 
+public class Hooks
 {
-    /*public static void onDamageCalculation(EntityLivingBase liv, DamageSource ds, float damage)
-    {
-        if(!liv.isEntityInvulnerable(ds))
-        {
-            MinecraftForge.EVENT_BUS.post(new LivingDamageCalculationEvent(liv, ds, damage));
-        }
-    }*/
-    
-    public static ITextComponent onGetTabListDisplayName(EntityPlayerMP p)
-    {
-        PlayerTabListNameEvent e = new PlayerTabListNameEvent(p);
-        MinecraftForge.EVENT_BUS.post(e);
-        return e.getName();
-    }
-    
-    public static void onSetEntityActionState(EntityPlayerMP p, float strafe, float forward, boolean jumping, boolean sneaking)
-    {
-        System.out.println("WUSI");
-    }
-    
-    public static boolean onEntityCanTrample(Entity ent, World w, Block b, BlockPos pos, float fallDistance)
-    {
-        return !MinecraftForge.EVENT_BUS.post(new FarmlandTrampleEvent(w, pos, w.getBlockState(pos), fallDistance, ent));
-    }
-    
-    public static void onPlayerConnection(EntityPlayerMP p)
-    {
-        MinecraftForge.EVENT_BUS.post(new PlayerConnectionEvent(p));
-    }
-    
-    public static void onPlayerPreRespawn(EntityPlayerMP p, int dimension, boolean conqueredEnd)
-    {
-        MinecraftForge.EVENT_BUS.post(new PlayerPreRespawnEvent(p));
-    }
-    
-    public static ModServerCommandManager onCreateCommandManager(MinecraftServer server)
-    {
-        return new ModServerCommandManager(server);
-    }
-    
-    public static IRecipe onfindMatchingRecipe(InventoryCrafting craftMatrix, World w)
-    {
-        for(IRecipe irecipe : CraftingManager.REGISTRY)
-        {
-            if(irecipe.matches(craftMatrix, w))
-            {
-                Container c = getContainerEventHandler(craftMatrix);
-                EntityPlayer p;
-                if(c == null)
-                {
-                    return null;
-                }
-                else if(c instanceof ContainerPlayer)
-                {
-                    p = getContainerPlayer((ContainerPlayer) c);
-                }
-                else if(c instanceof ContainerWorkbench)
-                {
-                    p = getContainerEventHandler((ContainerWorkbench) c);
-                }
-                else
-                {
-                    return null;
-                }
-                System.out.println(p);
-                RecipeChosenEvent e = new RecipeChosenEvent(p, irecipe);
-                if(MinecraftForge.EVENT_BUS.post(e))
-                {
-                    return null;
-                }
-                return e.getRecipe();
-            }
-        }
-        return null;
-    }
-    
-    private static Field getField(Class c, String... field)
+    private static Consumer<DedicatedServer> playerListFunction = null;
+
+    public static void setPlayerListFunction(Consumer<DedicatedServer> c)
     {
-        try
-        {
-            return ReflectionHelper.findField(c, field);
-        }
-        catch(SecurityException | ReflectionHelper.UnableToFindFieldException ex)
-        {
-            System.out.println(String.join(", ", field) + " - " + ex);
-        }
-        return null;
+        playerListFunction = c;
     }
-    
-    private static <T> T getFieldValue(Class<T> cast, Object o, Field f)
+
+    public static void setPlayerList(DedicatedServer server)
     {
-        try
+        if(playerListFunction != null)
         {
-            return (T) f.get(o);
+            playerListFunction.accept(server);
         }
-        catch(SecurityException | IllegalAccessException | IllegalArgumentException ex)
+        else
         {
-            System.out.println(f + " - " + ex);
-            return null;
+            try
+            {
+                server.setPlayerList(new DedicatedPlayerList(server));
+            }
+            catch(Exception ex)
+            {
+                // this is stupid and should not be needed
+                ex.printStackTrace();
+            }
         }
     }
-    
-    private final static Field CONTAINER_EVENT_HANDLER = getField(InventoryCrafting.class, "field_70465_c", "eventHandler");
-    
-    public static Container getContainerEventHandler(InventoryCrafting craftMatrix)
-    {
-        return getFieldValue(Container.class, craftMatrix, CONTAINER_EVENT_HANDLER);
-    }
-    
-    private final static Field CONTAINER_PLAYER = getField(ContainerPlayer.class, "field_82862_h", "player");
-    
-    public static EntityPlayer getContainerPlayer(ContainerPlayer cp)
-    {
-        return getFieldValue(EntityPlayer.class, cp, CONTAINER_PLAYER);
-    }
-    
-    private final static Field CONTAINER_WORKBENCH = getField(ContainerWorkbench.class, "field_192390_i", "player");
-    
-    public static EntityPlayer getContainerEventHandler(ContainerWorkbench cw)
-    {
-        return getFieldValue(EntityPlayer.class, cw, CONTAINER_WORKBENCH);
-    }
 }

+ 0 - 32
src/main/java/me/kcm/events/LivingDamageCalculationEvent.java

@@ -1,32 +0,0 @@
-package me.kcm.events;
-
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.util.DamageSource;
-import net.minecraftforge.event.entity.living.LivingEvent;
-
-public class LivingDamageCalculationEvent extends LivingEvent
-{
-    private final DamageSource source;
-    private float amount;
-    public LivingDamageCalculationEvent(EntityLivingBase liv, DamageSource source, float amount)
-    {
-        super(liv);
-        this.source = source;
-        this.amount = amount;
-    }
-
-    public DamageSource getSource() 
-    {
-        return source; 
-    }
-
-    public float getAmount() 
-    {
-        return amount; 
-    }
-
-    public void setAmount(float amount)
-    {
-        this.amount = amount; 
-    }
-}

+ 0 - 18
src/main/java/me/kcm/events/PlayerConnectionEvent.java

@@ -1,18 +0,0 @@
-package me.kcm.events;
-
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraftforge.event.entity.player.PlayerEvent;
-
-public class PlayerConnectionEvent extends PlayerEvent
-{
-    public PlayerConnectionEvent(EntityPlayerMP player) 
-    {
-        super(player);
-    }
-
-    @Override
-    public EntityPlayerMP getEntityPlayer() 
-    {
-        return (EntityPlayerMP) super.getEntityPlayer();
-    }
-}

+ 0 - 12
src/main/java/me/kcm/events/PlayerPreRespawnEvent.java

@@ -1,12 +0,0 @@
-package me.kcm.events;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraftforge.event.entity.player.PlayerEvent;
-
-public class PlayerPreRespawnEvent extends PlayerEvent
-{
-    public PlayerPreRespawnEvent(EntityPlayer player) 
-    {
-        super(player);
-    }
-}

+ 0 - 32
src/main/java/me/kcm/events/PlayerTabListNameEvent.java

@@ -1,32 +0,0 @@
-package me.kcm.events;
-;
-import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraftforge.event.entity.player.PlayerEvent;
-
-public class PlayerTabListNameEvent extends PlayerEvent
-{
-    private ITextComponent com;
-    
-    public PlayerTabListNameEvent(EntityPlayerMP p) 
-    {
-        super(p);
-        this.com = null;
-    }
-    
-    @Override
-    public EntityPlayerMP getEntityPlayer()
-    {
-        return (EntityPlayerMP) super.getEntityPlayer();
-    }
-
-    public ITextComponent getName() 
-    {
-        return com;
-    }
-
-    public void setName(ITextComponent com) 
-    {
-        this.com = com;
-    }
-}

+ 0 - 28
src/main/java/me/kcm/events/RecipeChosenEvent.java

@@ -1,28 +0,0 @@
-package me.kcm.events;
-
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.crafting.IRecipe;
-import net.minecraftforge.event.entity.player.PlayerEvent;
-import net.minecraftforge.fml.common.eventhandler.Cancelable;
-
-@Cancelable
-public class RecipeChosenEvent extends PlayerEvent
-{
-    private IRecipe recipe;
-    
-    public RecipeChosenEvent(EntityPlayer player, IRecipe recipe) 
-    {
-        super(player);
-        this.recipe = recipe;
-    }
-
-    public void setRecipe(IRecipe recipe) 
-    {
-        this.recipe = recipe;
-    }
-    
-    public IRecipe getRecipe() 
-    {
-        return recipe;
-    }
-}

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

@@ -0,0 +1,3 @@
+{
+    "Dedicated Server Transformer": "class_transformer/playerlist.js"
+}

+ 45 - 0
src/main/resources/META-INF/mods.toml

@@ -0,0 +1,45 @@
+# This is an example mods.toml file. It contains the data relating to the loading mods.
+# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
+# The overall format is standard TOML format, v0.5.0.
+# Note that there are a couple of TOML lists in this file.
+# Find more information on toml format here:  https://github.com/toml-lang/toml
+# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
+modLoader="javafml" #mandatory
+# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
+loaderVersion="[26,)" #mandatory (24 is current forge version)
+# A URL to refer people to when problems occur with this mod
+#issueTrackerURL="http://my.issue.tracker/" #optional
+# A list of mods - how many allowed here is determined by the individual mod loader
+[[mods]] #mandatory
+# The modid of the mod
+modId="kcm" #mandatory
+# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
+version="0.0.1" #mandatory
+ # A display name for the mod
+displayName="Kajetans Core Mod" #mandatory
+# A URL to query for updates for this mod. See the JSON update specification <here>
+#updateJSONURL="http://myurl.me/" #optional
+# A URL for the "homepage" for this mod, displayed in the mod UI
+#displayURL="http://example.com/" #optional
+# A file name (in the root of the mod JAR) containing a logo for display
+#logoFile="examplemod.png" #optional
+# A text field displayed in the mod UI
+credits="kajetanjohannes" #optional
+# A text field displayed in the mod UI
+authors="kajetanjohannes" #optional
+# The description text for the mod (multi line!) (#mandatory)
+description='''
+Kajetans Core Mod for Mundus Crassus
+'''
+# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
+#[[dependencies.examplemod]] #optional
+    # the modid of the dependency
+    #modId="forge" #mandatory
+    # Does this dependency have to exist - if not, ordering below must be specified
+    #mandatory=true #mandatory
+    # The version range of the dependency
+    #versionRange="[25,)" #mandatory
+    # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
+    #ordering="NONE"
+    # Side this dependency is applied on - BOTH, CLIENT or SERVER
+    #side="BOTH"

+ 56 - 0
src/main/resources/class_transformer/playerlist.js

@@ -0,0 +1,56 @@
+var transformerName = "Dedicated Server Transformer";
+var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI');
+var Opcodes = Java.type('org.objectweb.asm.Opcodes');
+var VarInsnNode = Java.type("org.objectweb.asm.tree.VarInsnNode");
+var MethodInsnNode = Java.type("org.objectweb.asm.tree.MethodInsnNode");
+var LineNumberNode = Java.type("org.objectweb.asm.tree.LineNumberNode");
+
+function initializeCoreMod() {
+    return {
+        transformerName: {
+            'target': {
+                'type': 'CLASS',
+                'name': 'net.minecraft.server.dedicated.DedicatedServer'
+            },
+            'transformer': function (classNode) {
+                var methods = classNode.methods;
+
+                var targetMethodName = ASMAPI.mapMethod("func_71197_b"); // init
+                var targetMethodDesc = "()Z";
+
+                for (var i in methods)
+                {
+                    var method = methods[i];
+                    if (method.name.equals(targetMethodName) && method.desc.equals(targetMethodDesc))
+                    {
+                        transform(method);
+                        break;
+                    }
+                }
+                return classNode;
+            }
+        }
+    };
+}
+
+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/events/Hooks", 
+                "setPlayerList", "(Lnet/minecraft/server/dedicated/DedicatedServer;)V", false));
+            break;
+        }
+    }
+}

+ 109 - 0
src/main/resources/class_transformer/test.js

@@ -0,0 +1,109 @@
+var transformerName = "Dedicated Server Transformer";
+var ASMAPI = Java.type('net.minecraftforge.coremod.api.ASMAPI');
+var Opcodes = Java.type('org.objectweb.asm.Opcodes');
+var VarInsnNode = Java.type("org.objectweb.asm.tree.VarInsnNode");
+var MethodInsnNode = Java.type("org.objectweb.asm.tree.MethodInsnNode");
+var LineNumberNode = Java.type("org.objectweb.asm.tree.LineNumberNode");
+
+function initializeCoreMod() {
+    return {
+        transformerName: {
+            'target': {
+                'type': 'CLASS',
+                'name': 'net.minecraft.server.dedicated.DedicatedServer'
+            },
+            'transformer': function (classNode) {
+                var methods = classNode.methods;
+
+                var targetMethodName = ASMAPI.mapMethod("func_71197_b"); // init
+                var targetMethodDesc = "()Z";
+
+                for (var i in methods)
+                {
+                    var method = methods[i];
+
+                    print(method.name + " " + method.desc);
+                    if (method.name.equals(targetMethodName) && method.desc.equals(targetMethodDesc))
+                    {
+                        transform(method);
+                        break;
+                    }
+                }
+                return classNode;
+            }
+        }
+    };
+}
+
+function transform(method)
+{
+    print("Match found " + method.name + " " + method.desc);
+    var instrList = method.instructions;
+    
+    /*instrList.remove(instrList.get(2));
+    instrList.insert(instrList.get(1), new VarInsnNode(Opcodes.ALOAD, 0));
+    instrList.insert(instrList.get(2), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
+        "onGetTabListDisplayName", "(Lnet/minecraft/entity/player/EntityPlayerMP;)Lnet/minecraft/util/text/ITextComponent;", false));*/
+    
+    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")
+        {
+            print("_________________________________________");
+            for(var j = -10; j < 10; j++)
+            {
+                printInstr(instrList.get(i + j));
+            }
+                           
+            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/events/Hooks", 
+            //    "newPlayerList", "(Lnet/minecraft/server/dedicated/DedicatedServer;)Lnet/minecraft/server/dedicated/DedicatedPlayerList;", false));
+            //instrList.insert(instrList.get(i - 3), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
+            //    "newPlayerList", "()Lnet/minecraft/server/dedicated/DedicatedPlayerList;", false));
+            instrList.insert(instrList.get(i - 4), new MethodInsnNode(Opcodes.INVOKESTATIC, "me/kcm/events/Hooks", 
+                "setPlayerList", "(Lnet/minecraft/server/dedicated/DedicatedServer;)V", false));
+                
+            print("_________________________________________");
+            for(var j = -10; j < 10; j++)
+            {
+                printInstr(instrList.get(i + j));
+            }
+            break;
+        }
+    }
+}
+
+function printInstr(instr)
+{
+    if(instr.getOpcode() == -1)
+    {
+        return;
+    }
+    var out = "> ";
+    out += instr.getOpcode();
+    out += "_";
+    out += instr.getType();
+    
+    if(instr instanceof VarInsnNode)
+    {
+        out += " Var: " + instr.var;
+    }
+    else if(instr instanceof MethodInsnNode)
+    {
+        out += " " + instr.owner + "." + instr.name + ":" + instr.desc;
+    }
+    else if(instr instanceof FieldInsnNode)
+    {
+        out += " " + instr.owner + "." + instr.name + ":" + instr.desc;
+    }
+    //out += " " + instr;
+    print(out);
+}

+ 0 - 16
src/main/resources/mcmod.info

@@ -1,16 +0,0 @@
-[
-{
-  "modid": "kcm",
-  "name": "Kajetans Core Mod",
-  "description": "Kajetans Core Mod für Mundus Crassus",
-  "version": "${version}",
-  "mcversion": "${mcversion}",
-  "url": "",
-  "updateUrl": "",
-  "authorList": ["kajetanjohannes"],
-  "credits": "kajetanjohannes",
-  "logoFile": "",
-  "screenshots": [],
-  "dependencies": []
-}
-]

+ 7 - 0
src/main/resources/pack.mcmeta

@@ -0,0 +1,7 @@
+{
+    "pack": {
+        "description": "kcm resources",
+        "pack_format": 4,
+        "_comment": "A pack_format of 4 requires json lang files. Note: we require v4 pack meta for all mods."
+    }
+}