So I basically want to be able to put stuff on a block and take it back off (changing it's state).
Since I want to partially require different items/tools for that I'm using the onBlockActivated-Method:
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!facing.equals(EnumFacing.UP)) return false;
ItemStack item = playerIn.getHeldItem(hand);
if (item == null || item.isEmpty()) return false;
Type type = state.getValue(VARIANT);
if (item.getItem().getToolClasses(item).contains("shovel")) {
if (type.equals(Type.CLEAN)) return false; // clean up cleaned
if (type.equals(Type.HAYED)) { //take back clean wheat
if (!worldIn.isRemote) {
worldIn.setBlockState(pos, getStateFromMeta(Type.CLEAN.getMeta()));
Renergy.l("Dropping Wheat");
EntityItem recycle = new EntityItem(worldIn, hitX, hitY + 0.1, hitZ, new ItemStack(Items.WHEAT));
recycle.setDefaultPickupDelay();
worldIn.spawnEntity(recycle);
worldIn.playSound(playerIn, hitX, hitY, hitZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.BLOCKS, 1f, 1f);
}
return true;
}
//More cases....
Now changing the BlockState and decreasing the item in hand (placing something on the block) works without any problems.
Taking the item back from the block (with a shovel in this case) however only changes the BlockState.
The item wont spawn, the sound wont play and what frustrates me the most is that there is absolutely no StackTrace whatsoever.
There seems to be a similar topic from about a year ago that sadly never got resolved, so I'm opening this topic.
I'm currently building against forge 2619