General Category > Coding

[Some common problems]

(1/1)

muCkk:
Incorrectly decompiled fields/methods
DecompiledFixedMinecraftServer.getWorldManager(int)MinecraftServer.getWorldServer(int)ModLoader.getMinecraftServerInstance().configManagerModLoader.getMinecraftServerInstance().serverConfigurationManager
Register Blocks after you created them - Use Blocks after you registered them

--- Code: ---public class mod_myMod extends BaseModMp {

  public static ModBlock myBlock;

  public mod_myMod() {
      myBlock = new ModBlock(...);
      ModLoader.RegisterBlock(...);
      [do something with that Block, recipe etc.]
  }
}

--- End code ---

Fixing enums
Before

--- Code: ---package net.minecraft.server;

public final class ThermometerVersion extends Enum
{
    public static final ThermometerVersion ANALOG;
    public static final ThermometerVersion DIGITAL;
    private static final ThermometerVersion $VALUES[];

    public static final ThermometerVersion[] values()
    {
        return (ThermometerVersion[])$VALUES.clone();
    }

    public static final ThermometerVersion valueOf(String s)
    {
        return (ThermometerVersion)Enum.valueOf(net.minecraft.server.ThermometerVersion.class, s);
    }
   
    public ThermometerVersion(String s, int i) {}
   
    static
    {
        ANALOG = new ThermometerVersion("ANALOG", 0);
        DIGITAL = new ThermometerVersion("DIGITAL", 1);
        $VALUES = (new ThermometerVersion[]
                {
                    ANALOG, DIGITAL
                });
    }
}
--- End code ---

Fixed

--- Code: ---package net.minecraft.server;

public enum ThermometerVersion
{

        ANALOG,
        DIGITAL;
}

--- End code ---

Fixed enum with values:

--- Code: ---package net.minecraft.server;

public enum MyEnum
{

        SOMENAME(5),
        ANOTHERNAME(12);

        private int intvar;

      private MyEnum(int i) {
          this.intvar = i;
      }
}

--- End code ---

Getting the worlds of a server
Before

--- Code: ---net.minecraft.server.WorldServer worldserver[] = ModLoader.getMinecraftServerInstance().worldMngr;
--- End code ---
After

--- Code: ---List<WorldServer> worldList = ModLoader.getMinecraftServerInstance().worlds;
net.minecraft.server.WorldServer worldserverHelper[] = new net.minecraft.server.WorldServer[worldList.size()];
net.minecraft.server.WorldServer worldserver[] = worldList.toArray(worldserverHelper);
--- End code ---

Create a config
ModloaderMP can create configs for you very easily. All you have to do is make the field for your config static and add an annotation. If you need a little more use Bukkits config API: Bukkit Wiki

In this example the default value would be 243:


--- Code: ---@MLProp(info="BlockID of my mod", max=256.0D, min=1.0D, name="myBlockID")
public static int myBlockID = 243;

--- End code ---

Navigation

[0] Message Index

Go to full version