Merge branch 'master' into development

This commit is contained in:
Ben Spiers 2014-07-13 19:56:28 +01:00
commit d8b9ff7a20
7 changed files with 62 additions and 25 deletions

View file

@ -0,0 +1,38 @@
package mekanism.api;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
public class BlockInfo
{
public Block block;
public int meta;
public BlockInfo(Block b, int j)
{
block = b;
meta = j;
}
public static BlockInfo get(ItemStack stack)
{
return new BlockInfo(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
}
@Override
public boolean equals(Object obj)
{
return obj instanceof BlockInfo &&
((BlockInfo)obj).block == block &&
((BlockInfo)obj).meta == meta;
}
@Override
public int hashCode()
{
int code = 1;
code = 31 * code + block.getUnlocalizedName().hashCode();
code = 31 * code + meta;
return code;
}
}

View file

@ -1,29 +1,29 @@
package mekanism.api;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
public class ItemInfo
{
public Block block;
public Item item;
public int meta;
public ItemInfo(Block b, int j)
public ItemInfo(Item i, int j)
{
block = b;
item = i;
meta = j;
}
public static ItemInfo get(ItemStack stack)
{
return new ItemInfo(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
return new ItemInfo(stack.getItem(), stack.getItemDamage());
}
@Override
public boolean equals(Object obj)
{
return obj instanceof ItemInfo &&
((ItemInfo)obj).block == block &&
return obj instanceof BlockInfo &&
((ItemInfo)obj).item == item &&
((ItemInfo)obj).meta == meta;
}
@ -31,8 +31,8 @@ public class ItemInfo
public int hashCode()
{
int code = 1;
code = 31 * code + block.getUnlocalizedName().hashCode();
code = 31 * code + item.getUnlocalizedName().hashCode();
code = 31 * code + meta;
return code;
}
}
}

View file

@ -11,11 +11,11 @@ import net.minecraftforge.oredict.OreDictionary;
public class MekanismAPI
{
//Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes
private static Set<ItemInfo> cardboardBoxIgnore = new HashSet<ItemInfo>();
private static Set<BlockInfo> cardboardBoxIgnore = new HashSet<BlockInfo>();
public static boolean isBlockCompatible(Item item, int meta)
{
for(ItemInfo i : cardboardBoxIgnore)
for(BlockInfo i : cardboardBoxIgnore)
{
if(i.block == Block.getBlockFromItem(item) && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta))
{
@ -28,15 +28,15 @@ public class MekanismAPI
public static void addBoxBlacklist(Block block, int meta)
{
cardboardBoxIgnore.add(new ItemInfo(block, meta));
cardboardBoxIgnore.add(new BlockInfo(block, meta));
}
public static void removeBoxBlacklist(Block block, int meta)
{
cardboardBoxIgnore.remove(new ItemInfo(block, meta));
cardboardBoxIgnore.remove(new BlockInfo(block, meta));
}
public static Set<ItemInfo> getBoxIgnore()
public static Set<BlockInfo> getBoxIgnore()
{
return cardboardBoxIgnore;
}

View file

@ -3,11 +3,10 @@ package mekanism.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mekanism.api.ItemInfo;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StackUtils;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

View file

@ -365,11 +365,11 @@ public final class OreDictManager
} catch(Exception e) {}
try {
FurnaceRecipes.smelting().func_151394_a(new ItemStack(Mekanism.Dust, 8), MekanismUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), 0.0F);
FurnaceRecipes.smelting().func_151394_a(new ItemStack(Mekanism.Dust, 1, 8), MekanismUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), 0.0F);
} catch(Exception e) {}
try {
FurnaceRecipes.smelting().func_151394_a(new ItemStack(Mekanism.Dust, 9), MekanismUtils.size(OreDictionary.getOres("ingotLead").get(0), 1), 0.0F);
FurnaceRecipes.smelting().func_151394_a(new ItemStack(Mekanism.Dust, 1, 9), MekanismUtils.size(OreDictionary.getOres("ingotLead").get(0), 1), 0.0F);
} catch(Exception e) {}
try {

View file

@ -4,12 +4,12 @@ import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.BlockInfo;
import mekanism.api.Coord4D;
import mekanism.api.ItemInfo;
import mekanism.common.tile.TileEntityBoundingBlock;
import mekanism.common.tile.TileEntityDigitalMiner;
import mekanism.common.util.MekanismUtils;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
@ -21,7 +21,7 @@ public class ThreadMinerSearch extends Thread
public BitSet oresToMine = new BitSet();
public Map<ItemInfo, Boolean> acceptedItems = new HashMap<ItemInfo, Boolean>();
public Map<BlockInfo, Boolean> acceptedItems = new HashMap<BlockInfo, Boolean>();
public int found = 0;
@ -44,7 +44,7 @@ public class ThreadMinerSearch extends Thread
Coord4D coord = tileEntity.getStartingCoord();
int diameter = tileEntity.getDiameter();
int size = tileEntity.getTotalSize();
ItemInfo info = new ItemInfo(null, 0);
BlockInfo info = new BlockInfo(null, 0);
for(int i = 0; i < size; i++)
{

View file

@ -1,12 +1,12 @@
package mekanism.common.network;
import io.netty.buffer.ByteBuf;
import mekanism.api.ItemInfo;
import mekanism.api.BlockInfo;
import mekanism.api.MekanismAPI;
import mekanism.common.Mekanism;
import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage;
import net.minecraft.block.Block;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
@ -28,7 +28,7 @@ public class PacketBoxBlacklist implements IMessageHandler<BoxBlacklistMessage,
{
dataStream.writeInt(MekanismAPI.getBoxIgnore().size());
for(ItemInfo info : MekanismAPI.getBoxIgnore())
for(BlockInfo info : MekanismAPI.getBoxIgnore())
{
dataStream.writeInt(Block.getIdFromBlock(info.block));
dataStream.writeInt(info.meta);