mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 11:59:17 +00:00
Merge pull request #2245 from HenryLoenwind/magnetBlacklist
New Config: Blacklist items from Magnet
This commit is contained in:
commit
be4d3e99d8
2 files changed
+35
No files matched your search
@@ -303,6 +303,8 @@ public final class Config {
|
||||
public static int magnetPowerUsePerSecondRF = 1;
|
||||
public static int magnetPowerCapacityRF = 100000;
|
||||
public static int magnetRange = 5;
|
||||
public static String[] magnetBlacklist = new String[] { "appliedenergistics2:item.ItemCrystalSeed", "Botania:livingrock",
|
||||
"Botania:manaTablet" };
|
||||
|
||||
public static boolean useCombustionGenModel = false;
|
||||
|
||||
@@ -1015,6 +1017,9 @@ public final class Config {
|
||||
magnetRange = config.get(sectionMagnet.name, "magnetRange", magnetRange,
|
||||
"Range of the magnet in blocks.").getInt(magnetRange);
|
||||
|
||||
magnetBlacklist = config.getStringList("magnetBlacklist", sectionMagnet.name, magnetBlacklist,
|
||||
"These items will not be picked up by the magnet.");
|
||||
|
||||
useCombustionGenModel = config.get(sectionAesthetic.name, "useCombustionGenModel", useCombustionGenModel,
|
||||
"If set to true: WIP Combustion Generator model will be used").getBoolean(useCombustionGenModel);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package crazypants.enderio.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
@@ -9,10 +10,12 @@ import net.minecraft.entity.item.EntityXPOrb;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.PacketMagnetState.SlotType;
|
||||
@@ -53,6 +56,10 @@ public class MagnetController implements IEntitySelector {
|
||||
|
||||
public void doHoover(EntityPlayer player) {
|
||||
|
||||
if (blacklist == null) {
|
||||
initBlacklist();
|
||||
}
|
||||
|
||||
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
|
||||
player.posX - Config.magnetRange, player.posY - Config.magnetRange, player.posZ - Config.magnetRange,
|
||||
player.posX + Config.magnetRange, player.posY + Config.magnetRange, player.posZ + Config.magnetRange);
|
||||
@@ -84,8 +91,31 @@ public class MagnetController implements IEntitySelector {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Item> blacklist = null;
|
||||
|
||||
private static void initBlacklist() {
|
||||
blacklist = new ArrayList<Item>();
|
||||
for (String name : Config.magnetBlacklist) {
|
||||
String[] parts = name.split(":");
|
||||
if (parts.length == 2) {
|
||||
Item item = GameRegistry.findItem(parts[0], parts[1]);
|
||||
if (item != null) {
|
||||
blacklist.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntityApplicable(Entity var1) {
|
||||
if (!blacklist.isEmpty() && var1 instanceof EntityItem) {
|
||||
Item item = ((EntityItem) var1).getEntityItem().getItem();
|
||||
for (Item blacklisted : blacklist) {
|
||||
if (blacklisted == item) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user