Advertisement
Disconsented

Untitled

Apr 15th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     package tutorial.generic;
  2.     import net.minecraft.block.BlockGrass;
  3.     import net.minecraft.entity.player.EntityPlayer;
  4.     import net.minecraft.nbt.NBTTagCompound;
  5.     import net.minecraftforge.event.entity.EntityEvent;
  6.     import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
  7.     import net.minecraftforge.event.entity.EntityJoinWorldEvent;
  8.     import net.minecraftforge.event.entity.living.LivingDeathEvent;
  9.     import net.minecraftforge.event.world.BlockEvent.BreakEvent;
  10.     import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  11.      
  12.      
  13.     public class genericHooks {
  14.             @SubscribeEvent
  15.     public void onEntityConstructing(EntityConstructing event) {
  16.                     if (event.entity instanceof EntityPlayer) {
  17.                             if (PlayerInformation.get((EntityPlayer) event.entity) == null)
  18.                                     PlayerInformation.register((EntityPlayer) event.entity);
  19.                     }
  20.             }
  21.      
  22.      
  23.     @SubscribeEvent
  24.     public void onBreakEvent(BreakEvent event){
  25.      
  26.              if (event.getPlayer() instanceof EntityPlayer) {
  27.              EntityPlayer ent = (EntityPlayer) event.getPlayer();
  28.              PlayerInformation playerInfo = PlayerInformation.get((EntityPlayer) event.getPlayer());
  29.              
  30.              if ( event.block.getClass() == BlockGrass.class ){
  31.                      System.out.println("Broken block:"+event.block.getClass());            
  32.                      playerInfo.addXP(1);
  33.                      System.out.println("From NBT, Player XP:" + playerInfo.getXP());
  34.                      }
  35.              }
  36.          }
  37.  
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement