Skip to content

Commit

Permalink
Magnets: Treat white/blacklist options as lists of block IDs, not ite…
Browse files Browse the repository at this point in the history
…m IDs. Fixes #4648
  • Loading branch information
quat1024 committed Feb 11, 2024
1 parent ec4de83 commit 5c5776e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package org.violetmoon.quark.addons.oddities.magnetsystem;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import net.minecraft.core.registries.BuiltInRegistries;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.addons.oddities.block.be.MagnetBlockEntity;
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.quark.api.IMagnetMoveAction;
import org.violetmoon.quark.api.IMagnetTracker;
import org.violetmoon.quark.api.QuarkCapabilities;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.util.RegistryUtil;
import org.violetmoon.zeta.util.handler.RecipeCrawlHandler;

import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -57,10 +62,18 @@ public static void onRecipeReset() {
}

public static void onDigest() {
RecipeCrawlHandler.recursivelyFindCraftedItemsFromStrings(MagnetsModule.magneticDerivationList, MagnetsModule.magneticWhitelist, MagnetsModule.magneticBlacklist, i -> {
//TODO(Zeta): Eschew the built-in whitelist/blacklist system... (https://github.com/VazkiiMods/Zeta/issues/2)
RecipeCrawlHandler.recursivelyFindCraftedItemsFromStrings(MagnetsModule.magneticDerivationList, Collections.emptyList(), Collections.emptyList(), i -> {
if(i instanceof BlockItem bi)
magnetizableBlocks.add(bi.getBlock());
});

//...in favor of manual fixup
List<Block> magneticWhitelist = RegistryUtil.massRegistryGet(MagnetsModule.magneticWhitelist, BuiltInRegistries.BLOCK);
List<Block> magneticBlacklist = RegistryUtil.massRegistryGet(MagnetsModule.magneticBlacklist, BuiltInRegistries.BLOCK);

magnetizableBlocks.addAll(magneticWhitelist);
magneticBlacklist.forEach(magnetizableBlocks::remove);
}

public static void applyForce(Level world, BlockPos pos, int magnitude, boolean pushing, Direction dir, int distance, BlockPos origin) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ public class MagnetsModule extends ZetaModule {
@Config(description = "Any items you place in this list will be derived so that any block made of it will become magnetizable")
public static List<String> magneticDerivationList = Lists.newArrayList("minecraft:iron_ingot", "minecraft:copper_ingot", "minecraft:exposed_copper", "minecraft:weathered_copper", "minecraft:oxidized_copper", "minecraft:raw_iron", "minecraft:raw_copper", "minecraft:iron_ore", "minecraft:deepslate_iron_ore", "minecraft:copper_ore", "minecraft:deepslate_copper_ore", "quark:gravisand");

@Config
@Config(description = "Block IDs to force-allow magnetism on, regardless of their crafting recipe")
public static List<String> magneticWhitelist = Lists.newArrayList("minecraft:chipped_anvil", "minecraft:damaged_anvil");
@Config

@Config(description = "Block IDs to force-disable magnetism on, regardless of their crafting recipe")
public static List<String> magneticBlacklist = Lists.newArrayList("minecraft:tripwire_hook");

@Config(flag = "magnet_pre_end")
Expand Down

0 comments on commit 5c5776e

Please sign in to comment.