Finished off the filtering system! Also added new "fuzzy mode" to ItemStack filters in order to ignore metadata checks.

This commit is contained in:
Aidan C. Brady 2014-07-20 20:19:01 -04:00
parent 4adb6de83d
commit de86e0b2a2
7 changed files with 48 additions and 16 deletions

View file

@ -149,6 +149,11 @@ public class GuiMItemStackFilter extends GuiMekanism
{
drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis);
}
if(xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59)
{
drawCreativeTabHoveringText(MekanismUtils.localize("gui.digitalMiner.fuzzyMode") + ": " + LangUtils.transYesNo(filter.fuzzy), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@ -196,6 +201,14 @@ public class GuiMItemStackFilter extends GuiMekanism
else {
drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14);
}
if(xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59)
{
drawTexturedModalRect(guiWidth + 14, guiHeight + 45, 176 + 37, 0, 14, 14);
}
else {
drawTexturedModalRect(guiWidth + 14, guiHeight + 45, 176 + 37, 14, 14, 14);
}
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35)
{
@ -249,6 +262,12 @@ public class GuiMItemStackFilter extends GuiMekanism
SoundHandler.playSound("gui.button.press");
filter.requireStack = !filter.requireStack;
}
if(xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59)
{
SoundHandler.playSound("gui.button.press");
filter.fuzzy = !filter.fuzzy;
}
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35)
{

View file

@ -105,7 +105,8 @@ public class GuiSlot extends GuiElement
PLUS(18, 18, 18, 18),
POWER(18, 18, 36, 18),
INPUT(18, 18, 54, 18),
OUTPUT(18, 18, 72, 18);
OUTPUT(18, 18, 72, 18),
CHECK(18, 18, 0, 36);
public int width;
public int height;

View file

@ -3,23 +3,16 @@ package mekanism.common.miner;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
import mekanism.api.ListUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class MItemStackFilter extends MinerFilter
{
private static List<Block> metaIgnoreArray = ListUtils.asList(Blocks.planks, Blocks.ladder, Blocks.torch,
Blocks.furnace, Blocks.dispenser, Blocks.piston,
Blocks.piston_extension, Blocks.piston_head);
public ItemStack itemType;
public boolean fuzzy;
public MItemStackFilter(ItemStack item)
{
@ -36,7 +29,7 @@ public class MItemStackFilter extends MinerFilter
return false;
}
if(itemStack.getItem() == itemType.getItem() && metaIgnoreArray.contains(Block.getBlockFromItem(itemType.getItem())))
if(itemStack.getItem() == itemType.getItem() && fuzzy)
{
return true;
}
@ -50,6 +43,8 @@ public class MItemStackFilter extends MinerFilter
super.write(nbtTags);
nbtTags.setInteger("type", 0);
nbtTags.setBoolean("fuzzy", fuzzy);
itemType.writeToNBT(nbtTags);
return nbtTags;
@ -60,6 +55,7 @@ public class MItemStackFilter extends MinerFilter
{
super.read(nbtTags);
fuzzy = nbtTags.getBoolean("fuzzy");
itemType = ItemStack.loadItemStackFromNBT(nbtTags);
}
@ -70,6 +66,8 @@ public class MItemStackFilter extends MinerFilter
super.write(data);
data.add(fuzzy);
data.add(MekanismUtils.getID(itemType));
data.add(itemType.stackSize);
data.add(itemType.getItemDamage());
@ -80,6 +78,8 @@ public class MItemStackFilter extends MinerFilter
{
super.read(dataStream);
fuzzy = dataStream.readBoolean();
itemType = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt());
}
@ -105,6 +105,7 @@ public class MItemStackFilter extends MinerFilter
MItemStackFilter filter = new MItemStackFilter();
filter.replaceStack = replaceStack;
filter.requireStack = requireStack;
filter.fuzzy = fuzzy;
filter.itemType = itemType.copy();
return filter;

View file

@ -206,11 +206,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
List<ItemStack> drops = MinerUtils.getDrops(worldObj, coord, silkTouch);
if(canInsert(drops))
if(canInsert(drops) && setReplace(coord, index))
{
add(drops);
setReplace(coord, index);
toRemove.add(index);
worldObj.playAuxSFXAtEntity(null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, Block.getIdFromBlock(block) + (meta << 12));
@ -294,10 +292,13 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
return MekanismUtils.getTicks(this, 80);
}
public void setReplace(Coord4D obj, int index)
/*
* returns false if unsuccessful
*/
public boolean setReplace(Coord4D obj, int index)
{
ItemStack stack = getReplace(index);
if(stack != null)
{
worldObj.setBlock(obj.xCoord, obj.yCoord, obj.zCoord, Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 3);
@ -307,9 +308,18 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
obj.getBlock(worldObj).dropBlockAsItem(worldObj, obj.xCoord, obj.yCoord, obj.zCoord, obj.getMetadata(worldObj), 1);
worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord);
}
return true;
}
else {
worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord);
if(!replaceMap.get(index).requireStack)
{
worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord);
return true;
}
return false;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -440,6 +440,7 @@ gui.digitalMiner.toMine=To mine
gui.digitalMiner.running=Running
gui.digitalMiner.inverse=Inverse mode
gui.digitalMiner.requireReplace=Require replace
gui.digitalMiner.fuzzyMode=Fuzzy mode
//Recipe names
recipe.mekanismShaped=Shaped