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( ) ); }