Skip to content

Commit

Permalink
Block tag for unethical TNT check
Browse files Browse the repository at this point in the history
(resolves #4768)
  • Loading branch information
TheRealWormbo committed Nov 29, 2024
1 parent 688e9e3 commit 3a372a7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.

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.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.world.level.block.TntBlock;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;

import vazkii.botania.common.lib.BotaniaTags;
import vazkii.botania.xplat.XplatAbstractions;

import java.util.WeakHashMap;
Expand Down Expand Up @@ -118,7 +119,8 @@ private static void checkUnethical(PrimedTnt entity) {
final var blockEntity = entity.level().getBlockEntity(blockPos);
if (blockEntity instanceof PistonMovingBlockEntity movingBlockEntity
&& movingBlockEntity.getMovementDirection() == dir
&& movingBlockEntity.getMovedState().getBlock() instanceof TntBlock) {
&& (movingBlockEntity.getMovedState().getBlock() instanceof TntBlock
|| movingBlockEntity.getMovedState().is(BotaniaTags.Blocks.UNETHICAL_TNT_CHECK))) {
// found a moving block that marks the destination of a TNT block moving away from the TNT entity
XplatAbstractions.INSTANCE.ethicalComponent(entity).markUnethical();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ public static class Blocks {
*/
public static final TagKey<Block> PASTURE_SEED_REPLACEABLE = tag("pasture_seed_replaceable");

/**
* Blocks in this tag are considered when checking for unethical TNT sources. Blocks only need to be added
* to this tag if their implementation does not extend {@link net.minecraft.world.level.block.TntBlock}.
*/
public static final TagKey<Block> UNETHICAL_TNT_CHECK = tag("unethical_tnt_check");

private static TagKey<Block> tag(String name) {
return TagKey.create(Registries.BLOCK, prefix(name));
}
Expand Down
3 changes: 3 additions & 0 deletions Xplat/src/main/java/vazkii/botania/data/BlockTagProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -214,6 +215,8 @@ protected void addTags(HolderLookup.Provider provider) {

tag(BotaniaTags.Blocks.PASTURE_SEED_REPLACEABLE).add(Blocks.DIRT, Blocks.GRASS_BLOCK, Blocks.MYCELIUM);

tag(BotaniaTags.Blocks.UNETHICAL_TNT_CHECK).addOptional(new ResourceLocation("ae2:tiny_tnt"));

tag(BlockTags.FLOWER_POTS)
.add(Arrays.stream(DyeColor.values())
.map(BotaniaBlocks::getPottedFlower)
Expand Down

0 comments on commit 3a372a7

Please sign in to comment.