From de86e0b2a2ddc45e2e2c9383b219106ee4e2da21 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sun, 20 Jul 2014 20:19:01 -0400 Subject: [PATCH] Finished off the filtering system! Also added new "fuzzy mode" to ItemStack filters in order to ignore metadata checks. --- .../client/gui/GuiMItemStackFilter.java | 19 +++++++++++++++ .../java/mekanism/client/gui/GuiSlot.java | 3 ++- .../common/miner/MItemStackFilter.java | 19 ++++++++------- .../common/tile/TileEntityDigitalMiner.java | 22 +++++++++++++----- .../mekanism/gui/GuiMItemStackFilter.png | Bin 4501 -> 5141 bytes .../assets/mekanism/gui/elements/GuiSlot.png | Bin 2836 -> 2957 bytes .../resources/assets/mekanism/lang/en_US.lang | 1 + 7 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java index 8fc9b078e..57a591522 100644 --- a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java @@ -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) { diff --git a/src/main/java/mekanism/client/gui/GuiSlot.java b/src/main/java/mekanism/client/gui/GuiSlot.java index 2e22eadbe..c17a4f5a6 100644 --- a/src/main/java/mekanism/client/gui/GuiSlot.java +++ b/src/main/java/mekanism/client/gui/GuiSlot.java @@ -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; diff --git a/src/main/java/mekanism/common/miner/MItemStackFilter.java b/src/main/java/mekanism/common/miner/MItemStackFilter.java index 39552089c..1bc560607 100644 --- a/src/main/java/mekanism/common/miner/MItemStackFilter.java +++ b/src/main/java/mekanism/common/miner/MItemStackFilter.java @@ -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 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; diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index 640e33e8b..b8ac8b017 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -206,11 +206,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I List 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; } } diff --git a/src/main/resources/assets/mekanism/gui/GuiMItemStackFilter.png b/src/main/resources/assets/mekanism/gui/GuiMItemStackFilter.png index 4da67ab336695cab7182bfeea1314ee09e5696b9..f848a31e60b262cda7a6c5499f8de4df5f17712a 100644 GIT binary patch delta 3730 zcmbVPc{r478=n~?CPkF3%_J?(U~FZ}7=<{>aunJ|Otyr<#4yG?lT%q5Q%NLSt{Ez4932Eqt17}@4LQpuB)%-ujjp=-}Afg-|xNO`?}tk{V|6N#>d6~`;yPR=R>PaJ4t9V6)Sx1P>;M>xUrnwOt0L0|qWLYKea2qWd; zUm>A>xxv<(a}Mwsw36amH7~5zd$d%BSG2AZ~r%ze-Rlu`(b_Ead>xcFZc$rqm%b_ zyuQ5rMy5a4w?gsmF8@yD<@bj!zCz^22~tf(75R-D_;&HwMp)O<*WH<)dLsc!?bui7 zf5rYtbPTzX{XeStruA!-FBY}=81hf!P@7M^Jai5O5+#}$8J;14$Gc8@ch<>*F4vbR zFfGK!fgV%Q#p5h<>lTyH-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f{f9~pj|k+5zP>dELg?3pu^w=)ALg{)Wa}%M+^ndz^l(B5+_gv zC`UwS{7LnVtE3y?4?Lq(?#U2j{y?`1-=>5IxCJ+iA_#xvxSh-{V3a|9F`K$Id zuc7(#?tS@o`V>ir{_GIfua7vOq%ukHS3&V0!%n*(PbYsxWFI1!P^nC<*yM-^Oewvl znq@}-vXK8a0h_)-BY!ljY;u5$Q2vVg^(vYr6mWm=6>&5z@K;YS70FX_nH>EcuZ+!EO1xnq9l#qh}t@3hs zcqWQqtASmt{ZJTtggiUQ@wWY3e*wuv7$-ctPjH15bnSdk0*qnZ|9S@cdu{)ti@mZT zX>PuGrNTpFsatumc%_1EO)YflF-j}E{QG)}#z)o3>k^9)!BmkRLmUnA`};B4g9Fe& z^3Z}-O&i9|dP9=c$PZ5{UyitNbQvXa?c4)Bna|mGDPahg>KSMMAV7`x7Pw>qK2&o2 z=Q7Y=9}N?XU_O+Fh^LyF4comvz>lgSuC~$Ov&68j=3P`#nMX};J0fpbDX3-mzWGut znYDcFL{4medKn8@Fo|(SN5ak!BSbjrS1@oOo&mCz9U(;aMzW->3g!|`o16nQY($i(dy9ufVjIMsv^PZoJsm^tJu-zQ+UV0UH290b(F*T_Nl)BG>ANl-~x`B_P69oc6 z55pO3njyG-PZqPqL4*rXD2?8V9 z9{4Z%6QR2YxAA<#r}JBxdJL)8Wf#>5k`Pu#BXEz9#rsrYtq{`T?gCb-(-4))*;~~^ zhy>t|jIGkCF1hZ*Sd)iI$rR_bvC($AwZg}VJ>!Z_!c+cIuBTOP)O7EZA{M-}PsmjW zGqUPJp)c8lGS9MACVhnKVK2mrW>pJnn~`bH)$VB4X-M=e_ui_a5y=*9%I@2 GfBzpkMV;UP diff --git a/src/main/resources/assets/mekanism/gui/elements/GuiSlot.png b/src/main/resources/assets/mekanism/gui/elements/GuiSlot.png index dc64827db380cee1e492cf6f49103a39a99abf02..bea9f695f85d7242a167318b013b08d376360818 100644 GIT binary patch delta 973 zcmV;;12X)S7L6CM9|V5~SV=@dRCodH-M>#1K@T=}kl5MUT9}wqH z-!N~EgBzx1XJ-c?@mN_|32U$WiBUp0ad|2%uTLe%ITMbBSK)t7a-8#FA-oCCljDRi zw-aNtg*Z(ia^-2Nqv?9Ab1i+Ko6@-6C@>vABTnFyV|8_P*Z}U`?4^VWFRwlhVSNzJ z^&TX}xzT^J(*QzP?wwAG^R<6_*Z_LH>q&9?{l%U8H$!TirXq6XX{w{?`fi>1Xw16lCfvyT@09_q9brWboV7M!A3vn7lEG;b!w;$iw z*hqTv=hJ`S8zj}Y`P^hP8T z0Rod02PS{y6*#*zvuAUTyxCc9S2@vR-K%D$D3#Y99T^l&{ z5=a#=`BMemPoSd$CVxiV}OS54Ilmi*~hXsBEU{vV_BwL{*00000NkvXXu0mjf*H60< delta 809 zcmV+^1J?YF7nByT9|V5}-$_J4RCodH-LYyEK^OqwISm%}ioSqCKuDuaP@7beRf1nhhYD?w4t%pMDyaK|Q@$z&G4ZF1SY{r^AT-28h9 z*}2i`>gp^cZrj`2VdvvCF-i!RZjQp%?kG9V)o>wv2#=HFTn~Tu!>8~zIZg;`2Ql_D z#OVuBDoeaB;+JLv=6m&Wm4ftC1-IDu2P$z;+rfF}>eDPh9<+b=`dorP=TXGwAH zO`G9TR6ql$bYPT4poD-1 zP(oP_0+kAA0F@4mvIvwA&;Uv(%R!)00S%zifl(HL5&{}P31vA5R4SkWR5~!qB2Yp= z11O;^2Z2fjG=NG6Mp*<(2xtH$l;t2$slZBH3n1RlpSpj=#XOq(`4a=h#XREu{Ha@9 z%p=~8 zZzpfc