From 3ad6b1c7cb5d55fc99068cbcdd497c7704b26e48 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 12 May 2016 19:00:42 +0200 Subject: [PATCH] Made Item Laser relays that have a whitelist have more priority than those who don't --- .../mod/tile/TileEntityItemViewer.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java index fa490f7c0..3d21eb0b6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemViewer.java @@ -2,6 +2,7 @@ package de.ellpeck.actuallyadditions.mod.tile; import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler; import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay.TileEntityLaserRelayItem; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay.TileEntityLaserRelayItemWhitelist; import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import net.minecraft.item.ItemStack; @@ -11,6 +12,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.items.IItemHandler; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class TileEntityItemViewer extends TileEntityInventoryBase{ @@ -32,6 +34,7 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{ private SpecificItemHandlerInfo getSwitchedIndexHandler(int i){ List infos = this.getItemHandlerInfos(); + Collections.sort(infos); int currentI = 0; if(infos != null && !infos.isEmpty()){ for(GenericItemHandlerInfo info : infos){ @@ -195,7 +198,7 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{ } } - public static class GenericItemHandlerInfo{ + public static class GenericItemHandlerInfo implements Comparable{ public List handlers = new ArrayList(); public TileEntityLaserRelayItem relayInQuestion; @@ -221,5 +224,21 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{ } return false; } + + @Override + public int compareTo(GenericItemHandlerInfo other){ + if(other != null){ + boolean thisWhitelist = this.relayInQuestion instanceof TileEntityLaserRelayItemWhitelist; + boolean otherWhitelist = other.relayInQuestion instanceof TileEntityLaserRelayItemWhitelist; + + if(!thisWhitelist && otherWhitelist){ + return 1; + } + else if(thisWhitelist && !otherWhitelist){ + return -1; + } + } + return 0; + } } }