Skip to content

Instantly share code, notes, and snippets.

@AndersBillLinden
Created January 24, 2016 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndersBillLinden/ab3b97b92951f3aff319 to your computer and use it in GitHub Desktop.
Save AndersBillLinden/ab3b97b92951f3aff319 to your computer and use it in GitHub Desktop.
harvest block in PlayerInteractEvent
@SubscribeEvent
public boolean onPlayerInteract(PlayerInteractEvent event)
{
World world = event.world;
EntityPlayer player = event.entityPlayer;
ItemStack item = player.getCurrentEquippedItem();
if (item != null && item.getItem() == IronGolemFarmMod.redstonePickaxe &&
event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)
{
BlockPos pos = event.pos;
IBlockState bs = world.getBlockState(pos);
Block block = bs.getBlock();
block.harvestBlock(world, player, pos, bs, null);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment