mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 16:58:34 +01:00
Added Oredict-based checking to everything with filters~
This commit is contained in:
parent
5e63208098
commit
38de0e9ac7
13 changed files with 109 additions and 37 deletions
|
@ -33,6 +33,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
import net.minecraft.stats.Achievement;
|
import net.minecraft.stats.Achievement;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -309,7 +310,7 @@ public final class BookletUtils{
|
||||||
* Called when one of the buttons to open an index or a chapter is pressed
|
* Called when one of the buttons to open an index or a chapter is pressed
|
||||||
*/
|
*/
|
||||||
public static void handleChapterButtonClick(GuiBooklet booklet, GuiButton button){
|
public static void handleChapterButtonClick(GuiBooklet booklet, GuiButton button){
|
||||||
int place = Util.arrayContains(booklet.chapterButtons, button);
|
int place = ArrayUtils.indexOf(booklet.chapterButtons, button);
|
||||||
if(place >= 0){
|
if(place >= 0){
|
||||||
if(booklet.currentEntrySet.getCurrentEntry() != null){
|
if(booklet.currentEntrySet.getCurrentEntry() != null){
|
||||||
if(booklet.currentEntrySet.getCurrentChapter() == null){
|
if(booklet.currentEntrySet.getCurrentChapter() == null){
|
||||||
|
|
|
@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -34,7 +35,7 @@ public class BookletPageAA extends BookletPage{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getID(){
|
public int getID(){
|
||||||
return Util.arrayContains(this.chapter.getPages(), this)+1;
|
return ArrayUtils.indexOf(this.chapter.getPages(), this)+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class WorldData{
|
||||||
|
|
||||||
public static final String DATA_TAG = ModUtil.MOD_ID+"data";
|
public static final String DATA_TAG = ModUtil.MOD_ID+"data";
|
||||||
public static final ArrayList<PlayerSave> PLAYER_SAVE_DATA = new ArrayList<PlayerSave>();
|
public static final ArrayList<PlayerSave> PLAYER_SAVE_DATA = new ArrayList<PlayerSave>();
|
||||||
private static final Map<Integer, WorldData> WORLD_DATA = new ConcurrentHashMap<Integer, WorldData>();
|
private static final ConcurrentHashMap<Integer, WorldData> WORLD_DATA = new ConcurrentHashMap<Integer, WorldData>();
|
||||||
public final ConcurrentSet<Network> laserRelayNetworks = new ConcurrentSet<Network>();
|
public final ConcurrentSet<Network> laserRelayNetworks = new ConcurrentSet<Network>();
|
||||||
private final ISaveHandler handler;
|
private final ISaveHandler handler;
|
||||||
private final int dimension;
|
private final int dimension;
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class OreGen implements IWorldGenerator{
|
||||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){
|
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider){
|
||||||
int dimension = world.provider.getDimension();
|
int dimension = world.provider.getDimension();
|
||||||
if(dimension != -1 && dimension != 1){
|
if(dimension != -1 && dimension != 1){
|
||||||
if(world.getWorldType() != WorldType.FLAT && Util.arrayContains(ArrayUtils.toObject(ConfigIntListValues.ORE_GEN_DIMENSION_BLACKLIST.getValue()), world.provider.getDimension()) < 0){
|
if(world.getWorldType() != WorldType.FLAT && !ArrayUtils.contains(ConfigIntListValues.ORE_GEN_DIMENSION_BLACKLIST.getValue(), world.provider.getDimension())){
|
||||||
this.generateDefault(world, random, chunkX*16, chunkZ*16);
|
this.generateDefault(world, random, chunkX*16, chunkZ*16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class OreGen implements IWorldGenerator{
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onWorldDecoration(DecorateBiomeEvent.Decorate event){
|
public void onWorldDecoration(DecorateBiomeEvent.Decorate event){
|
||||||
if((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)){
|
if((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT)){
|
||||||
if(Util.arrayContains(ArrayUtils.toObject(ConfigIntListValues.PLANT_DIMENSION_BLACKLIST.getValue()), event.getWorld().provider.getDimension()) < 0){
|
if(!ArrayUtils.contains(ConfigIntListValues.PLANT_DIMENSION_BLACKLIST.getValue(), event.getWorld().provider.getDimension())){
|
||||||
this.generateRice(event);
|
this.generateRice(event);
|
||||||
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.GRASS, event);
|
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.CANOLA.ordinal(), ConfigIntValues.CANOLA_AMOUNT.getValue(), ConfigBoolValues.DO_CANOLA_GEN.isEnabled(), Material.GRASS, event);
|
||||||
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.GRASS, event);
|
this.genPlantNormally(InitBlocks.blockWildPlant, TheWildPlants.FLAX.ordinal(), ConfigIntValues.FLAX_AMOUNT.getValue(), ConfigBoolValues.DO_FLAX_GEN.isEnabled(), Material.GRASS, event);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class FilterSettingsGui extends Gui{
|
||||||
public SmallerButton whitelistButton;
|
public SmallerButton whitelistButton;
|
||||||
public SmallerButton metaButton;
|
public SmallerButton metaButton;
|
||||||
public SmallerButton nbtButton;
|
public SmallerButton nbtButton;
|
||||||
|
public SmallerButton oredictButton;
|
||||||
|
|
||||||
public FilterSettingsGui(FilterSettings settings, int x, int y, List<GuiButton> buttonList){
|
public FilterSettingsGui(FilterSettings settings, int x, int y, List<GuiButton> buttonList){
|
||||||
this.theSettings = settings;
|
this.theSettings = settings;
|
||||||
|
@ -47,6 +48,9 @@ public class FilterSettingsGui extends Gui{
|
||||||
this.nbtButton = new SmallerButton(this.theSettings.nbtButtonId, x, y+36, "");
|
this.nbtButton = new SmallerButton(this.theSettings.nbtButtonId, x, y+36, "");
|
||||||
buttonList.add(this.nbtButton);
|
buttonList.add(this.nbtButton);
|
||||||
|
|
||||||
|
this.oredictButton = new SmallerButton(this.theSettings.oredictButtonId, x, y+54, "");
|
||||||
|
buttonList.add(this.oredictButton);
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +58,7 @@ public class FilterSettingsGui extends Gui{
|
||||||
this.whitelistButton.displayString = (this.theSettings.isWhitelist ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"W";
|
this.whitelistButton.displayString = (this.theSettings.isWhitelist ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"W";
|
||||||
this.metaButton.displayString = (this.theSettings.respectMeta ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"M";
|
this.metaButton.displayString = (this.theSettings.respectMeta ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"M";
|
||||||
this.nbtButton.displayString = (this.theSettings.respectNBT ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"N";
|
this.nbtButton.displayString = (this.theSettings.respectNBT ? TextFormatting.DARK_GREEN : TextFormatting.RED)+"N";
|
||||||
|
this.oredictButton.displayString = (this.theSettings.respectOredict == 0 ? TextFormatting.RED : (this.theSettings.respectOredict == 1 ? TextFormatting.GREEN : TextFormatting.DARK_GREEN))+"O";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawHover(int mouseX, int mouseY){
|
public void drawHover(int mouseX, int mouseY){
|
||||||
|
@ -71,5 +76,22 @@ public class FilterSettingsGui extends Gui{
|
||||||
else if(this.nbtButton.isMouseOver()){
|
else if(this.nbtButton.isMouseOver()){
|
||||||
GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.BOLD+(this.theSettings.respectNBT ? "Respecting" : "Ignoring")+" NBT"), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
|
GuiUtils.drawHoveringText(Collections.singletonList(TextFormatting.BOLD+(this.theSettings.respectNBT ? "Respecting" : "Ignoring")+" NBT"), mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
|
||||||
}
|
}
|
||||||
|
else if(this.oredictButton.isMouseOver()){
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
list.add(TextFormatting.BOLD+(this.theSettings.respectOredict == 0 ? "Ignoring" : (this.theSettings.respectOredict == 1 ? "Soft Respecting" : "Hard Respecting"))+" OreDictionary");
|
||||||
|
|
||||||
|
String type = null;
|
||||||
|
if(this.theSettings.respectOredict == 1){
|
||||||
|
type = "only one";
|
||||||
|
}
|
||||||
|
else if(this.theSettings.respectOredict == 2){
|
||||||
|
type = "all";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type != null){
|
||||||
|
list.addAll(mc.fontRendererObj.listFormattedStringToWidth("The item being passed only has to contain "+TextFormatting.DARK_GREEN+type+TextFormatting.RESET+" of the OreDictionary tags of the item in the filter.", 200));
|
||||||
|
}
|
||||||
|
GuiUtils.drawHoveringText(list, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRendererObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,8 @@ public class GuiInputter extends GuiContainer{
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|
||||||
if(this.isAdvanced){
|
if(this.isAdvanced){
|
||||||
this.leftFilter = new FilterSettingsGui(this.tileInputter.leftFilter, this.guiLeft+3, this.guiTop+16, this.buttonList);
|
this.leftFilter = new FilterSettingsGui(this.tileInputter.leftFilter, this.guiLeft+3, this.guiTop+6, this.buttonList);
|
||||||
this.rightFilter = new FilterSettingsGui(this.tileInputter.rightFilter, this.guiLeft+157, this.guiTop+16, this.buttonList);
|
this.rightFilter = new FilterSettingsGui(this.tileInputter.rightFilter, this.guiLeft+157, this.guiTop+6, this.buttonList);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fieldPullStart = new GuiTextField(3000, this.fontRendererObj, this.guiLeft+6, this.guiTop+80+(this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8);
|
this.fieldPullStart = new GuiTextField(3000, this.fontRendererObj, this.guiLeft+6, this.guiTop+80+(this.isAdvanced ? OFFSET_ADVANCED : 0), 34, 8);
|
||||||
|
|
|
@ -65,11 +65,11 @@ public class GuiLaserRelayItemWhitelist extends GuiContainer{
|
||||||
public void initGui(){
|
public void initGui(){
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|
||||||
this.leftFilter = new FilterSettingsGui(this.tile.leftFilter, this.guiLeft+3, this.guiTop+8, this.buttonList);
|
this.leftFilter = new FilterSettingsGui(this.tile.leftFilter, this.guiLeft+3, this.guiTop+6, this.buttonList);
|
||||||
this.rightFilter = new FilterSettingsGui(this.tile.rightFilter, this.guiLeft+157, this.guiTop+8, this.buttonList);
|
this.rightFilter = new FilterSettingsGui(this.tile.rightFilter, this.guiLeft+157, this.guiTop+6, this.buttonList);
|
||||||
|
|
||||||
this.buttonSmartWhitelistLeft = new SmallerButton(2, this.guiLeft+3, this.guiTop+64, "S");
|
this.buttonSmartWhitelistLeft = new SmallerButton(2, this.guiLeft+3, this.guiTop+79, "S");
|
||||||
this.buttonSmartWhitelistRight = new SmallerButton(3, this.guiLeft+157, this.guiTop+64, "S");
|
this.buttonSmartWhitelistRight = new SmallerButton(3, this.guiLeft+157, this.guiTop+79, "S");
|
||||||
this.buttonList.add(this.buttonSmartWhitelistLeft);
|
this.buttonList.add(this.buttonSmartWhitelistLeft);
|
||||||
this.buttonList.add(this.buttonSmartWhitelistRight);
|
this.buttonList.add(this.buttonSmartWhitelistRight);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class GuiRangedCollector extends GuiContainer{
|
||||||
public void initGui(){
|
public void initGui(){
|
||||||
super.initGui();
|
super.initGui();
|
||||||
|
|
||||||
this.filter = new FilterSettingsGui(this.collector.filter, this.guiLeft+3, this.guiTop+16, this.buttonList);
|
this.filter = new FilterSettingsGui(this.collector.filter, this.guiLeft+3, this.guiTop+6, this.buttonList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,8 @@ import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemFilter;
|
import de.ellpeck.actuallyadditions.mod.items.ItemFilter;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
public class FilterSettings{
|
public class FilterSettings{
|
||||||
|
|
||||||
|
@ -30,21 +32,27 @@ public class FilterSettings{
|
||||||
public boolean respectNBT;
|
public boolean respectNBT;
|
||||||
private boolean lastRespectNBT;
|
private boolean lastRespectNBT;
|
||||||
|
|
||||||
|
public int respectOredict;
|
||||||
|
private int lastRecpectOredict;
|
||||||
|
|
||||||
public final int whitelistButtonId;
|
public final int whitelistButtonId;
|
||||||
public final int metaButtonId;
|
public final int metaButtonId;
|
||||||
public final int nbtButtonId;
|
public final int nbtButtonId;
|
||||||
|
public final int oredictButtonId;
|
||||||
|
|
||||||
public FilterSettings(int startSlot, int endSlot, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, int buttonIdStart){
|
public FilterSettings(int startSlot, int endSlot, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, int defaultRespectOredict, int buttonIdStart){
|
||||||
this.startSlot = startSlot;
|
this.startSlot = startSlot;
|
||||||
this.endSlot = endSlot;
|
this.endSlot = endSlot;
|
||||||
|
|
||||||
this.isWhitelist = defaultWhitelist;
|
this.isWhitelist = defaultWhitelist;
|
||||||
this.respectMeta = defaultRespectMeta;
|
this.respectMeta = defaultRespectMeta;
|
||||||
this.respectNBT = defaultRespectNBT;
|
this.respectNBT = defaultRespectNBT;
|
||||||
|
this.respectOredict = defaultRespectOredict;
|
||||||
|
|
||||||
this.whitelistButtonId = buttonIdStart;
|
this.whitelistButtonId = buttonIdStart;
|
||||||
this.metaButtonId = buttonIdStart+1;
|
this.metaButtonId = buttonIdStart+1;
|
||||||
this.nbtButtonId = buttonIdStart+2;
|
this.nbtButtonId = buttonIdStart+2;
|
||||||
|
this.oredictButtonId = buttonIdStart+3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeToNBT(NBTTagCompound tag, String name){
|
public void writeToNBT(NBTTagCompound tag, String name){
|
||||||
|
@ -52,6 +60,7 @@ public class FilterSettings{
|
||||||
compound.setBoolean("Whitelist", this.isWhitelist);
|
compound.setBoolean("Whitelist", this.isWhitelist);
|
||||||
compound.setBoolean("Meta", this.respectMeta);
|
compound.setBoolean("Meta", this.respectMeta);
|
||||||
compound.setBoolean("NBT", this.respectNBT);
|
compound.setBoolean("NBT", this.respectNBT);
|
||||||
|
compound.setInteger("Oredict", this.respectOredict);
|
||||||
tag.setTag(name, compound);
|
tag.setTag(name, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,16 +69,18 @@ public class FilterSettings{
|
||||||
this.isWhitelist = compound.getBoolean("Whitelist");
|
this.isWhitelist = compound.getBoolean("Whitelist");
|
||||||
this.respectMeta = compound.getBoolean("Meta");
|
this.respectMeta = compound.getBoolean("Meta");
|
||||||
this.respectNBT = compound.getBoolean("NBT");
|
this.respectNBT = compound.getBoolean("NBT");
|
||||||
|
this.respectOredict = compound.getInteger("Oredict");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsUpdateSend(){
|
public boolean needsUpdateSend(){
|
||||||
return this.lastWhitelist != this.isWhitelist || this.lastRespectMeta != this.respectMeta || this.lastRespectNBT != this.respectNBT;
|
return this.lastWhitelist != this.isWhitelist || this.lastRespectMeta != this.respectMeta || this.lastRespectNBT != this.respectNBT || this.lastRecpectOredict != this.respectOredict;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLasts(){
|
public void updateLasts(){
|
||||||
this.lastWhitelist = this.isWhitelist;
|
this.lastWhitelist = this.isWhitelist;
|
||||||
this.lastRespectMeta = this.respectMeta;
|
this.lastRespectMeta = this.respectMeta;
|
||||||
this.lastRespectNBT = this.respectNBT;
|
this.lastRespectNBT = this.respectNBT;
|
||||||
|
this.lastRecpectOredict = this.respectOredict;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onButtonPressed(int id){
|
public void onButtonPressed(int id){
|
||||||
|
@ -82,17 +93,25 @@ public class FilterSettings{
|
||||||
else if(id == this.nbtButtonId){
|
else if(id == this.nbtButtonId){
|
||||||
this.respectNBT = !this.respectNBT;
|
this.respectNBT = !this.respectNBT;
|
||||||
}
|
}
|
||||||
|
else if(id == this.oredictButtonId){
|
||||||
|
if(this.respectOredict+1 > 2){
|
||||||
|
this.respectOredict = 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.respectOredict++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean check(ItemStack stack, ItemStack[] slots){
|
public boolean check(ItemStack stack, ItemStack[] slots){
|
||||||
return check(stack, slots, this.startSlot, this.endSlot, this.isWhitelist, this.respectMeta, this.respectNBT);
|
return check(stack, slots, this.startSlot, this.endSlot, this.isWhitelist, this.respectMeta, this.respectNBT, this.respectOredict);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean check(ItemStack stack, ItemStack[] slots, int startSlot, int endSlot, boolean whitelist, boolean meta, boolean nbt){
|
public static boolean check(ItemStack stack, ItemStack[] slots, int startSlot, int endSlot, boolean whitelist, boolean meta, boolean nbt, int oredict){
|
||||||
if(stack != null){
|
if(stack != null){
|
||||||
for(int i = startSlot; i < endSlot; i++){
|
for(int i = startSlot; i < endSlot; i++){
|
||||||
if(slots[i] != null){
|
if(slots[i] != null){
|
||||||
if(areEqualEnough(slots[i], stack, meta, nbt)){
|
if(areEqualEnough(slots[i], stack, meta, nbt, oredict)){
|
||||||
return whitelist;
|
return whitelist;
|
||||||
}
|
}
|
||||||
else if(slots[i].getItem() instanceof ItemFilter){
|
else if(slots[i].getItem() instanceof ItemFilter){
|
||||||
|
@ -100,7 +119,7 @@ public class FilterSettings{
|
||||||
ItemDrill.loadSlotsFromNBT(filterSlots, slots[i]);
|
ItemDrill.loadSlotsFromNBT(filterSlots, slots[i]);
|
||||||
if(filterSlots != null && filterSlots.length > 0){
|
if(filterSlots != null && filterSlots.length > 0){
|
||||||
for(ItemStack filterSlot : filterSlots){
|
for(ItemStack filterSlot : filterSlots){
|
||||||
if(filterSlot != null && areEqualEnough(filterSlot, stack, meta, nbt)){
|
if(filterSlot != null && areEqualEnough(filterSlot, stack, meta, nbt, oredict)){
|
||||||
return whitelist;
|
return whitelist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,14 +131,54 @@ public class FilterSettings{
|
||||||
return !whitelist;
|
return !whitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean areEqualEnough(ItemStack first, ItemStack second, boolean meta, boolean nbt){
|
private static boolean areEqualEnough(ItemStack first, ItemStack second, boolean meta, boolean nbt, int oredict){
|
||||||
if(first.getItem() != second.getItem()){
|
if(first.getItem() != second.getItem()){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
boolean metaFine = !meta || first.getItemDamage() == second.getItemDamage();
|
boolean metaFine = !meta || first.getItemDamage() == second.getItemDamage();
|
||||||
boolean nbtFine = !nbt || ItemStack.areItemStackTagsEqual(first, second);
|
boolean nbtFine = !nbt || ItemStack.areItemStackTagsEqual(first, second);
|
||||||
return metaFine && nbtFine;
|
if(metaFine && nbtFine){
|
||||||
|
if(oredict == 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
int[] firstIds = OreDictionary.getOreIDs(first);
|
||||||
|
int[] secondIds = OreDictionary.getOreIDs(second);
|
||||||
|
boolean firstEmpty = ArrayUtils.isEmpty(firstIds);
|
||||||
|
boolean secondEmpty = ArrayUtils.isEmpty(secondIds);
|
||||||
|
|
||||||
|
//Both empty, meaning none has OreDict entries, so they are equal
|
||||||
|
if(firstEmpty && secondEmpty){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//Only one empty, meaning they are not equal
|
||||||
|
else if(firstEmpty || secondEmpty){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(int id : firstIds){
|
||||||
|
if(ArrayUtils.contains(secondIds, id)){
|
||||||
|
//Needs to match only one id, so return true on first match
|
||||||
|
if(oredict == 1){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Needs to match every id, so just return false when no match
|
||||||
|
else if(oredict == 2){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//If oredict mode 1, this will fail because nothing matched
|
||||||
|
//If oredict mode 2, this will mean nothing hasn't matched
|
||||||
|
return oredict == 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,8 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
|
||||||
private int lastPullSide;
|
private int lastPullSide;
|
||||||
private int lastPullStart;
|
private int lastPullStart;
|
||||||
private int lastPullEnd;
|
private int lastPullEnd;
|
||||||
public FilterSettings leftFilter = new FilterSettings(PULL_FILTER_START, PULL_FILTER_START+12, true, true, false, -1000);
|
public FilterSettings leftFilter = new FilterSettings(PULL_FILTER_START, PULL_FILTER_START+12, true, true, false, 0, -1000);
|
||||||
public FilterSettings rightFilter = new FilterSettings(PUT_FILTER_START, PUT_FILTER_START+12, true, true, false, -2000);
|
public FilterSettings rightFilter = new FilterSettings(PUT_FILTER_START, PUT_FILTER_START+12, true, true, false, 0, -2000);
|
||||||
|
|
||||||
private boolean hasCheckedTilesAround;
|
private boolean hasCheckedTilesAround;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem
|
||||||
|
|
||||||
public final IInventory filterInventory;
|
public final IInventory filterInventory;
|
||||||
private ItemStack[] slots = new ItemStack[24];
|
private ItemStack[] slots = new ItemStack[24];
|
||||||
public FilterSettings leftFilter = new FilterSettings(0, 12, true, true, false, -1000);
|
public FilterSettings leftFilter = new FilterSettings(0, 12, true, true, false, 0, -1000);
|
||||||
public FilterSettings rightFilter = new FilterSettings(12, 24, true, true, false, -2000);
|
public FilterSettings rightFilter = new FilterSettings(12, 24, true, true, false, 0, -2000);
|
||||||
|
|
||||||
public TileEntityLaserRelayItemWhitelist(){
|
public TileEntityLaserRelayItemWhitelist(){
|
||||||
super("laserRelayItemWhitelist");
|
super("laserRelayItemWhitelist");
|
||||||
|
@ -212,7 +212,7 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem
|
||||||
ItemStack copy = stack.copy();
|
ItemStack copy = stack.copy();
|
||||||
copy.stackSize = 1;
|
copy.stackSize = 1;
|
||||||
|
|
||||||
if(!FilterSettings.check(copy, this.slots, usedSettings.startSlot, usedSettings.endSlot, true, usedSettings.respectMeta, usedSettings.respectNBT)){
|
if(!FilterSettings.check(copy, this.slots, usedSettings.startSlot, usedSettings.endSlot, true, usedSettings.respectMeta, usedSettings.respectNBT, usedSettings.respectOredict)){
|
||||||
for(int k = usedSettings.startSlot; k < usedSettings.endSlot; k++){
|
for(int k = usedSettings.startSlot; k < usedSettings.endSlot; k++){
|
||||||
if(this.slots[k] != null){
|
if(this.slots[k] != null){
|
||||||
if(this.slots[k].getItem() instanceof ItemFilter){
|
if(this.slots[k].getItem() instanceof ItemFilter){
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
|
||||||
|
|
||||||
public static final int WHITELIST_START = 6;
|
public static final int WHITELIST_START = 6;
|
||||||
public static final int RANGE = 6;
|
public static final int RANGE = 6;
|
||||||
public FilterSettings filter = new FilterSettings(WHITELIST_START, WHITELIST_START+12, true, true, false, -1000);
|
public FilterSettings filter = new FilterSettings(WHITELIST_START, WHITELIST_START+12, true, true, false, 0, -1000);
|
||||||
|
|
||||||
public TileEntityRangedCollector(){
|
public TileEntityRangedCollector(){
|
||||||
super(18, "rangedCollector");
|
super(18, "rangedCollector");
|
||||||
|
|
|
@ -41,15 +41,4 @@ public final class Util{
|
||||||
public static boolean isDevVersion(){
|
public static boolean isDevVersion(){
|
||||||
return ModUtil.VERSION.equals("@VERSION@");
|
return ModUtil.VERSION.equals("@VERSION@");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int arrayContains(Object[] array, Object obj){
|
|
||||||
if(obj != null){
|
|
||||||
for(int i = 0; i < array.length; i++){
|
|
||||||
if(array[i] != null && (obj == array[i] || array[i].equals(obj))){
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue