Created
January 13, 2017 02:59
-
-
Save Robijnvogel/d6e4ac43513c18e042533b22375f5a36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { | |
//Check if the metadata value is 0 -- we don't want the user to replace Ancient Fabric | |
if (heldItem != null && state.getValue(TYPE) != 1) { | |
Block block = Block.getBlockFromItem(heldItem.getItem()); | |
if (!state.isNormalCube() || block instanceof BlockContainer || block == this || player.isSneaking()) { | |
return false; | |
} | |
if (!world.isRemote) { | |
if (!player.capabilities.isCreativeMode) { | |
heldItem.stackSize--; | |
} | |
world.setBlockState(pos, block.getStateForPlacement(world, pos, side, hitX, hitY, hitZ, 0, player)); //these parameters actually might not really be the right ones | |
} | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment