Add block blacklist for magnets

This commit is contained in:
Super committed 2025-10-13 13:38:50 +03:00
1 parent 0937d7b2d6
commit 6d8b0a0e72
2 files changed
+43 -1

No files matched your search

@@ -55,6 +55,8 @@ public class ConfigHandler {
public static boolean enableFlight;
private static String[] itemDislocatorBlacklist;
public static Map<String, Integer> itemDislocatorBlacklistMap = new HashMap<String, Integer>();
private static String[] itemDislocatorBlockBlacklist;
public static Map<String, Integer> itemDislocatorBlockBlacklistMap = new HashMap<String, Integer>();
public static boolean itemDislocatorDisableSound;
// spawner
@@ -303,7 +305,12 @@ public class ConfigHandler {
"Item Dislocator Blacklist",
Configuration.CATEGORY_GENERAL,
new String[] { "appliedenergistics2:item.ItemCrystalSeed" },
"A list of items of items that should be ignored by the item dislocator. Use the items registry name e.g. minecraft:apple you can also add a meta value like so minecraft:wool|4");
"A list of items that should be ignored by the item dislocator. Use the items registry name e.g. minecraft:apple you can also add a meta value like so minecraft:wool|4");
itemDislocatorBlockBlacklist = config.getStringList(
"Item Dislocator Block Blacklist",
Configuration.CATEGORY_GENERAL,
new String[] { "Thaumcraft:blockAlchemyFurnace|0", "Botania:pool" },
"A list of blocks that will cause items above or inside of them to be ignored by the item dislocator. Use the items registry name e.g. minecraft:apple you can also add a meta value like so minecraft:wool|4");
itemDislocatorDisableSound = config.get(
Configuration.CATEGORY_GENERAL,
"Item Dislocator Disable Sound",
@@ -428,6 +435,16 @@ public class ConfigHandler {
}
}
itemDislocatorBlockBlacklistMap.clear();
for (String s : itemDislocatorBlockBlacklist) {
if (s.contains("|")) {
itemDislocatorBlockBlacklistMap
.put(s.substring(0, s.indexOf("|")), Integer.parseInt(s.substring(s.indexOf("|") + 1)));
} else {
itemDislocatorBlockBlacklistMap.put(s, -1);
}
}
if (disableLog) {
disableLog = false;
LogHelper.warn("###########################################");
@@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.common.items.tools;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.renderer.texture.IIconRegister;
@@ -147,6 +148,30 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem {
continue;
}
int x = (int) Math.floor(item.posX);
int y = (int) Math.floor(item.posY);
int z = (int) Math.floor(item.posZ);
Block block = world.getBlock(x, y, z);
String blockName = Item.itemRegistry.getNameForObject(Item.getItemFromBlock(block));
int meta = world.getBlockMetadata(x, y, z);
if (ConfigHandler.itemDislocatorBlockBlacklistMap.containsKey(blockName)
&& (ConfigHandler.itemDislocatorBlockBlacklistMap.get(blockName) == -1
|| ConfigHandler.itemDislocatorBlockBlacklistMap.get(blockName) == meta)) {
continue;
}
y--;
block = world.getBlock(x, y, z);
blockName = Item.itemRegistry.getNameForObject(Item.getItemFromBlock(block));
meta = world.getBlockMetadata(x, y, z);
if (ConfigHandler.itemDislocatorBlockBlacklistMap.containsKey(blockName)
&& (ConfigHandler.itemDislocatorBlockBlacklistMap.get(blockName) == -1
|| ConfigHandler.itemDislocatorBlockBlacklistMap.get(blockName) == meta)) {
continue;
}
if (!skipPlayerCheck) {
EntityPlayer closestPlayer = world.getClosestPlayerToEntity(item, range);
if (closestPlayer == null || closestPlayer != player) continue;