You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
im trying to make a java class for a block, that if you mine it with a hammer it gives you a shard instead of the but, but the code i have its not working rn :c
public class BauxiteOreBlock extends Block {
public BauxiteOreBlock() {
super(BlockBehaviour.Properties.of().strength(1.5f, 4.0f).requiresCorrectToolForDrops());
}
@Override
public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, @Nullable ItemStack stack) {
if (stack.getItem() == ModItems.HAMMER.get()) {
popResource(level, pos, new ItemStack(ModItems.BAUXITESHARD.get()));
} else {
super.playerDestroy(level, player, pos, state, blockEntity, stack);
}
}
}
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.