Changed white- and blacklists in laser relays and ESDs to be for putting and pulling instead of both for both

This commit is contained in:
Ellpeck 2016-06-06 17:59:01 +02:00
parent 5bd872620c
commit 0b106526af
7 changed files with 37 additions and 24 deletions

View file

@ -172,8 +172,8 @@ public class GuiInputter extends GuiContainer{
this.mc.getTextureManager().bindTexture(this.isAdvanced ? resLocAdvanced : resLoc); this.mc.getTextureManager().bindTexture(this.isAdvanced ? resLocAdvanced : resLoc);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93+(this.isAdvanced ? OFFSET_ADVANCED : 0)); this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93+(this.isAdvanced ? OFFSET_ADVANCED : 0));
this.fontRendererObj.drawString(StringUtil.localize("info."+ModUtil.MOD_ID+".gui.pull"), this.guiLeft+22+3, this.guiTop+32+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); this.fontRendererObj.drawString("INBOUND", this.guiLeft+23+3, this.guiTop+32+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
this.fontRendererObj.drawString(StringUtil.localize("info."+ModUtil.MOD_ID+".gui.put"), this.guiLeft+107+3, this.guiTop+32+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); this.fontRendererObj.drawString("OUTBOUND", this.guiLeft+104+3, this.guiTop+32+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
this.fontRendererObj.drawString(sideString[this.tileInputter.sideToPull+1], this.guiLeft+24+1, this.guiTop+45+3+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); this.fontRendererObj.drawString(sideString[this.tileInputter.sideToPull+1], this.guiLeft+24+1, this.guiTop+45+3+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);
this.fontRendererObj.drawString(sideString[this.tileInputter.sideToPut+1], this.guiLeft+109+1, this.guiTop+45+3+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT); this.fontRendererObj.drawString(sideString[this.tileInputter.sideToPut+1], this.guiLeft+109+1, this.guiTop+45+3+(this.isAdvanced ? OFFSET_ADVANCED : 0), StringUtil.DECIMAL_COLOR_GRAY_TEXT);

View file

@ -55,11 +55,13 @@ public class GuiLaserRelayItemWhitelist extends GuiContainer{
this.whitelistLeft = new SmallerButton(0, this.guiLeft+3, this.guiTop+16, ""); this.whitelistLeft = new SmallerButton(0, this.guiLeft+3, this.guiTop+16, "");
this.whitelistRight = new SmallerButton(1, this.guiLeft+157, this.guiTop+16, ""); this.whitelistRight = new SmallerButton(1, this.guiLeft+157, this.guiTop+16, "");
SmallerButton smartWhitelist = new SmallerButton(2, this.guiLeft+80, this.guiTop+33, "S"); SmallerButton smartWhitelistLeft = new SmallerButton(2, this.guiLeft+3, this.guiTop+34, "S");
SmallerButton smartWhitelistRight = new SmallerButton(3, this.guiLeft+157, this.guiTop+34, "S");
this.buttonList.add(this.whitelistLeft); this.buttonList.add(this.whitelistLeft);
this.buttonList.add(this.whitelistRight); this.buttonList.add(this.whitelistRight);
this.buttonList.add(smartWhitelist); this.buttonList.add(smartWhitelistLeft);
this.buttonList.add(smartWhitelistRight);
} }
@Override @Override
@ -90,7 +92,7 @@ public class GuiLaserRelayItemWhitelist extends GuiContainer{
list.addAll(infoList); list.addAll(infoList);
this.drawHoveringText(list, x, y); this.drawHoveringText(list, x, y);
} }
if(x >= this.guiLeft+80 && y >= this.guiTop+33 && x <= this.guiLeft+95 && y <= this.guiTop+46){ if(((x >= this.guiLeft+3 && x <= this.guiLeft+3+15) || (x >= this.guiLeft+157 && x <= this.guiLeft+157+15)) && y <= this.guiTop+34+15 && y >= this.guiTop+34){
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add(TextFormatting.BOLD+StringUtil.localize("info."+ModUtil.MOD_ID+".gui.smart")); list.add(TextFormatting.BOLD+StringUtil.localize("info."+ModUtil.MOD_ID+".gui.smart"));
list.addAll(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localize("info."+ModUtil.MOD_ID+".gui.smartInfo"), 200)); list.addAll(this.fontRendererObj.listFormattedStringToWidth(StringUtil.localize("info."+ModUtil.MOD_ID+".gui.smartInfo"), 200));
@ -101,6 +103,11 @@ public class GuiLaserRelayItemWhitelist extends GuiContainer{
@Override @Override
public void drawGuiContainerForegroundLayer(int x, int y){ public void drawGuiContainerForegroundLayer(int x, int y){
AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.tile.name); AssetUtil.displayNameString(this.fontRendererObj, this.xSize, -10, this.tile.name);
String s1 = "INBOUND";
String s2 = "OUTBOUND";
this.fontRendererObj.drawString(s1, 46-this.fontRendererObj.getStringWidth(s1)/2, 80, StringUtil.DECIMAL_COLOR_GRAY_TEXT);
this.fontRendererObj.drawString(s2, 131-this.fontRendererObj.getStringWidth(s2)/2, 80, StringUtil.DECIMAL_COLOR_GRAY_TEXT);
} }
@Override @Override

View file

@ -114,7 +114,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
} }
} }
//If ESD has enough Space & Item in question is on whitelist //If ESD has enough Space & Item in question is on whitelist
if(tempStack != null && (this.slots[0] == null || (tempStack.isItemEqual(this.slots[0]) && this.slots[0].stackSize < maxSize)) && this.checkBothFilters(tempStack)){ if(tempStack != null && (this.slots[0] == null || (tempStack.isItemEqual(this.slots[0]) && this.slots[0].stackSize < maxSize)) && this.checkBothFilters(tempStack, false)){
//Deal with ISided //Deal with ISided
if(theSided != null){ if(theSided != null){
//Check if Item can be inserted from any Side (Because Sidedness gets ignored!) //Check if Item can be inserted from any Side (Because Sidedness gets ignored!)
@ -203,7 +203,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
maxSize = theInventory.getInventoryStackLimit(); maxSize = theInventory.getInventoryStackLimit();
} }
} }
if(theInventory.isItemValidForSlot(i, this.slots[0]) && (tempStack == null || (tempStack.isItemEqual(this.slots[0]) && tempStack.stackSize < maxSize)) && this.checkBothFilters(this.slots[0])){ if(theInventory.isItemValidForSlot(i, this.slots[0]) && (tempStack == null || (tempStack.isItemEqual(this.slots[0]) && tempStack.stackSize < maxSize)) && this.checkBothFilters(this.slots[0], true)){
if(theSided != null){ if(theSided != null){
for(int j = 0; j <= 5; j++){ for(int j = 0; j <= 5; j++){
if(theSided.canInsertItem(i, this.slots[0], EnumFacing.values()[j])){ if(theSided.canInsertItem(i, this.slots[0], EnumFacing.values()[j])){
@ -260,13 +260,12 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt
/** /**
* Checks if one of the filters contains the ItemStack * Checks if one of the filters contains the ItemStack
* (Whitelist or empty Blacklist in one of them always lets the Item through!)
* *
* @param stack The ItemStack * @param stack The ItemStack
* @return If the Item is filtered correctly * @return If the Item is filtered correctly
*/ */
private boolean checkBothFilters(ItemStack stack){ private boolean checkBothFilters(ItemStack stack, boolean output){
return this.checkFilter(stack, true, this.isPullWhitelist) || this.checkFilter(stack, false, this.isPutWhitelist); return this.checkFilter(stack, !output, output ? this.isPutWhitelist : this.isPullWhitelist);
} }
/** /**

View file

@ -91,7 +91,7 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){ public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){
SpecificItemHandlerInfo handler = this.getSwitchedIndexHandler(index); SpecificItemHandlerInfo handler = this.getSwitchedIndexHandler(index);
if(handler != null){ if(handler != null){
if(this.isWhitelisted(handler, stack)){ if(this.isWhitelisted(handler, stack, true)){
if(ItemStack.areItemsEqual(handler.handler.getStackInSlot(handler.switchedIndex), stack)){ if(ItemStack.areItemsEqual(handler.handler.getStackInSlot(handler.switchedIndex), stack)){
ItemStack gaveBack = handler.handler.extractItem(handler.switchedIndex, stack.stackSize, true); ItemStack gaveBack = handler.handler.extractItem(handler.switchedIndex, stack.stackSize, true);
return gaveBack != null; return gaveBack != null;
@ -101,11 +101,11 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{
return false; return false;
} }
private boolean isWhitelisted(SpecificItemHandlerInfo handler, ItemStack stack){ private boolean isWhitelisted(SpecificItemHandlerInfo handler, ItemStack stack, boolean output){
boolean whitelisted = handler.relayInQuestion.isWhitelisted(stack); boolean whitelisted = handler.relayInQuestion.isWhitelisted(stack, output);
TileEntityLaserRelayItem connected = this.getConnectedRelay(); TileEntityLaserRelayItem connected = this.getConnectedRelay();
if(connected != null && connected != handler.relayInQuestion){ if(connected != null && connected != handler.relayInQuestion){
return whitelisted && connected.isWhitelisted(stack); return whitelisted && connected.isWhitelisted(stack, !output);
} }
else{ else{
return whitelisted; return whitelisted;
@ -116,7 +116,7 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{
public boolean isItemValidForSlot(int index, ItemStack stack){ public boolean isItemValidForSlot(int index, ItemStack stack){
SpecificItemHandlerInfo handler = this.getSwitchedIndexHandler(index); SpecificItemHandlerInfo handler = this.getSwitchedIndexHandler(index);
if(handler != null){ if(handler != null){
if(this.isWhitelisted(handler, stack)){ if(this.isWhitelisted(handler, stack, false)){
ItemStack gaveBack = handler.handler.insertItem(handler.switchedIndex, stack, true); ItemStack gaveBack = handler.handler.insertItem(handler.switchedIndex, stack, true);
return !ItemStack.areItemStacksEqual(gaveBack, stack); return !ItemStack.areItemStacksEqual(gaveBack, stack);
} }

View file

@ -32,7 +32,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
this("laserRelayItem"); this("laserRelayItem");
} }
public boolean isWhitelisted(ItemStack stack){ public boolean isWhitelisted(ItemStack stack, boolean output){
return true; return true;
} }

View file

@ -20,6 +20,7 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextComponentTranslation;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor{ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem implements IButtonReactor{
@ -162,8 +163,8 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem
} }
@Override @Override
public boolean isWhitelisted(ItemStack stack){ public boolean isWhitelisted(ItemStack stack, boolean output){
return this.checkFilter(stack, true, this.isLeftWhitelist) || this.checkFilter(stack, false, this.isRightWhitelist); return this.checkFilter(stack, !output, output ? this.isRightWhitelist : this.isLeftWhitelist);
} }
private boolean checkFilter(ItemStack stack, boolean left, boolean isWhitelist){ private boolean checkFilter(ItemStack stack, boolean left, boolean isWhitelist){
@ -207,18 +208,24 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem
this.isRightWhitelist = !this.isRightWhitelist; this.isRightWhitelist = !this.isRightWhitelist;
} }
else if(buttonID == 2){ else if(buttonID == 2){
this.addWhitelistSmart(); this.addWhitelistSmart(false);
}
else if(buttonID == 3){
this.addWhitelistSmart(true);
} }
} }
private void addWhitelistSmart(){ private void addWhitelistSmart(boolean output){
int slotStart = output ? 12 : 0;
int slotStop = slotStart+12;
List<IItemHandler> handlers = this.getAllHandlersAround(); List<IItemHandler> handlers = this.getAllHandlersAround();
for(IItemHandler handler : handlers){ for(IItemHandler handler : handlers){
for(int i = 0; i < handler.getSlots(); i++){ for(int i = 0; i < handler.getSlots(); i++){
ItemStack stack = handler.getStackInSlot(i); ItemStack stack = handler.getStackInSlot(i);
if(stack != null){ if(stack != null){
if(!ItemUtil.contains(this.slots, stack, false)){ if(!ItemUtil.contains(Arrays.copyOfRange(this.slots, slotStart, slotStop), stack, false)){
for(int j = 0; j < this.slots.length; j++){ for(int j = slotStart; j < slotStop; j++){
if(this.slots[j] == null || this.slots[j].stackSize <= 0){ if(this.slots[j] == null || this.slots[j].stackSize <= 0){
ItemStack whitelistStack = stack.copy(); ItemStack whitelistStack = stack.copy();
whitelistStack.stackSize = 1; whitelistStack.stackSize = 1;

View file

@ -541,10 +541,10 @@ info.actuallyadditions.gui.coffee=Coffee
info.actuallyadditions.gui.ok=Ok info.actuallyadditions.gui.ok=Ok
info.actuallyadditions.gui.the=the info.actuallyadditions.gui.the=the
info.actuallyadditions.gui.smart=Smart Whitelist info.actuallyadditions.gui.smart=Smart Whitelist
info.actuallyadditions.gui.smartInfo=When pressing this, all items from inventories adjacent to this relay will be added to the white- and blacklist. First, the left side will be completely filled, and if there's more items, they will go to the right side. info.actuallyadditions.gui.smartInfo=When pressing this, all items from inventories adjacent to this relay will be added to this part of the white- or blacklist.
info.actuallyadditions.inputter.info.1=This is the first Slot in the connected Inventory to <p> at. info.actuallyadditions.inputter.info.1=This is the first Slot in the connected Inventory to <p> at.
info.actuallyadditions.inputter.info.2=This is the slot after the last Slot in the connected Inventory to <p> at. What that means: If you, for example, write 2 in the field to the left and 5 in this one, it will <p> at Slot 2, 3, and 4. info.actuallyadditions.inputter.info.2=This is the slot after the last Slot in the connected Inventory to <p> at. What that means: If you, for example, write 2 in the field to the left and 5 in this one, it will <p> at Slot 2, 3, and 4.
info.actuallyadditions.inputter.whitelistInfo=This applies for this part of the white-/blacklist. The other side applies as well, so you can have some Items whitelisted and some blacklisted. Note that, if you have an empty blacklist or an item whitelisted on at least one side, it will always go through. info.actuallyadditions.inputter.whitelistInfo=When pressing this, this side's whitelist mode will be changed. To let all items through, an empty blacklist can be used, to let no items through, an empty whitelist can be used. To configure certain items, place them in the slots.
info.actuallyadditions.noLens=No Lens info.actuallyadditions.noLens=No Lens
info.actuallyadditions.booklet.manualName.1=Actually Additions info.actuallyadditions.booklet.manualName.1=Actually Additions
info.actuallyadditions.booklet.manualName.2=Manual info.actuallyadditions.booklet.manualName.2=Manual