No worries, thanks for replying anyway. I've mostly figured it out since yesterday.
I now have a new problem (that I've also asked elsewhere, but the more the merrier...): I can place the entities by clicking on a block with my wand item, which removes the block and places an entity which looks and feels like a block, but I want them to look like the block they replaced, so I have this code:
My entity file looks like this:
public class BlockEntity extends Entity{
public int blockId;
public int meta;
public BlockEntity(World par1World) { // #1
super(par1World);
...
}
public BlockEntity(World par1World, int x, int y, int z , int blockId , int meta ) { // #2
super(par1World);
this.blockId = blockId;
...
}
...
}
My wand item uses constructor #2 to create the entity, and passes in the blockId of the block that was clicked on. (Works fine)
The plan is for the renderer to check the blockId stored here to select the correct block to render.
But what happens is that before rendering constructor #1 gets called (not by me) and so blockId gets reset to 0! (I know this is what's happening, I've checked)
My renderer has no way of getting the correct block ID...
Nowhere in the code is there a call to my constructor #1 (for example the code compiles fine even if I delete constructor #1).
The only solution I can think of atm is to create separate entities and renderers for each type of block, which is a TERRIBLE solution...
What is calling constructor #1?
I have to admit I'm totally stumped. How do I fix this?
EDIT: In case you were wondering, deleting constructor #1 causes MC to crash:
2013-02-19 19:17:56 [INFO] [STDERR] java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:17:56 [INFO] [STDERR] at lv.a(EntityList.java:139)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:401)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:103)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:83)
2013-02-19 19:17:56 [INFO] [STDERR] at im.f(ChunkProviderServer.java:182)
2013-02-19 19:17:56 [INFO] [STDERR] at im.c(ChunkProviderServer.java:118)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:310)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.a(IntegratedServer.java:84)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.c(IntegratedServer.java:100)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)
2013-02-19 19:17:56 [INFO] [STDERR] at fy.run(SourceFile:849)
2013-02-19 19:17:56 [INFO] [STDOUT] Skipping Entity with id Grumdot_SMPships.grumdot_myentityblock
2013-02-19 19:17:56 [INFO] [STDERR] java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:17:56 [INFO] [STDERR] at lv.a(EntityList.java:139)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:401)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:103)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:83)
2013-02-19 19:17:56 [INFO] [STDERR] at im.f(ChunkProviderServer.java:182)
2013-02-19 19:17:56 [INFO] [STDERR] at im.c(ChunkProviderServer.java:118)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:310)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.a(IntegratedServer.java:84)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.c(IntegratedServer.java:100)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)
2013-02-19 19:17:56 [INFO] [STDERR] at fy.run(SourceFile:849)
2013-02-19 19:17:56 [INFO] [STDOUT] Skipping Entity with id Grumdot_SMPships.grumdot_myentityblock
2013-02-19 19:17:56 [INFO] [STDERR] java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:17:56 [INFO] [STDERR] at lv.a(EntityList.java:139)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:401)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:103)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:83)
2013-02-19 19:17:56 [INFO] [STDERR] at im.f(ChunkProviderServer.java:182)
2013-02-19 19:17:56 [INFO] [STDERR] at im.c(ChunkProviderServer.java:118)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:310)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.a(IntegratedServer.java:84)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.c(IntegratedServer.java:100)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)
2013-02-19 19:17:56 [INFO] [STDERR] at fy.run(SourceFile:849)
2013-02-19 19:17:56 [INFO] [STDOUT] Skipping Entity with id Grumdot_SMPships.grumdot_myentityblock
2013-02-19 19:17:56 [INFO] [STDERR] java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:17:56 [INFO] [STDERR] at lv.a(EntityList.java:139)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:401)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:103)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:83)
2013-02-19 19:17:56 [INFO] [STDERR] at im.f(ChunkProviderServer.java:182)
2013-02-19 19:17:56 [INFO] [STDERR] at im.c(ChunkProviderServer.java:118)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:310)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.a(IntegratedServer.java:84)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.c(IntegratedServer.java:100)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)
2013-02-19 19:17:56 [INFO] [STDERR] at fy.run(SourceFile:849)
2013-02-19 19:17:56 [INFO] [STDOUT] Skipping Entity with id Grumdot_SMPships.grumdot_myentityblock
2013-02-19 19:17:56 [INFO] [STDERR] java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:17:56 [INFO] [STDERR] at lv.a(EntityList.java:139)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:401)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:103)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:83)
2013-02-19 19:17:56 [INFO] [STDERR] at im.f(ChunkProviderServer.java:182)
2013-02-19 19:17:56 [INFO] [STDERR] at im.c(ChunkProviderServer.java:118)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:310)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.a(IntegratedServer.java:84)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.c(IntegratedServer.java:100)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)
2013-02-19 19:17:56 [INFO] [STDERR] at fy.run(SourceFile:849)
2013-02-19 19:17:56 [INFO] [STDOUT] Skipping Entity with id Grumdot_SMPships.grumdot_myentityblock
2013-02-19 19:17:56 [INFO] [STDERR] java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:17:56 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:17:56 [INFO] [STDERR] at lv.a(EntityList.java:139)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:401)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:103)
2013-02-19 19:17:56 [INFO] [STDERR] at aam.a(AnvilChunkLoader.java:83)
2013-02-19 19:17:56 [INFO] [STDERR] at im.f(ChunkProviderServer.java:182)
2013-02-19 19:17:56 [INFO] [STDERR] at im.c(ChunkProviderServer.java:118)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:310)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.a(IntegratedServer.java:84)
2013-02-19 19:17:56 [INFO] [STDERR] at bdz.c(IntegratedServer.java:100)
2013-02-19 19:17:56 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:458)
2013-02-19 19:17:56 [INFO] [STDERR] at fy.run(SourceFile:849)
2013-02-19 19:17:56 [INFO] [STDOUT] Skipping Entity with id Grumdot_SMPships.grumdot_myentityblock
2013-02-19 19:18:08 [INFO] [STDOUT] ###############5
2013-02-19 19:18:08 [INFO] [STDOUT] &&&&&&&&&&& new block entity has id 5
2013-02-19 19:18:08 [SEVERE] [ForgeModLoader] A severe problem occurred during the spawning of an entity
java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at cpw.mods.fml.client.FMLClientHandler.spawnEntityIntoClientWorld(FMLClientHandler.java:341)
at cpw.mods.fml.common.FMLCommonHandler.spawnEntityIntoClientWorld(FMLCommonHandler.java:334)
at cpw.mods.fml.common.network.EntitySpawnPacket.execute(EntitySpawnPacket.java:183)
at cpw.mods.fml.common.network.FMLNetworkHandler.handleFMLPacket(FMLNetworkHandler.java:102)
at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:67)
at ayh.a(NetClientHandler.java:1483)
at di.a(SourceFile:59)
at cf.b(MemoryConnection.java:80)
at ayh.d(NetClientHandler.java:240)
at ayp.b(WorldClient.java:92)
at net.minecraft.client.Minecraft.l(Minecraft.java:1872)
at net.minecraft.client.Minecraft.J(Minecraft.java:846)
at net.minecraft.client.Minecraft.run(Minecraft.java:771)
at java.lang.Thread.run(Thread.java:662)
2013-02-19 19:18:09 [INFO] [ForgeModLoader] Unloading dimension 0
2013-02-19 19:18:09 [INFO] [ForgeModLoader] Unloading dimension -1
2013-02-19 19:18:09 [INFO] [ForgeModLoader] Unloading dimension 1
2013-02-19 19:18:10 [INFO] [STDERR] t: Exception in world tick
2013-02-19 19:18:10 [INFO] [STDERR] at net.minecraft.client.Minecraft.l(Minecraft.java:1888)
2013-02-19 19:18:10 [INFO] [STDERR] at net.minecraft.client.Minecraft.J(Minecraft.java:846)
2013-02-19 19:18:10 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:771)
2013-02-19 19:18:10 [INFO] [STDERR] at java.lang.Thread.run(Thread.java:662)
2013-02-19 19:18:10 [INFO] [STDERR] Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:18:10 [INFO] [STDERR] at com.google.common.base.Throwables.propagate(Throwables.java:160)
2013-02-19 19:18:10 [INFO] [STDERR] at cpw.mods.fml.client.FMLClientHandler.spawnEntityIntoClientWorld(FMLClientHandler.java:394)
2013-02-19 19:18:10 [INFO] [STDERR] at cpw.mods.fml.common.FMLCommonHandler.spawnEntityIntoClientWorld(FMLCommonHandler.java:334)
2013-02-19 19:18:10 [INFO] [STDERR] at cpw.mods.fml.common.network.EntitySpawnPacket.execute(EntitySpawnPacket.java:183)
2013-02-19 19:18:10 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handleFMLPacket(FMLNetworkHandler.java:102)
2013-02-19 19:18:10 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:67)
2013-02-19 19:18:10 [INFO] [STDERR] at ayh.a(NetClientHandler.java:1483)
2013-02-19 19:18:10 [INFO] [STDERR] at di.a(SourceFile:59)
2013-02-19 19:18:10 [INFO] [STDERR] at cf.b(MemoryConnection.java:80)
2013-02-19 19:18:10 [INFO] [STDERR] at ayh.d(NetClientHandler.java:240)
2013-02-19 19:18:10 [INFO] [STDERR] at ayp.b(WorldClient.java:92)
2013-02-19 19:18:10 [INFO] [STDERR] at net.minecraft.client.Minecraft.l(Minecraft.java:1872)
2013-02-19 19:18:10 [INFO] [STDERR] ... 3 more
2013-02-19 19:18:10 [INFO] [STDERR] Caused by: java.lang.NoSuchMethodException: SMPships.MyBlockEntity.<init>(yc)
2013-02-19 19:18:10 [INFO] [STDERR] at java.lang.Class.getConstructor0(Class.java:2706)
2013-02-19 19:18:10 [INFO] [STDERR] at java.lang.Class.getConstructor(Class.java:1657)
2013-02-19 19:18:10 [INFO] [STDERR] at cpw.mods.fml.client.FMLClientHandler.spawnEntityIntoClientWorld(FMLClientHandler.java:341)
2013-02-19 19:18:10 [INFO] [STDERR] ... 13 more
2013-02-19 19:18:20 [INFO] [STDOUT] Stopping!
2013-02-19 19:18:20 [INFO] [STDOUT] SoundSystem shutting down...
2013-02-19 19:18:20 [INFO] [STDOUT] Author: Paul Lamb, www.paulscode.com
2013-02-19 19:18:20 [INFO] [STDERR] Exception in thread "Minecraft main thread" org.lwjgl.LWJGLException: X Error - disp: 0x7fbf3c060410 serial: 5446 error: BadWindow (invalid Window parameter) request_code: 2 minor_code: 0
2013-02-19 19:18:20 [INFO] [STDERR] at org.lwjgl.opengl.LinuxDisplay.globalErrorHandler(LinuxDisplay.java:318)
2013-02-19 19:18:20 [INFO] [STDERR] at org.lwjgl.opengl.LinuxKeyboard.nSetDetectableKeyRepeat(Native Method)
2013-02-19 19:18:20 [INFO] [STDERR] at org.lwjgl.opengl.LinuxKeyboard.setDetectableKeyRepeat(LinuxKeyboard.java:152)
2013-02-19 19:18:20 [INFO] [STDERR] at org.lwjgl.opengl.LinuxKeyboard.destroy(LinuxKeyboard.java:163)
2013-02-19 19:18:20 [INFO] [STDERR] at org.lwjgl.opengl.LinuxDisplay.destroyKeyboard(LinuxDisplay.java:1203)
2013-02-19 19:18:20 [INFO] [STDERR] at org.lwjgl.input.Keyboard.destroy(Keyboard.java:349)
2013-02-19 19:18:20 [INFO] [STDERR] at net.minecraft.client.Minecraft.e(Minecraft.java:723)
2013-02-19 19:18:20 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:801)
2013-02-19 19:18:20 [INFO] [STDERR] at java.lang.Thread.run(Thread.java:662)
EDIT 2: Here is a stack trace for constructor #1:
java.lang.Exception
2013-02-19 20:04:53 [INFO] [STDERR] at SMPships.BlockEntity.<init>(BlockEntity.java:61)
2013-02-19 20:04:53 [INFO] [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2013-02-19 20:04:53 [INFO] [STDERR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
2013-02-19 20:04:53 [INFO] [STDERR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
2013-02-19 20:04:53 [INFO] [STDERR] at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
2013-02-19 20:04:53 [INFO] [STDERR] at cpw.mods.fml.client.FMLClientHandler.spawnEntityIntoClientWorld(FMLClientHandler.java:341)
2013-02-19 20:04:53 [INFO] [STDERR] at cpw.mods.fml.common.FMLCommonHandler.spawnEntityIntoClientWorld(FMLCommonHandler.java:334)
2013-02-19 20:04:53 [INFO] [STDERR] at cpw.mods.fml.common.network.EntitySpawnPacket.execute(EntitySpawnPacket.java:183)
2013-02-19 20:04:53 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handleFMLPacket(FMLNetworkHandler.java:102)
2013-02-19 20:04:53 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.handlePacket250Packet(FMLNetworkHandler.java:67)
2013-02-19 20:04:53 [INFO] [STDERR] at ayh.a(NetClientHandler.java:1483)
2013-02-19 20:04:53 [INFO] [STDERR] at di.a(SourceFile:59)
2013-02-19 20:04:53 [INFO] [STDERR] at cf.b(MemoryConnection.java:80)
2013-02-19 20:04:53 [INFO] [STDERR] at ayh.d(NetClientHandler.java:240)
2013-02-19 20:04:53 [INFO] [STDERR] at ayp.b(WorldClient.java:92)
2013-02-19 20:04:53 [INFO] [STDERR] at net.minecraft.client.Minecraft.l(Minecraft.java:1872)
2013-02-19 20:04:53 [INFO] [STDERR] at net.minecraft.client.Minecraft.J(Minecraft.java:846)
2013-02-19 20:04:53 [INFO] [STDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:771)
2013-02-19 20:04:53 [INFO] [STDERR] at java.lang.Thread.run(Thread.java:662)
Is this problem something to do with the entity being spawned in both client and server?
My client proxy has nothing but:
MinecraftForgeClient.preloadTexture("smpShipsBlocks.png");
RenderingRegistry.registerEntityRenderingHandler( BlockEntity.class, new BlockEntityRender() );
And my common proxy has nothing happening in it at all.
You could try storing the block ID integers in a separate class and making an erase method or something. It may not be very efficient but it's all I can think of at the moment. I wrote a concept for you: http://pastebin.com/EUmGXyPs
Rollback Post to RevisionRollBack
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
Hi. I have a quick question... How do you add a modded item to a recipe?
I had the same problem and realized you just have to type the name of the item that you created. You don't have to type Item.Whatever item you created. So if you named you item banana you would type: Character.valueOf('B'), Banana
I had the same problem and realized you just have to type the name of the item that you created. You don't have to type Item.Whatever item you created. So if you named you item banana you would type: Character.valueOf('B'), Banana
You don't have to use Character.valueOf. You can just put the two single quotes.
Rollback Post to RevisionRollBack
When life gives you a potato, wonder why the heck life just gave you a potato. Why not something else? Like money? Or a combustable lemon? No, you get a potato. Nothing else.
You could try storing the block ID integers in a separate class and making an erase method or something. It may not be very efficient but it's all I can think of at the moment. I wrote a concept for you: http://pastebin.com/EUmGXyPs
Thanks Dragonphly, I appreciate the reply. It turns out (I've been told) that the way to access that extra data in the entity class is to make the entity implement IEntityAdditionalSpawnData.
Hum, so you have switched to forge now, can't say I blame you, modloader never really got past the 1.3 update, and has been basically staying afloat since.
Now I will likely have to switch to forge myself, perhaps I will wait for 1.5.
But, I have a few questions about forge, namely, what all does it... Um, do? I had heard good things about it, but I can never seem to find what it actually does.
Perhaps, you could also make (or perhaps direct people to) a tutorial on how to convert from modloader to forge, even if it was simple.
Hum, so you have switched to forge now, can't say I blame you, modloader never really got past the 1.3 update, and has been basically staying afloat since.
Now I will likely have to switch to forge myself, perhaps I will wait for 1.5.
But, I have a few questions about forge, namely, what all does it... Um, do? I had heard good things about it, but I can never seem to find what it actually does.
Perhaps, you could also make (or perhaps direct people to) a tutorial on how to convert from modloader to forge, even if it was simple.
Do you want the High-Detail, Highly Difficult to understand explanation which will give you a fantastic understanding of Forge, or a simple explanation?
Do you want the High-Detail, Highly Difficult to understand explanation which will give you a fantastic understanding of Forge, or a simple explanation?
I'll write them up for tomorrow. You better be ready to read, lol.
... 0.o
...
.
But actually it was good to have a wait, I have been working on a new mod of mine that I likely wouldn't have been working on had you posted yesterday, so thanks for keeping me waiting
But actually it was good to have a wait, I have been working on a new mod of mine that I likely wouldn't have been working on had you posted yesterday, so thanks for keeping me waiting
Yeah, sorry about not writing it yesterday. I got stuck doing AP Biology work all night. Now, for the explanation:
Minecraft Forge Explanation
What does the Minecraft Forge API do?
The Minecraft Forge API supplies a means of interacting with the internal Minecraft Source without editing it yourself, which in most cases would cause incompatibilities between mods.
Minecraft Forge also uses a sophisticated instance of Reflection in two specific areas:
The main basis of the ForgeModloader portion of the API traverses the many packages of the Minecraft Jar directory and the "mods" directory and dynamically loads Class files to determine via reflection whether any contain the @Mod Annotation. These files are then stored as Mod Candidates to be further reviewed later. Any classes found to be Mod Candidates are then attempted to be loaded entirely.
The EnumHelper, used for the addition of Enumeration values to Minecraft BaseClasses, is also a prime example of the usage of Reflection within MinecraftForge. This class takes advantage of three specific classes from which 5 items are received. These classes are: sun.reflect.ReflectionFactory, sun.reflect.ConstructorAccessor, and sun.reflect.MethodAccessor. This combination of classes allows for the Access of the Enumeration's private constructor to create new instances of said Enumeration.
How does the API Function?
The MinecraftForgeAPI uses a State driven system. The different States can be found in the FMLLoaderState enumeration. The different states are:
NOINIT
LOADING
CONSTRUCTING
PREINITIALIZATION
INITIALIZATION
POSTINITIALIZATION
AVAILABLE
SERVER_STARTING
SERVER_STARTED
SERVER_STOPPING
SERVER_STOPPED
ERRORED
Many of these states are quite self-explanatory, but there are just a few I would like to touch up on.
NOINIT - MinecraftForge is Uninitialized
LOADING - Currently Loading Forge and Mod Files
CONSTRUCTING - Constructing objects of the loaded Mod Files.
What does the API allow you to do?
The Forge API allows you to perform any number of different tasks, all the way from the simple addition of Blocks and Items, to advanced Rendering Implementations, to any number of other things.
How does Forge prevail over ModLoader?
Beyond the fact that ModLoader has remained in an unstable, only partially working state, and whose creator has seemingly abandoned the project almost entirely, Forge allows for many more details to be modifiable. For instance, unlike in ModLoader, a programmer is able to use the MinecraftForge class's setBlockLevel() method to establish the level of Pickaxe needed to be able to attain the block's item drop. You are also able to add new Enumeration values via the method described earlier in the post, so that it is not required for you to edit the Base Enums (which will cause incompatibilities with any other mods that do), and certain features implemented within Vanilla Minecraft will still be applied. For instance, the usage of a Custom enumeration for Tool Materials disallows these tools from being Enchantable.
One of the most important features of Forge is that it is 100% compatible with ModLoader mods!
What extra implementation features does the MinecraftForge API offer?
ASM ByteCode Framework Access
Annotation-Based Dynamic Loading system
Diverse and Dynamic Event Driven system using an Event Bus to dynamically distribute ASM Event Calls.
Automatic Network Channel Registration
ASM ByteCode Framework:
The ASM ByteCode Framework allows a programmer to perform a large range of actions. This Framework allows a programmer to insert ByteCode into ClassFiles, or literally Construct new Class Files entirely. For a more in-depth description of Modifying Classes or Creating new Classes, view the basic tutorial on ASM and the advanced tutorial on ASM.
Another area of the ASM Framework are AccessTransformers. For more on those, visit this tutorial.
So, basically it allows a person to edit base classes without editing them.
That is simplifying it faaaaaaaaaaaaaaaaaaaaaaaaaaaaar too much, but sure. It's main goal is to prevent the need to edit base classes to maintain compatibility.
Hey. I have been having an issue where my game keeps crashing when trying to test out my mod. I believe that minecraft cannot find my BaseClass. Here is the error:
cpw.mods.fml.common.LoaderException: java.lang.ClassNotFoundException: sonick.weapons.common.BaseClass
at cpw.mods.fml.common.LoadController.transition(LoadController.java:117)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:485)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:161)
at net.minecraft.client.Minecraft.a(Minecraft.java:410)
at asq.a(SourceFile:56)
at net.minecraft.client.Minecraft.run(Minecraft.java:744)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: sonick.weapons.common.BaseClass
at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:185)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at cpw.mods.fml.common.ModClassLoader.loadClass(ModClassLoader.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:416)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
at com.google.common.eventbus.EventBus.post(EventBus.java:268)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
at com.google.common.eventbus.EventBus.post(EventBus.java:268)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:83)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:479)
... 5 more
Caused by: java.lang.NullPointerException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at net.minecraftforge.transformers.EventTransformer.transform(EventTransformer.java:29)
at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:228)
at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:173)
... 32 more
--- END ERROR REPORT aea7ddda ----------
Hello! Thank you for the tutorials about forge, just started using it this past weekend and it is really helpful to start those modders who are only familiar with modloader like me.
ps.
player.addChatMessage("Silly question, how do I change the color of this function addChatMessage to red or blue etc when displayed to the user?");
Hello! Thank you for the tutorials about forge, just started using it this past weekend and it is really helpful to start those modders who are only familiar with modloader like me.
ps.
player.addChatMessage("Silly question, how do I change the color of this function addChatMessage to red or blue etc when displayed to the user?");
Not a silly question at all. Basically, you just add a colour code in front of the text you want to change the colour of.
\u00A70 = Black
\u00A71 = Dark Blue
\u00A72 = Dark Green
\u00A73 = Dark Cyan
\u00A74 = Dark Red
\u00A75 = Purple
\u00A76 = Orange
\u00A77 = Light Grey
\u00A78 = Dark Grey
\u00A79 = Lilic
\u00A7a = Light Green
\u00A7b = Light Cyan
\u00A7c = Light Red
\u00A7d = Pink
\u00A7e = Yellow
\u00A7f = White
player.addChatMessage("\u00A72Text");
Would look like:
Text
If you want to add white text after coloured text, just add the colour code for white just before the bit that you want to stay white.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
You could try storing the block ID integers in a separate class and making an erase method or something. It may not be very efficient but it's all I can think of at the moment. I wrote a concept for you: http://pastebin.com/EUmGXyPs
You don't have to use Character.valueOf. You can just put the two single quotes.
Thanks Dragonphly, I appreciate the reply. It turns out (I've been told) that the way to access that extra data in the entity class is to make the entity implement IEntityAdditionalSpawnData.
Now I will likely have to switch to forge myself, perhaps I will wait for 1.5.
But, I have a few questions about forge, namely, what all does it... Um, do? I had heard good things about it, but I can never seem to find what it actually does.
Perhaps, you could also make (or perhaps direct people to) a tutorial on how to convert from modloader to forge, even if it was simple.
Do you want the High-Detail, Highly Difficult to understand explanation which will give you a fantastic understanding of Forge, or a simple explanation?
Um, how about both?
I'll write them up for tomorrow. You better be ready to read, lol.
... 0.o
...
.
But actually it was good to have a wait, I have been working on a new mod of mine that I likely wouldn't have been working on had you posted yesterday, so thanks for keeping me waiting
Yeah, sorry about not writing it yesterday. I got stuck doing AP Biology work all night. Now, for the explanation:
What does the Minecraft Forge API do?
The Minecraft Forge API supplies a means of interacting with the internal Minecraft Source without editing it yourself, which in most cases would cause incompatibilities between mods.
Minecraft Forge also uses a sophisticated instance of Reflection in two specific areas:
The MinecraftForgeAPI uses a State driven system. The different States can be found in the FMLLoaderState enumeration. The different states are:
NOINIT - MinecraftForge is Uninitialized
LOADING - Currently Loading Forge and Mod Files
CONSTRUCTING - Constructing objects of the loaded Mod Files.
What does the API allow you to do?
The Forge API allows you to perform any number of different tasks, all the way from the simple addition of Blocks and Items, to advanced Rendering Implementations, to any number of other things.
How does Forge prevail over ModLoader?
Beyond the fact that ModLoader has remained in an unstable, only partially working state, and whose creator has seemingly abandoned the project almost entirely, Forge allows for many more details to be modifiable. For instance, unlike in ModLoader, a programmer is able to use the MinecraftForge class's setBlockLevel() method to establish the level of Pickaxe needed to be able to attain the block's item drop. You are also able to add new Enumeration values via the method described earlier in the post, so that it is not required for you to edit the Base Enums (which will cause incompatibilities with any other mods that do), and certain features implemented within Vanilla Minecraft will still be applied. For instance, the usage of a Custom enumeration for Tool Materials disallows these tools from being Enchantable.
One of the most important features of Forge is that it is 100% compatible with ModLoader mods!
What extra implementation features does the MinecraftForge API offer?
The ASM ByteCode Framework allows a programmer to perform a large range of actions. This Framework allows a programmer to insert ByteCode into ClassFiles, or literally Construct new Class Files entirely. For a more in-depth description of Modifying Classes or Creating new Classes, view the basic tutorial on ASM and the advanced tutorial on ASM.
Another area of the ASM Framework are AccessTransformers. For more on those, visit this tutorial.
So, basically it allows a person to edit base classes without editing them.
That is simplifying it faaaaaaaaaaaaaaaaaaaaaaaaaaaaar too much, but sure. It's main goal is to prevent the need to edit base classes to maintain compatibility.
at cpw.mods.fml.common.LoadController.transition(LoadController.java:117)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:485)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:161)
at net.minecraft.client.Minecraft.a(Minecraft.java:410)
at asq.a(SourceFile:56)
at net.minecraft.client.Minecraft.run(Minecraft.java:744)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: sonick.weapons.common.BaseClass
at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:185)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at cpw.mods.fml.common.ModClassLoader.loadClass(ModClassLoader.java:57)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:416)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
at com.google.common.eventbus.EventBus.post(EventBus.java:268)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:69)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:317)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:300)
at com.google.common.eventbus.EventBus.post(EventBus.java:268)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:83)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:479)
... 5 more
Caused by: java.lang.NullPointerException
at org.objectweb.asm.ClassReader.<init>(Unknown Source)
at net.minecraftforge.transformers.EventTransformer.transform(EventTransformer.java:29)
at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:228)
at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:173)
... 32 more
--- END ERROR REPORT aea7ddda ----------
ps.
player.addChatMessage("Silly question, how do I change the color of this function addChatMessage to red or blue etc when displayed to the user?");
Not a silly question at all. Basically, you just add a colour code in front of the text you want to change the colour of.
\u00A70 = Black
\u00A71 = Dark Blue
\u00A72 = Dark Green
\u00A73 = Dark Cyan
\u00A74 = Dark Red
\u00A75 = Purple
\u00A76 = Orange
\u00A77 = Light Grey
\u00A78 = Dark Grey
\u00A79 = Lilic
\u00A7a = Light Green
\u00A7b = Light Cyan
\u00A7c = Light Red
\u00A7d = Pink
\u00A7e = Yellow
\u00A7f = White
Would look like:
Text
If you want to add white text after coloured text, just add the colour code for white just before the bit that you want to stay white.
together they are powerful beyond imagination."