Skip to content

Commit 80c4f54

Browse files
committed
Make it possible to blacklist blocks from being mined by the disassembler or meka tool
1 parent acd57ce commit 80c4f54

File tree

7 files changed

+24
-19
lines changed

7 files changed

+24
-19
lines changed

src/datagen/generated/mekanism/.cache/f4271571320fe007f5d8ba9eb4461ed6922f6a93

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/generated/mekanism/data/mekanism/tags/blocks/incorrect_for_disassembler.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datagen/generated/mekanism/data/mekanism/tags/blocks/incorrect_for_meka_tool.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/mekanism/common/item/gear/ItemAtomicDisassembler.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,6 @@ public class ItemAtomicDisassembler extends ItemEnergized implements IItemHUDPro
8585
ToolActions.SWORD_DIG);
8686
private static final Lazy<RadialData<DisassemblerMode>> LAZY_RADIAL_DATA = Lazy.of(() ->
8787
IRadialDataHelper.INSTANCE.dataForEnum(Mekanism.rl("disassembler_mode"), DisassemblerMode.NORMAL));
88-
//Allow harvesting everything, things that are unbreakable are caught elsewhere
89-
public static final Tool MINE_ANY_TOOL = new Tool(
90-
//TODO - 1.20.5: Can speed be empty like it is here?
91-
// Maybe we want it to be denies drop and an empty tag?
92-
List.of(new Tool.Rule(new AnyHolderSet<>(BuiltInRegistries.BLOCK.asLookup()), Optional.empty(), Optional.of(true))),
93-
//TODO - 1.20.5: Figure out what these values are meant to be
94-
1, 0
95-
);
9688

