I am rewritting CCPortable, a mod that adds PDAs to Computercraft and I'm stuck on the TileEntity part.
I think the code is correct (and eclipse doesn't give errors) but when i lauch it, I get this crash log:
2013-02-13 12:07:36 [FINER] [ForgeModLoader] Sending event FMLConstructionEvent to mod CCPortable
2013-02-13 12:07:36 [INFO] [STDERR] Exception in thread "Minecraft main thread" java.lang.NoClassDefFoundError: CCPortable/common/TileEntityPDA
2013-02-13 12:07:36 [INFO] [STDERR] at java.lang.Class.getDeclaredMethods0(Native Method)
2013-02-13 12:07:36 [INFO] [STDERR] at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
2013-02-13 12:07:36 [INFO] [STDERR] at java.lang.Class.getDeclaredMethods(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.common.FMLModContainer.gatherAnnotations(FMLModContainer.java:310)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:455)
2013-02-13 12:07:37 [INFO] [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-02-13 12:07:37 [INFO] [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:140)
2013-02-13 12:07:37 [INFO] [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-02-13 12:07:37 [INFO] [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
2013-02-13 12:07:37 [INFO] [STDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:268)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:83)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.common.Loader.loadMods(Loader.java:479)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:161)
2013-02-13 12:07:37 [INFO] [STDERR] at net.minecraft.client.Minecraft.a(Minecraft.java:410)
2013-02-13 12:07:37 [INFO] [STDERR] at asq.a(SourceFile:56)
2013-02-13 12:07:37 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:744)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.Thread.run(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] Caused by: java.lang.ClassNotFoundException: CCPortable.common.TileEntityPDA
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:185)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] ... 31 more
2013-02-13 12:07:37 [INFO] [STDERR] Caused by: java.lang.NoClassDefFoundError: dan200/computer/api/IPeripheral
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.ClassLoader.defineClass1(Native Method)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.ClassLoader.defineClass(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at java.security.SecureClassLoader.defineClass(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:174)
2013-02-13 12:07:37 [INFO] [STDERR] ... 33 more
2013-02-13 12:07:37 [INFO] [STDERR] Caused by: java.lang.ClassNotFoundException: dan200.computer.api.IPeripheral
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:185)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at java.lang.ClassLoader.loadClass(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] ... 37 more
2013-02-13 12:07:37 [INFO] [STDERR] Caused by: java.lang.NullPointerException
2013-02-13 12:07:37 [INFO] [STDERR] at org.objectweb.asm.ClassReader.<init>(Unknown Source)
2013-02-13 12:07:37 [INFO] [STDERR] at net.minecraftforge.transformers.EventTransformer.transform(EventTransformer.java:29)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:228)
2013-02-13 12:07:37 [INFO] [STDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:173)
2013-02-13 12:07:37 [INFO] [STDERR] ... 39 more
Here is the code of the TileEntity:
package CCPortable.common;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public class TileEntityPDA extends TileEntity implements IPeripheral {
public IComputerAccess computer;
public int id;
public int pda;
public int side = -1;
// public static World world;
@Override
public String getType() {
return "PDA_receiver";
}
@Override
public String[] getMethodNames() {
String[] methods = { "alert", "write", "setCursorPos" };
return methods;
// ME WANT TERM FUNCTIONS
}
@Override
public Object[] callMethod(IComputerAccess computer, int method,
Object[] arg) throws Exception {
EntityPlayer ply = (EntityPlayer) CCPortable.allPLYs.get(this.pda);
ObjectPDA pda = (ObjectPDA) CCPortable.allPDAs.get(this.pda);
switch (method) {
case 0:
if (arg.length == 2 && arg[0] instanceof Double && arg[1] instanceof Double)
this.worldObj.addBlockEvent((int) ply.posX, (int) ply.posY,
(int) ply.posZ, Block.music.blockID, (Integer) arg[0],
(Integer) arg[1]);
else
throw new Exception("Invalid arguments to function");
case 1:
if (arg.length == 1 && arg[0] instanceof String) {
pda.write((String) arg[0]);
CCPortable.allPDAs.put(this.pda, pda);
} else {
throw new Exception("Invalid arguments to function");
}
case 2:
if (arg.length == 2 && arg[0] instanceof Double && arg[1] instanceof Double) {
pda.setCursorPos((Integer) arg[0], (Integer) arg[1]);
CCPortable.allPDAs.put(this.pda, pda);
} else {
throw new Exception("Invalid arguments to function");
}
}
return null;
}
@Override
public boolean canAttachToSide(int sidee) {
if (this.side == -1) {
this.side = sidee;
return true;
}
return this.side == sidee;
}
@Override
public void attach(IComputerAccess acomputer) {
/*this.computer = acomputer;
this.computer.mountFixedDir("rom/apis/receiver",
"mods/CCPortable/receiver.lua", true, 0);*/
}
@Override
public void detach(IComputerAccess computer) {
/*this.computer.unmount("rom/apis/receiver");
this.computer = null;
this.side = -1;*/
}
public int getID() {
return this.id;
}
public void setPDA(int id) {
this.pda = id;
}
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.id = nbt.getInteger("ID");
this.pda = nbt.getInteger("PID");
}
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setInteger("ID", this.id);
nbt.setInteger("PID", this.pda);
}
}
If you need to see the rest of the code, it is on my GitHub: https://github.com/T...ims/CCPortable/Thanks for reading.
Thomasims