I have fixed it since this post; all of the code is in the repository as stated earlier, but thanks for your help anyway! The problem was that for some reason the ".setSymbol(String)", etc. wasn't actually saving the variable so I moved all of those into parameters of Element so it would get saved, and then it worked fine.
I have created a class where every base type of material is listed so I can refer to their properties in this file and so I can add new subtypes for each new material type automatically by adding their unlocalized names to an array/stack and having the Item classes check these arrays/stacks. While it seems like it should work, they do not show up in NEI and when I am given them through "/give" the game crashes with a render issue.
I added the registrations to the proxy just to see if it would work by registering it there, etc. (I don't think its a redundancy problem, since I had this same error when I hadn't registered it twice.)
I've added a custom mob to my mod, with its own model, which crashes the game every time it spawns. (I have not even been able to see the mob in-game yet.) From the error it gives me, all I can tell is that something is wrong with either the ID I am registering it with or something not being registered correctly or at all.
Error:
2013-01-16 11:42:36 [INFO] [STDERR] java.lang.NullPointerException
2013-01-16 11:42:36 [INFO] [STDERR] at cpw.mods.fml.common.network.EntitySpawnPacket.generatePacket(EntitySpawnPacket.java:63)
2013-01-16 11:42:36 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLPacket.makePacket(FMLPacket.java:119)
2013-01-16 11:42:36 [INFO] [STDERR] at cpw.mods.fml.common.network.FMLNetworkHandler.getEntitySpawningPacket(FMLNetworkHandler.java:354)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.entity.EntityTrackerEntry.getPacketForThisEntity(EntityTrackerEntry.java:460)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.entity.EntityTrackerEntry.tryStartWachingThis(EntityTrackerEntry.java:366)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.entity.EntityTracker.updateTrackedEntities(EntityTracker.java:257)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:598)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:123)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497)
2013-01-16 11:42:36 [INFO] [STDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
EDIT: Removing .setIndependent and final didn't do anything.
EDIT 2: Nevermind, it seems that only the garnet achievement isn't triggering. :/ Nevermind again, it works, I just had it triggering the peridot achievement instead (from copying and pasting the if statements XD) Thanks for all you guys' help, hope people in the future like me can see this thread and get some clarification too.
Oh, no, I have registered it in my init() function, I just didn't paste it up there. (On a side note: Thank god my code survived the change to 1.4.6! And no, it still doesn't trigger in 1.4.6 either.)
I was using .addStat before, I changed it just to see if that might've been causing some of the problems before.
My Achievements:
//Achievement Registrations
public static final Achievement amethystAchieve = new Achievement(2100, "amethystAchieve", 0, 1, mod_Amethyst.amethyst, null).setIndependent().registerAchievement();
public static final Achievement peridotAchieve = new Achievement(2101, "peridotAchieve", 0, 0, mod_Amethyst.peridot, null).setIndependent().registerAchievement();
public static final Achievement garnetAchieve = new Achievement(2102, "garnetAchieve", 0, -1, mod_Amethyst.garnet, null).setIndependent().registerAchievement();
public static final Achievement temperAmethystAch = new Achievement(2103, "temperAmethystAch", 2, 2, mod_Amethyst.amethystIngot, amethystAchieve).registerAchievement();
public static final Achievement temperPeridotAch = new Achievement(2104, "temperPeridotAch", 2, 0, mod_Amethyst.peridotIngot, peridotAchieve).registerAchievement();
public static final Achievement temperGarnetAch = new Achievement(2105, "temperGarnetAch", 2, -2, mod_Amethyst.garnetIngot, garnetAchieve).registerAchievement();
public static final Achievement gemStackAch = new Achievement(2106, "gemStackAch", 4, 0, mod_Amethyst.gemAlloyIngot, null).setIndependent().registerAchievement();
//Achievement Page Registration
public static final AchievementPage moresAchPage = new AchievementPage("M'ores", amethystAchieve, peridotAchieve, garnetAchieve, temperAmethystAch, temperPeridotAch, temperGarnetAch, gemStackAch);
On a potentially unrelated note, I have the first three achievements set up to be triggered in the CraftingHandler as well (by having the ore block smelted to get the gem, like if you have a Silk Touch pickaxe) just to see if the achievements were working at all. I was just wondering if it only works with one trigger for the achievement or it doesn't matter how many triggers there are.
EDIT: Changing it to .addStat didn't do anything different.
Ok, so now I get an error when I'm picking up one of the items I set to trigger the achievements:
java.lang.NullPointerException
at dx.mods.amethyst.MoresEventHooks.onItemPickup(MoresEventHooks.java:13)
at net.minecraftforge.event.ASMEventHandler_3_MoresEventHooks_onItemPickup_EntityItemPickupEvent.invoke(.dynamic)
at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:35)
at net.minecraftforge.event.EventBus.post(EventBus.java:103)
at net.minecraft.src.EntityItem.onCollideWithPlayer(EntityItem.java:298)
at net.minecraft.src.EntityPlayer.collideWithPlayer(EntityPlayer.java:561)
at net.minecraft.src.EntityPlayer.onLivingUpdate(EntityPlayer.java:552)
at net.minecraft.src.EntityLiving.onUpdate(EntityLiving.java:775)
at net.minecraft.src.EntityPlayer.onUpdate(EntityPlayer.java:277)
at net.minecraft.src.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:217)
at net.minecraft.src.NetServerHandler.handleFlying(NetServerHandler.java:256)
at net.minecraft.src.Packet10Flying.processPacket(Packet10Flying.java:51)
at net.minecraft.src.MemoryConnection.processReadPackets(MemoryConnection.java:79)
at net.minecraft.src.NetServerHandler.networkTick(NetServerHandler.java:82)
at net.minecraft.src.NetworkListenThread.networkTick(NetworkListenThread.java:55)
at net.minecraft.src.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:111)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:110)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:494)
at net.minecraft.src.ThreadMinecraftServer.run(ThreadMinecraftServer.java:17)
MoresEventHooks.java:
package dx.mods.amethyst;
import net.minecraft.src.EntityPlayer;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
public class MoresEventHooks {
public EntityPlayer player;
@ForgeSubscribe
public void onItemPickup (EntityItemPickupEvent par1) {
if (par1.item.item.itemID == mod_Amethyst.amethyst.shiftedIndex) {
player.triggerAchievement(mod_Amethyst.amethystAchieve);
}
if (par1.item.item.itemID == mod_Amethyst.peridot.shiftedIndex) {
player.triggerAchievement(mod_Amethyst.peridotAchieve);
}
if (par1.item.item.itemID == mod_Amethyst.garnet.shiftedIndex) {
player.triggerAchievement(mod_Amethyst.garnetAchieve);
}
}
}
So, I'm not sure if I didn't put enough stuff in the if statements since it crashes at the lines where it gives the achievement, or I just did something stupidly wrong.
public class YOURCLASS{
@Init
public void YOURMETHOD{
MinecraftForge.EVENT_BUS.register(new ItemPickupHandler());
}
}
then you need a class for an itempickuphandler
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
public class ItemPickupHandler {
@ForgeSubscribe
public void onItemPickup(EntityItemPickupEvent event) {
//here goes the stuff that happens on pickup
}
}
there you go.
Mmkay, thanks. So then how do I specify the item that triggers the achievement?
EDIT: Nevermind, I went looking some more and I was missing one ".item" to put before the "itemId" when doing the if statement, I was trying "par1.item.itemID == mod_Blah.blahBlah.shiftedIndex" instead of "par1.item.item.itemID == mod_Blah.blahBlah.shiftedIndex"
I'm not saying it's his fault, just that you can't expect everyone to know exactly what you know. And I don't know basic Java really, I've only gotten to the point in my mod I am at through use of logic, tutorials, copying and pasting and trial and error. Anyway, I still don't understand how to implement this at all.
How is it not clear from all my posts in this thread that I know barely anything about Forge and therefore don't know what "listen" means in the context of Forge? If I knew how to do this I wouldn't be asking this question at all; I would have figured it out on my own already.
0
http://pastebin.com/caD7TL62 - Crash log
0
0
Crashes-
From NEI in log, the game does not crash though:
When I use /give:
Code-
Element.java: https://github.com/myoKun345/ElementalExperimentation/blob/master/elex_common/elex/element/Element.java
ItemElExDust.java: https://github.com/myoKun345/ElementalExperimentation/blob/master/elex_common/elex/item/ItemElExDust.java
ItemElExIngot.java: https://github.com/myoKun345/ElementalExperimentation/blob/master/elex_common/elex/item/ItemElExIngot.java
ItemIds.java: https://github.com/myoKun345/ElementalExperimentation/blob/master/elex_common/elex/lib/ItemIds.java
The rest of the code is there in the repository if you need to check anything else.
Thanks in advance!
0
And after doing that I still have the same error.
0
Error:
Registration in the mod file's init() method:
Registration in the proxy:
The entity, model and render file will be provided if you request it. Thanks in advance for any help!
0
EDIT: Removing .setIndependent and final didn't do anything.
EDIT 2:
Nevermind, it seems that only the garnet achievement isn't triggering. :/Nevermind again, it works, I just had it triggering the peridot achievement instead (from copying and pasting the if statements XD) Thanks for all you guys' help, hope people in the future like me can see this thread and get some clarification too.0
0
My Achievements:
On a potentially unrelated note, I have the first three achievements set up to be triggered in the CraftingHandler as well (by having the ore block smelted to get the gem, like if you have a Silk Touch pickaxe) just to see if the achievements were working at all. I was just wondering if it only works with one trigger for the achievement or it doesn't matter how many triggers there are.
EDIT: Changing it to .addStat didn't do anything different.
0
And my PickupNotifier.java is this:
What am I doing wrong or what have I not done that I should have done?
0
MoresEventHooks.java:
So, I'm not sure if I didn't put enough stuff in the if statements since it crashes at the lines where it gives the achievement, or I just did something stupidly wrong.
0
Mmkay, thanks. So then how do I specify the item that triggers the achievement?
EDIT: Nevermind, I went looking some more and I was missing one ".item" to put before the "itemId" when doing the if statement, I was trying "par1.item.itemID == mod_Blah.blahBlah.shiftedIndex" instead of "par1.item.item.itemID == mod_Blah.blahBlah.shiftedIndex"
0
0
0
0