9789
/**
9890
* @apiNote For use in calculating drops of given blocks. Given mods may do checks relating to tool actions we need to make sure that this stack is full energy.
@@ -106,7 +98,10 @@ public static ItemStack fullyChargedStack() {
10698
public ItemAtomicDisassembler(Properties properties) {
10799
super(properties.rarity(Rarity.RARE).setNoRepair().stacksTo(1)
108100
.component(MekanismDataComponents.DISASSEMBLER_MODE, DisassemblerMode.NORMAL)
109-
.component(DataComponents.TOOL, MINE_ANY_TOOL)
101+
.component(DataComponents.TOOL, new Tool(List.of(
102+
Tool.Rule.deniesDrops(MekanismTags.Blocks.INCORRECT_FOR_DISASSEMBLER),
103+
new Tool.Rule(new AnyHolderSet<>(BuiltInRegistries.BLOCK.asLookup()), Optional.empty(), Optional.of(true))
104+
), 1, 0))
110105
);
111106
this.attributeCache = new AttributeCache(this, MekanismConfig.gear.disassemblerMaxDamage, MekanismConfig.gear.disassemblerAttackSpeed);
112107
}

src/main/java/mekanism/common/item/gear/ItemMekaTool.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.List;
1212
import java.util.Map;
1313
import java.util.Map.Entry;
14+
import java.util.Optional;
1415
import java.util.stream.Collectors;
1516
import mekanism.api.Action;
1617
import mekanism.api.AutomationType;
@@ -46,6 +47,7 @@
4647
import net.minecraft.core.BlockPos;
4748
import net.minecraft.core.Holder;
4849
import net.minecraft.core.component.DataComponents;
50+
import net.minecraft.core.registries.BuiltInRegistries;
4951
import net.minecraft.network.chat.Component;
5052
import net.minecraft.resources.ResourceLocation;
5153
import net.minecraft.server.level.ServerPlayer;
@@ -67,6 +69,7 @@
6769
import net.minecraft.world.item.Rarity;
6870
import net.minecraft.world.item.TooltipFlag;
6971
import net.minecraft.world.item.component.ItemAttributeModifiers;
72+
import net.minecraft.world.item.component.Tool;
7073
import net.minecraft.world.item.context.UseOnContext;
7174
import net.minecraft.world.item.enchantment.Enchantment;
7275
import net.minecraft.world.item.enchantment.ItemEnchantments;
@@ -78,6 +81,7 @@
7881
import net.minecraft.world.phys.HitResult;
7982
import net.neoforged.neoforge.common.NeoForge;
8083
import net.neoforged.neoforge.common.ToolAction;
84+
import net.neoforged.neoforge.registries.holdersets.AnyHolderSet;
8185
import org.jetbrains.annotations.NotNull;
8286
import org.jetbrains.annotations.Nullable;
8387

@@ -88,8 +92,11 @@ public class ItemMekaTool extends ItemEnergized implements IRadialModuleContaine
8892
private final Int2ObjectMap<AttributeCache> attributeCaches = new Int2ObjectArrayMap<>(ModuleAttackAmplificationUnit.AttackDamage.values().length);
8993

9094
public ItemMekaTool(Properties properties) {
91-
super(IModuleHelper.INSTANCE.applyModuleContainerProperties(
92-
properties.rarity(Rarity.EPIC).setNoRepair().stacksTo(1).component(DataComponents.TOOL, ItemAtomicDisassembler.MINE_ANY_TOOL)
95+
super(IModuleHelper.INSTANCE.applyModuleContainerProperties(properties.rarity(Rarity.EPIC).setNoRepair()
96+
.component(DataComponents.TOOL, new Tool(List.of(
97+
Tool.Rule.deniesDrops(MekanismTags.Blocks.INCORRECT_FOR_MEKA_TOOL),
98+
new Tool.Rule(new AnyHolderSet<>(BuiltInRegistries.BLOCK.asLookup()), Optional.empty(), Optional.of(true))
99+
), 1, 0))
93100
));
94101
}
95102

src/main/java/mekanism/common/tags/MekanismTags.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ private Blocks() {
197197
public static final TagKey<Block> CARDBOARD_BLACKLIST = tag("cardboard_blacklist");
198198
public static final TagKey<Block> MINER_BLACKLIST = tag("miner_blacklist");
199199
public static final TagKey<Block> ATOMIC_DISASSEMBLER_ORE = tag("atomic_disassembler_ore");
200+
public static final TagKey<Block> INCORRECT_FOR_DISASSEMBLER = tag("incorrect_for_disassembler");
201+
public static final TagKey<Block> INCORRECT_FOR_MEKA_TOOL = tag("incorrect_for_meka_tool");
200202
/**
201203
* For use in the farming module to target blocks that should be effectively ignored when checking if the block below should be targeted.
202204
*/

src/tools/java/mekanism/tools/common/ToolsTags.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ private Blocks() {
1818
}
1919

2020
public static final TagKey<Block> MINEABLE_WITH_PAXEL = commonTag("mineable/paxel");
21-
public static final TagKey<Block> NEEDS_BRONZE_TOOL = tag("needs_bronze_tool");
22-
public static final TagKey<Block> NEEDS_LAPIS_LAZULI_TOOL = tag("needs_lapis_lazuli_tool");
23-
public static final TagKey<Block> NEEDS_OSMIUM_TOOL = tag("needs_osmium_tool");
24-
public static final TagKey<Block> NEEDS_REFINED_GLOWSTONE_TOOL = tag("needs_refined_glowstone_tool");
25-
public static final TagKey<Block> NEEDS_REFINED_OBSIDIAN_TOOL = tag("needs_refined_obsidian_tool");
26-
public static final TagKey<Block> NEEDS_STEEL_TOOL = tag("needs_steel_tool");
27-
2821
public static final TagKey<Block> INCORRECT_FOR_BRONZE_TOOL = tag("incorrect_for_bronze_tool");
2922
public static final TagKey<Block> INCORRECT_FOR_LAPIS_LAZULI_TOOL = tag("incorrect_for_lapis_lazuli_tool");
3023
public static final TagKey<Block> INCORRECT_FOR_OSMIUM_TOOL = tag("incorrect_for_osmium_tool");

0 commit comments

Comments
 (0)