mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 19:05:16 +00:00
Added proper blacklists for the Ring of Magnetization.
This commit is contained in:
1 parent
b5af383f61
commit
1c1e6525e9
6 files changed
+84
-6
No files matched your search
@@ -83,8 +83,9 @@ public final class BotaniaAPI {
|
||||
public static Map<String, Integer> oreWeights = new HashMap<String, Integer>();
|
||||
public static Map<String, Integer> oreWeightsNether = new HashMap<String, Integer>();
|
||||
public static Map<Item, Block> seeds = new HashMap();
|
||||
public static Set<Item> looniumBlacklist = new LinkedHashSet();
|
||||
public static Set<Item> looniumBlacklist = new LinkedHashSet<Item>();
|
||||
public static Set<Block> paintableBlocks = new LinkedHashSet<Block>();
|
||||
public static Set<String> magnetBlacklist = new LinkedHashSet<String>();
|
||||
|
||||
public static ArmorMaterial manasteelArmorMaterial = EnumHelper.addArmorMaterial("MANASTEEL", 16, new int[] { 2, 6, 5, 2 }, 18);
|
||||
public static ToolMaterial manasteelToolMaterial = EnumHelper.addToolMaterial("MANASTEEL", 3, 300, 6.2F, 2F, 20);
|
||||
@@ -281,6 +282,47 @@ public final class BotaniaAPI {
|
||||
paintableBlocks.add(paintable);
|
||||
return paintable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blacklists an item from being pulled by the Ring of Magnetization.
|
||||
* Short.MAX_VALUE can be used as the stack's damage for a wildcard.
|
||||
*/
|
||||
public static void blacklistItemFromMagnet(ItemStack stack) {
|
||||
String key = getMagnetKey(stack);
|
||||
magnetBlacklist.add(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blacklists a block from having items on top of it being pulled by the Ring of Magnetization.
|
||||
* Short.MAX_VALUE can be used as meta for a wildcard.
|
||||
*/
|
||||
public static void blacklistBlockFromMagnet(Block block, int meta) {
|
||||
String key = getMagnetKey(block, meta);
|
||||
magnetBlacklist.add(key);
|
||||
}
|
||||
|
||||
public static boolean isItemBlacklistedFromMagnet(ItemStack stack) {
|
||||
if(stack.getItemDamage() != Short.MAX_VALUE) {
|
||||
ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE);
|
||||
boolean general = isItemBlacklistedFromMagnet(copy);
|
||||
if(general)
|
||||
return true;
|
||||
}
|
||||
|
||||
String key = getMagnetKey(stack);
|
||||
return magnetBlacklist.contains(key);
|
||||
}
|
||||
|
||||
public static boolean isBlockBlacklistedFromMagnet(Block block, int meta) {
|
||||
if(meta != Short.MAX_VALUE) {
|
||||
boolean general = isBlockBlacklistedFromMagnet(block, Short.MAX_VALUE);
|
||||
if(general)
|
||||
return true;
|
||||
}
|
||||
|
||||
String key = getMagnetKey(block, meta);
|
||||
return magnetBlacklist.contains(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a Petal Recipe.
|
||||
@@ -559,4 +601,19 @@ public final class BotaniaAPI {
|
||||
public static Set<String> getAllSubTiles() {
|
||||
return subTiles.keySet();
|
||||
}
|
||||
|
||||
private static String getMagnetKey(ItemStack stack) {
|
||||
if(stack == null)
|
||||
return "";
|
||||
|
||||
return "i_" + stack.getItem().getUnlocalizedName() + "@" + stack.getItemDamage();
|
||||
}
|
||||
|
||||
private static String getMagnetKey(Block block, int meta) {
|
||||
if(meta == -1)
|
||||
return "b_" + block.getUnlocalizedName();
|
||||
|
||||
return "bm_" + block.getUnlocalizedName() + "@" + meta;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
@@ -61,6 +62,8 @@ public class BlockPool extends BlockModContainer implements IWandHUD, IWandable,
|
||||
setStepSound(soundTypeStone);
|
||||
setBlockName(LibBlockNames.POOL);
|
||||
setBlockBounds(0F, 0F, 0F, 1F, 0.5F, 1F);
|
||||
|
||||
BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.api.wand.IWandHUD;
|
||||
@@ -47,6 +48,8 @@ public class BlockRuneAltar extends BlockModContainer implements IWandable, IWan
|
||||
setResistance(10.0F);
|
||||
setStepSound(soundTypeStone);
|
||||
setBlockName(LibBlockNames.RUNE_ALTAR);
|
||||
|
||||
BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE);
|
||||
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexiconable;
|
||||
import vazkii.botania.api.lexicon.LexiconEntry;
|
||||
import vazkii.botania.client.core.helper.IconHelper;
|
||||
@@ -42,6 +43,8 @@ public class BlockTerraPlate extends BlockModContainer implements ILexiconable {
|
||||
setResistance(10F);
|
||||
setStepSound(soundTypeMetal);
|
||||
setBlockName(LibBlockNames.TERRA_PLATE);
|
||||
|
||||
BotaniaAPI.blacklistBlockFromMagnet(this, Short.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
|
||||
public final class IMCHandler {
|
||||
|
||||
|
||||
public static void processMessages(ImmutableList<IMCMessage> messageList) {
|
||||
Iterator<IMCMessage> iterator = messageList.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.common.item.equipment.bauble;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@@ -128,15 +129,26 @@ public class ItemMagnetRing extends ItemBauble {
|
||||
return false;
|
||||
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack == null || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(itemRegistry.getNameForObject(stack.getItem())))
|
||||
if(stack == null || stack.getItem() instanceof IManaItem || stack.getItem() instanceof IRelic || BLACKLIST.contains(itemRegistry.getNameForObject(stack.getItem())) || BotaniaAPI.isItemBlacklistedFromMagnet(stack))
|
||||
return false;
|
||||
|
||||
int x = net.minecraft.util.MathHelper.floor_double(item.posX);
|
||||
int y = net.minecraft.util.MathHelper.floor_double(item.posY);
|
||||
int y = (int) Math.floor(item.posY);
|
||||
int z = net.minecraft.util.MathHelper.floor_double(item.posZ);
|
||||
if(item.worldObj.getBlock(x, y, z) == ModBlocks.terraPlate)
|
||||
return false;
|
||||
Block block = item.worldObj.getBlock(x, y, z);
|
||||
int meta = item.worldObj.getBlockMetadata(x, y, z);
|
||||
|
||||
if(BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta))
|
||||
return false;
|
||||
|
||||
if(item.worldObj.isRemote) {
|
||||
block = item.worldObj.getBlock(x, y - 1, z);
|
||||
meta = item.worldObj.getBlockMetadata(x, y - 1, z);
|
||||
|
||||
if(BotaniaAPI.isBlockBlacklistedFromMagnet(block, meta))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user