Skip to content

Commit

Permalink
Add tag support to Horn/Drum of the Wild
Browse files Browse the repository at this point in the history
(fixes #4286)
  • Loading branch information
TheRealWormbo committed May 26, 2024
1 parent 0230450 commit d82210f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 7 additions & 16 deletions Xplat/src/main/java/vazkii/botania/common/item/HornItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,14 @@ private static boolean canHarvest(Level level, ItemStack stack, BlockPos pos,
HornHarvestable harvestable = XplatAbstractions.INSTANCE.findHornHarvestable(level, pos, state, be);
if (harvestable != null) {
return harvestable.canHornHarvest(level, pos, stack, type, user);
} else {
switch (type) {
default:
case WILD:
return state.getBlock() instanceof BushBlock && !state.is(BotaniaTags.Blocks.SPECIAL_FLOWERS);
case CANOPY: {
if (state.getBlock() instanceof LeavesBlock
&& state.getValue(LeavesBlock.PERSISTENT)) {
return false;
}

return state.is(BotaniaTags.Blocks.HORN_OF_THE_CANOPY_BREAKABLE);
}
case COVERING:
return state.is(BotaniaTags.Blocks.HORN_OF_THE_COVERING_BREAKABLE);
}
}
return switch (type) {
default -> state.getBlock() instanceof BushBlock && !state.is(BotaniaTags.Blocks.SPECIAL_FLOWERS)
|| state.is(BotaniaTags.Blocks.HORN_OF_THE_WILD_BREAKABLE);
case CANOPY -> state.is(BotaniaTags.Blocks.HORN_OF_THE_CANOPY_BREAKABLE)
&& !(state.getBlock() instanceof LeavesBlock && state.getValue(LeavesBlock.PERSISTENT));
case COVERING -> state.is(BotaniaTags.Blocks.HORN_OF_THE_COVERING_BREAKABLE);
};
}

public static void breakGrass(Level world, ItemStack stack, BlockPos srcPos, @Nullable LivingEntity user) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ public static class Blocks {
*/
public static final TagKey<Block> WEIGHT_LENS_WHITELIST = tag("weight_lens_whitelist");

/**
* Blocks in this tag can be broken by the Horn of the Wild,
* in addition to any {@code BushBlock}s that are not part of the {@link #SPECIAL_FLOWERS} tag.
*/
public static final TagKey<Block> HORN_OF_THE_WILD_BREAKABLE = tag("horn_of_the_wild_breakable");

/**
* Blocks in this tag can be broken by the Horn of the Canopy
*/
Expand Down
2 changes: 2 additions & 0 deletions Xplat/src/main/java/vazkii/botania/data/BlockTagProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ protected void addTags(HolderLookup.Provider provider) {
BotaniaBlocks.biomeCobblestoneFungal, BotaniaBlocks.biomeCobblestoneFungalSlab, BotaniaBlocks.biomeCobblestoneFungalStairs, BotaniaBlocks.biomeCobblestoneFungalWall,
BotaniaBlocks.biomeChiseledBrickFungal, fungalAltar);

tag(BotaniaTags.Blocks.HORN_OF_THE_WILD_BREAKABLE).add(Blocks.MOSS_CARPET);

tag(BlockTags.LEAVES);
tag(BotaniaTags.Blocks.HORN_OF_THE_CANOPY_BREAKABLE).addTag(BlockTags.LEAVES);

Expand Down

0 comments on commit d82210f

Please sign in to comment.