0

I am trying to work with a MinecraftForge method in a Bukkit plugin.

Here is my code so far:

NetworkManager ic2 = new ic2.core.IC2().network;
DimensionManager dmm = new net.minecraftforge.common.DimensionManager();
T worlds = dmm.getWorlds(); // What Data Type?

The problem is that the getWorlds() method seems to be a data type of in[] which eclipse doesn't recognise, so now I am stuck because I have no idea what datatype to make the worlds variable.

This is the getWorlds() method in the version of Forge I am using

public static in[] getWorlds() {
     return (in[]) worlds.values().toArray(new in[worlds.size()]);
}

Did some further digging and found this in the forge version I am using.

import in;

and then there is an "in" class in the class list; But it doesn't appear in the list in eclipse; It's the same jar as the one I decompiled.

Unihedron
  • 10,902
  • 13
  • 62
  • 72
Mattigins
  • 1,014
  • 9
  • 25
  • If you look at the [DimensionManager source code](https://github.com/Kiniamaro/MinecraftMod/blob/master/src/minecraft/net/minecraftforge/common/DimensionManager.java) you'll see that `DimensionManager#getWorlds` returns a `WorldServer[]` – BackSlash Jan 19 '14 at 11:38
  • So the data type should be "WorldServer"? that doesn't work either.. – Mattigins Jan 19 '14 at 11:41
  • No, the data type should be `WorldServer[]` – BackSlash Jan 19 '14 at 11:42
  • Also tried that, still same result. "Type mismatch: cannot convert from in[] to WorldServer[]" – Mattigins Jan 19 '14 at 11:43
  • Are you sure you have the correct API? – BackSlash Jan 19 '14 at 11:53
  • I just decompiled the version of Forge i am using (i can't use the latest) and here is what it look like `public static in[] getWorlds() { return (in[])worlds.values().toArray(new in[worlds.size()]); }` – Mattigins Jan 19 '14 at 11:54

1 Answers1

2

The reason why the getWorlds in the Forge library returns in[] is because of Mojang's obfuscation. Forge cannot modify every single reference to in to WorldServer because that would be too complex.

Because most of the classes used in Minecraft are part of the default package, they cannot be imported directly.

Mods are able to get past this limitation because they use have a special modules that converts references in the output bytecode to refer the the obfuscated classes.

You will need to compile your code against Bukkit using the Forge compiler.

hsun324
  • 549
  • 3
  • 9