Posted March 12, 20196 yr I need to give the player Exp from my mod when they kill specific entities, however when the event fires, they don't get any exp. What am I doing wrong? The event is fired, everything works, but the EXP still doesn't get set to what it should be set to. @SubscribeEvent public void onDeath(LivingDeathEvent event) { Entity entity = event.getEntityLiving(); if (event.getSource().getTrueSource() instanceof EntityPlayer) { Random rand = new Random(); EntityPlayer player = (EntityPlayer)event.getSource().getTrueSource(); if (entity instanceof EntityShinobi) { EntityShinobi shinobi = (EntityShinobi)entity; int i = rand.nextInt(17); int r = rand.nextInt(1); if (r == 0) { player.getCapability(CapabilityMana.MANA_CAPABILITY, null).setExp(player.getCapability(CapabilityMana.MANA_CAPABILITY, null).getExp() + 150+i); PacketHandler.INSTANCE.sendTo(new PacketExp(player), (EntityPlayerMP)player); } else { player.getCapability(CapabilityMana.MANA_CAPABILITY, null).setExp(player.getCapability(CapabilityMana.MANA_CAPABILITY, null).getExp() + 150-i); PacketHandler.INSTANCE.sendTo(new PacketExp(player), (EntityPlayerMP)player); } } } } Edited March 12, 20196 yr by FlashHUN
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.