mirror of
https://github.com/GTNewHorizons/Draconic-Evolution.git
synced 2026-10-25 20:22:19 +00:00
Add block blacklist for magnets (#80)
Co-authored-by: Super <26164930+EmperorSuper@users.noreply.github.com>
This commit is contained in:
1 parent
62e5e74f95
commit
7ada07b5ac
2 files changed
+51
-3
No files matched your search
@@ -55,6 +55,8 @@ public class ConfigHandler {
|
|||||||
public static boolean enableFlight;
|
public static boolean enableFlight;
|
||||||
private static String[] itemDislocatorBlacklist;
|
private static String[] itemDislocatorBlacklist;
|
||||||
public static Map<String, Integer> itemDislocatorBlacklistMap = new HashMap<String, Integer>();
|
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;
|
public static boolean itemDislocatorDisableSound;
|
||||||
|
|
||||||
// spawner
|
// spawner
|
||||||
@@ -303,7 +305,12 @@ public class ConfigHandler {
|
|||||||
"Item Dislocator Blacklist",
|
"Item Dislocator Blacklist",
|
||||||
Configuration.CATEGORY_GENERAL,
|
Configuration.CATEGORY_GENERAL,
|
||||||
new String[] { "appliedenergistics2:item.ItemCrystalSeed" },
|
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(
|
itemDislocatorDisableSound = config.get(
|
||||||
Configuration.CATEGORY_GENERAL,
|
Configuration.CATEGORY_GENERAL,
|
||||||
"Item Dislocator Disable Sound",
|
"Item Dislocator Disable Sound",
|
||||||
@@ -422,13 +429,35 @@ public class ConfigHandler {
|
|||||||
itemDislocatorBlacklistMap.clear();
|
itemDislocatorBlacklistMap.clear();
|
||||||
for (String s : itemDislocatorBlacklist) {
|
for (String s : itemDislocatorBlacklist) {
|
||||||
if (s.contains("|")) {
|
if (s.contains("|")) {
|
||||||
itemDislocatorBlacklistMap
|
try {
|
||||||
.put(s.substring(0, s.indexOf("|")), Integer.parseInt(s.substring(s.indexOf("|") + 1)));
|
itemDislocatorBlacklistMap
|
||||||
|
.put(s.substring(0, s.indexOf("|")), Integer.parseInt(s.substring(s.indexOf("|") + 1)));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
LogHelper.error("Error while loading dislocator blacklist.");
|
||||||
|
LogHelper.error("Could not parse meta (damage) for \"" + s + "\"");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
itemDislocatorBlacklistMap.put(s, -1);
|
itemDislocatorBlacklistMap.put(s, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
itemDislocatorBlockBlacklistMap.clear();
|
||||||
|
for (String s : itemDislocatorBlockBlacklist) {
|
||||||
|
if (s.contains("|")) {
|
||||||
|
try {
|
||||||
|
itemDislocatorBlockBlacklistMap
|
||||||
|
.put(s.substring(0, s.indexOf("|")), Integer.parseInt(s.substring(s.indexOf("|") + 1)));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
LogHelper.error("Error while loading dislocator block blacklist.");
|
||||||
|
LogHelper.error("Could not parse meta (damage) for \"" + s + "\"");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
itemDislocatorBlockBlacklistMap.put(s, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (disableLog) {
|
if (disableLog) {
|
||||||
disableLog = false;
|
disableLog = false;
|
||||||
LogHelper.warn("###########################################");
|
LogHelper.warn("###########################################");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.brandon3055.draconicevolution.common.items.tools;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
@@ -147,6 +148,24 @@ public class Magnet extends ItemDE implements IBauble, IConfigurableItem {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int x = (int) Math.floor(item.posX);
|
||||||
|
int y = (int) Math.floor(item.posY);
|
||||||
|
int z = (int) Math.floor(item.posZ);
|
||||||
|
|
||||||
|
boolean skip = false;
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
Block block = world.getBlock(x, y - i, z);
|
||||||
|
String blockName = Item.itemRegistry.getNameForObject(Item.getItemFromBlock(block));
|
||||||
|
int meta = world.getBlockMetadata(x, y - i, z);
|
||||||
|
if (ConfigHandler.itemDislocatorBlockBlacklistMap.containsKey(blockName)
|
||||||
|
&& (ConfigHandler.itemDislocatorBlockBlacklistMap.get(blockName) == -1
|
||||||
|
|| ConfigHandler.itemDislocatorBlockBlacklistMap.get(blockName) == meta)) {
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (skip) continue;
|
||||||
|
|
||||||
if (!skipPlayerCheck) {
|
if (!skipPlayerCheck) {
|
||||||
EntityPlayer closestPlayer = world.getClosestPlayerToEntity(item, range);
|
EntityPlayer closestPlayer = world.getClosestPlayerToEntity(item, range);
|
||||||
if (closestPlayer == null || closestPlayer != player) continue;
|
if (closestPlayer == null || closestPlayer != player) continue;
|
||||||
|
|||||||
Reference in new issue
Block a user