Hey guys, I am new at modding. Do anyone know how to override vanilla blocks properties? i want to make a right click detection when I hold something to a vanilla block.
here is my code [Does Not Work] :
@SubscribeEvent
public void rightClickBlock(BlockPos pos, PlayerInteractEvent.RightClickBlock event, PlayerEntity player, int face,World world){
Hey guys, I am new at modding. Do anyone know how to override vanilla blocks properties? i want to make a right click detection when I hold something to a vanilla block.
here is my code [Does Not Work] :
@SubscribeEvent
public void rightClickBlock(BlockPos pos, PlayerInteractEvent.RightClickBlock event, PlayerEntity player, int face,World world){
if(event.getUseBlock() != Result.DENY) {
if(world.getBlockState(pos) == Blocks.CHIPPED_ANVIL.defaultBlockState()) {
if(player.getMainHandItem() == ItemInit.ITEM_TO_RIGHT_CLICK.get().getDefaultInstance())
{world.setBlock(pos, Blocks.ANVIL.defaultBlockState(), face);
}
}
}
}