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

Block tag for unethical TNT check #4769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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