SHOW:
|
|
- or go back to the newest paste.
1 | - | package tutorial.generic; |
1 | + | package tutorial.generic; |
2 | - | import net.minecraft.block.BlockGrass; |
2 | + | import net.minecraft.block.BlockGrass; |
3 | - | import net.minecraft.entity.player.EntityPlayer; |
3 | + | import net.minecraft.entity.player.EntityPlayer; |
4 | - | import net.minecraft.nbt.NBTTagCompound; |
4 | + | import net.minecraft.nbt.NBTTagCompound; |
5 | - | import net.minecraftforge.event.entity.EntityEvent; |
5 | + | import net.minecraftforge.event.entity.EntityEvent; |
6 | - | import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; |
6 | + | import net.minecraftforge.event.entity.EntityEvent.EntityConstructing; |
7 | - | import net.minecraftforge.event.entity.EntityJoinWorldEvent; |
7 | + | import net.minecraftforge.event.entity.EntityJoinWorldEvent; |
8 | - | import net.minecraftforge.event.entity.living.LivingDeathEvent; |
8 | + | import net.minecraftforge.event.entity.living.LivingDeathEvent; |
9 | - | import net.minecraftforge.event.world.BlockEvent.BreakEvent; |
9 | + | import net.minecraftforge.event.world.BlockEvent.BreakEvent; |
10 | - | import cpw.mods.fml.common.eventhandler.SubscribeEvent; |
10 | + | import cpw.mods.fml.common.eventhandler.SubscribeEvent; |
11 | ||
12 | ||
13 | - | public class genericHooks { |
13 | + | public class genericHooks { |
14 | - | @SubscribeEvent |
14 | + | @SubscribeEvent |
15 | - | public void onEntityConstructing(EntityConstructing event) { |
15 | + | public void onEntityConstructing(EntityConstructing event) { |
16 | - | if (event.entity instanceof EntityPlayer) { |
16 | + | if (event.entity instanceof EntityPlayer) { |
17 | - | if (PlayerInformation.get((EntityPlayer) event.entity) == null) |
17 | + | if (PlayerInformation.get((EntityPlayer) event.entity) == null) |
18 | - | PlayerInformation.register((EntityPlayer) event.entity); |
18 | + | PlayerInformation.register((EntityPlayer) event.entity); |
19 | - | } |
19 | + | } |
20 | - | } |
20 | + | } |
21 | ||
22 | ||
23 | - | @SubscribeEvent |
23 | + | @SubscribeEvent |
24 | - | public void onBreakEvent(BreakEvent event){ |
24 | + | public void onBreakEvent(BreakEvent event){ |
25 | ||
26 | - | if (event.getPlayer() instanceof EntityPlayer) { |
26 | + | if (event.getPlayer() instanceof EntityPlayer) { |
27 | - | EntityPlayer ent = (EntityPlayer) event.getPlayer(); |
27 | + | EntityPlayer ent = (EntityPlayer) event.getPlayer(); |
28 | - | PlayerInformation playerInfo = PlayerInformation.get((EntityPlayer) event.getPlayer()); |
28 | + | PlayerInformation playerInfo = PlayerInformation.get((EntityPlayer) event.getPlayer()); |
29 | - | |
29 | + | |
30 | - | if ( event.block.getClass() == BlockGrass.class ){ |
30 | + | if ( event.block.getClass() == BlockGrass.class ){ |
31 | - | System.out.println("Broken block:"+event.block.getClass()); |
31 | + | System.out.println("Broken block:"+event.block.getClass()); |
32 | - | playerInfo.addXP(1); |
32 | + | playerInfo.addXP(1); |
33 | - | System.out.println("From NBT, Player XP:" + playerInfo.getXP()); |
33 | + | System.out.println("From NBT, Player XP:" + playerInfo.getXP()); |
34 | - | } |
34 | + | } |
35 | } | |
36 | - | } |
36 | + | |
37 | - | |
37 | + | |
38 | - | // These are methods in the EventHandler class, in case you don't know that by now |
38 | + | } |