Posted June 26, 201411 yr I made this method to give the player more xp when he kills a mob, but it doesn't work, it simply does nothing. @SubscribeEvent public void itDied(LivingDeathEvent event) { Entity entity = event.entity; DamageSource source = event.source; System.out.println("ASTA MERGE !111111111111"); if (source.getSourceOfDamage() instanceof EntityPlayer) { System.out.println("ASTA MERGE!!!!"); if (event.entity instanceof EntityMob) { System.out.println("ASTA MERGE!!! 222222"); EntityPlayer player = (EntityPlayer) event.source.getEntity(); player.addExperience(1000); } } } This is the part from my main modding class: public void preInit(FMLPreInitializationEvent e) { FMLCommonHandler.instance().bus().register(new PlayerEventHandler()); }
June 26, 201411 yr put this in your main file MinecraftForge.EVENT_BUS.register(new TheClassWhereYouHaveYouExperienceStuff());
June 26, 201411 yr Author I need a parameter for TheClassWhereYouHaveYouExperienceStuff(). It says "the constructor TheClassWhereYouHaveYouExperienceStuff() is undefined"
June 26, 201411 yr @Nevermind, the code example was an example and the TheClassWhereYouHaveYouExperienceStuff needs to be changed to the name of your event handler class. Based on your previous code posted above, I think you called it PlayerEventHandler, so in that case it would be: MinecraftForge.EVENT_BUS.register(new PlayerEventHandler()); By the way if you want to know more about event handlers, I have a tutorial with list of which events are on which bus (and explanation on how to check package to figure this out yourself), see: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-event-handling.html Check out my tutorials here: http://jabelarminecraft.blogspot.com/
June 26, 201411 yr Author Thanks jabelar, but I knew that was an example. The problem was that the name which I used was already used for something else. As for diesieben07, I don't find see a silly mistake as "not knowing absolute basics"
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.