From a203d00cadbdcdff536e0d5c7135a1c5e67662f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 10 Jul 2016 22:42:44 +0200 Subject: [PATCH] Custom wood now gives "Getting Wood!" --- .../materials/MWoodAchievementHandler.java | 24 +++++++++++++++++++ src/java/mmm/materials/Materials.java | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 src/java/mmm/materials/MWoodAchievementHandler.java diff --git a/src/java/mmm/materials/MWoodAchievementHandler.java b/src/java/mmm/materials/MWoodAchievementHandler.java new file mode 100644 index 0000000..50f382f --- /dev/null +++ b/src/java/mmm/materials/MWoodAchievementHandler.java @@ -0,0 +1,24 @@ +package mmm.materials; + + +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.stats.AchievementList; +import net.minecraftforge.event.entity.player.EntityItemPickupEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + + + +public class MWoodAchievementHandler +{ + + @SubscribeEvent + public void onEntityItemPickup( final EntityItemPickupEvent event ) + { + final Item item = event.getItem( ).getEntityItem( ).getItem( ); + if ( item instanceof ItemBlock && ( (ItemBlock) item ).getBlock( ) instanceof MLog ) { + event.getEntityPlayer( ).addStat( AchievementList.MINE_WOOD ); + } + } + +} diff --git a/src/java/mmm/materials/Materials.java b/src/java/mmm/materials/Materials.java index 4ad84e7..67999c1 100644 --- a/src/java/mmm/materials/Materials.java +++ b/src/java/mmm/materials/Materials.java @@ -8,6 +8,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.Item; +import net.minecraftforge.common.MinecraftForge; @@ -29,6 +30,8 @@ public class Materials ITEM = new MItems( ); ORE = new MOres( ); TRAP = new MTraps( ); + + MinecraftForge.EVENT_BUS.register( new MWoodAchievementHandler( ) ); }