Custom wood now gives "Getting Wood!"

This commit is contained in:
Emmanuel BENOîT 2016-07-10 22:42:44 +02:00
parent 46920572db
commit a203d00cad
2 changed files with 27 additions and 0 deletions

View file

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

View file

@ -8,6 +8,7 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
@ -29,6 +30,8 @@ public class Materials
ITEM = new MItems( ); ITEM = new MItems( );
ORE = new MOres( ); ORE = new MOres( );
TRAP = new MTraps( ); TRAP = new MTraps( );
MinecraftForge.EVENT_BUS.register( new MWoodAchievementHandler( ) );
} }