Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.20 (alternative option) #27

Open
wants to merge 2 commits into
base: 1.19.2
Choose a base branch
from

Conversation

gniftygnome
Copy link

This PR makes minimal changes in order to be as easy as possible to merge. However, the main reason I've created this PR is PR #26 will only work with vanilla logs. In that sense, this is a more correct implementation (as much as is possible since Material was removed). Instead of hard-coding some vanilla log types, this PR uses the minecraft:logs block tag, which must work for any mod using vanilla's LeavesBlock without significant modification, because that is the tag used in vanilla decay.

It is possible some mods with a custom leaves implementation may not work (may not add their logs to minecraft:logs), but I did not find any such mods in a brief survey of major Fabric biome mods. I don't think we need to worry about this, but if you want an implementation that should work in roughly any case the Material-based implementation did, the following is fairly equivalent. (I've noticed some mods seem to take a lot of liberties in their mapping of block sound group to wood type, so this doesn't assume bamboo isn't used for real logs or nether can't be a tree with leaves.)

    private void afterBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfo info) {
        if (!world.isClient && (state.getBlock() instanceof PillarBlock)) {
            BlockSoundGroup soundGroup = state.getSoundGroup();
            if (state.isIn(BlockTags.LOGS) ||
                    BlockSoundGroup.WOOD.equals(soundGroup) ||
                    BlockSoundGroup.NETHER_WOOD.equals(soundGroup) ||
                    BlockSoundGroup.CHERRY_WOOD.equals(soundGroup) ||
                    BlockSoundGroup.BAMBOO_WOOD.equals(soundGroup)) {
// ...

- Use the same vanilla methods LeavesBlock does to break blocks
- Check an instance call of hasRandomTicks as a proxy for shouldBreak
@gniftygnome
Copy link
Author

The second set of changes is a little more intrusive, but necessary for Terraform API leaves blocks to work. It also makes breaking waterlogged leaves work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant