diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java index 8d0094119..1cc469a85 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -25,7 +25,6 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityDigitalMiner; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; - import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; @@ -34,6 +33,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) @@ -43,6 +43,18 @@ public class GuiDigitalMinerConfig extends GuiMekanism public boolean isDragging = false; + // Scrollbar dimensions + private final int scrollX = 154; + private final int scrollY = 18; + private final int scrollW = 12; + private final int scrollH = 138; + + // Filter dimensions + private final int filterX = 56; + private final int filterY = 18; + private final int filterW = 96; + private final int filterH = 29; + public int dragOffset = 0; public int stackSwitch = 0; @@ -69,12 +81,12 @@ public class GuiDigitalMinerConfig extends GuiMekanism public int getFilterIndex() { - if(tileEntity.filters.size() <= 4) + if( needsScrollBars() ) { - return 0; + final int scrollSize = tileEntity.filters.size() - 4; + return (int)( ( scrollSize + 0.5 ) * scroll ); } - - return (int)((tileEntity.filters.size()*scroll) - ((4F/(float)tileEntity.filters.size()))*scroll); + return 0; } @Override @@ -197,7 +209,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) { - if(tileEntity.filters.size()>4) + if( needsScrollBars() ) { dragOffset = yAxis - (getScroll()+18); isDragging = true; @@ -213,6 +225,33 @@ public class GuiDigitalMinerConfig extends GuiMekanism { int yStart = i*29 + 18; + // Check for sorting button + final int arrowX = filterX + filterW - 12; + if( getFilterIndex() + i > 0 ) + if( xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20 ) + { + // Process up button click + final ArrayList data = new ArrayList(); + data.add( 11 ); + data.add( getFilterIndex() + i ); + + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "gui.button.press" ); + return; + } + if( getFilterIndex() + i < tileEntity.filters.size() - 1 ) + if( xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27 ) + { + // Process down button click + final ArrayList data = new ArrayList(); + data.add( 12 ); + data.add( getFilterIndex() + i ); + + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "gui.button.press" ); + return; + } + if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29) { MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); @@ -302,6 +341,35 @@ public class GuiDigitalMinerConfig extends GuiMekanism } } + /** + * Handles mouse input. + */ + @Override + public void handleMouseInput() + { + super.handleMouseInput(); + int i = Mouse.getEventDWheel(); + + if( i != 0 && needsScrollBars() ) + { + final int j = tileEntity.filters.size() - 4; + + if( i > 0 ) + i = 1; + + if( i < 0 ) + i = -1; + + scroll = (float)( scroll - (double)i / (double)j ); + + if( scroll < 0.0F ) + scroll = 0.0F; + + if( scroll > 1.0F ) + scroll = 1.0F; + } + } + @Override public void initGui() { @@ -463,7 +531,7 @@ public class GuiDigitalMinerConfig extends GuiMekanism int guiHeight = (height - ySize) / 2; drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15); + drawTexturedModalRect( guiLeft + scrollX, guiTop + scrollY + getScroll(), 232 + ( needsScrollBars() ? 0 : 12 ), 0, 12, 15 ); int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); @@ -496,6 +564,19 @@ public class GuiDigitalMinerConfig extends GuiMekanism drawTexturedModalRect(guiWidth + 56, guiHeight + yStart, mouseOver ? 0 : 96, 166, 96, 29); MekanismRenderer.resetColor(); + + // Draw sort buttons + final int arrowX = filterX + filterW - 12; + if( getFilterIndex() + i > 0 ) + { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20; + drawTexturedModalRect( guiLeft + arrowX, guiTop + yStart + 14, 190, mouseOver ? 143 : 115, 11, 7 ); + } + if( getFilterIndex() + i < tileEntity.filters.size() - 1 ) + { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27; + drawTexturedModalRect( guiLeft + arrowX, guiTop + yStart + 21, 190, mouseOver ? 157 : 129, 11, 7 ); + } } } @@ -658,4 +739,12 @@ public class GuiDigitalMinerConfig extends GuiMekanism public int stackIndex; public ItemStack renderStack; } + + /** + * returns true if there are more filters than can fit in the gui + */ + private boolean needsScrollBars() + { + return tileEntity.filters.size() > 4; + } } diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index 125a20faa..c923768d0 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -29,49 +29,81 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -@SideOnly(Side.CLIENT) +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly( Side.CLIENT ) public class GuiLogisticalSorter extends GuiMekanism { - public TileEntityLogisticalSorter tileEntity; + public TileEntityLogisticalSorter tileEntity; - public boolean isDragging = false; + /** + * True if the left mouse button was held down last time drawScreen was + * called. + */ + private boolean wasClicking; - public int dragOffset = 0; + // Buttons + int BUTTON_NEW = 0; - public int stackSwitch = 0; + /** Amount scrolled in filter list (0 = top, 1 = bottom) */ + public float scroll; + /** True if the scrollbar is being dragged */ + public boolean isDragging = false; - public Map oreDictStacks = new HashMap(); - public Map modIDStacks = new HashMap(); + // Scrollbar dimensions + private final int scrollX = 154; + private final int scrollY = 18; + private final int scrollW = 12; + private final int scrollH = 138; - public float scroll; + // Filter dimensions + private final int filterX = 56; + private final int filterY = 18; + private final int filterW = 96; + private final int filterH = 29; - public GuiLogisticalSorter(EntityPlayer player, TileEntityLogisticalSorter tentity) + public int dragOffset = 0; + + public int stackSwitch = 0; + + public Map< TOreDictFilter, StackData > oreDictStacks = new HashMap< TOreDictFilter, StackData >(); + public Map< TModIDFilter, StackData > modIDStacks = new HashMap< TModIDFilter, StackData >(); + + public GuiLogisticalSorter( EntityPlayer player, TileEntityLogisticalSorter entity ) { - super(tentity, new ContainerNull(player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png"))); + super( entity, new ContainerNull( player, entity ) ); + tileEntity = entity; + + // Set size of gui + // xSize = 189; + // ySize = 166; + + // Add common Mekanism gui elements + guiElements.add( new GuiRedstoneControl( this, tileEntity, MekanismUtils.getResource( ResourceType.GUI, "GuiLogisticalSorter.png" ) ) ); } public int getScroll() { - return Math.max(Math.min((int)(scroll*123), 123), 0); + // Calculate thumb position along scrollbar + return Math.max( Math.min( (int)( scroll * 123 ), 123 ), 0 ); } + // Get index to displayed filters public int getFilterIndex() { - if(tileEntity.filters.size() <= 4) + if( needsScrollBars() ) { - return 0; + final int scrollSize = tileEntity.filters.size() - 4; + return (int)( ( scrollSize + 0.5 ) * scroll ); } - - return (int)((tileEntity.filters.size()*scroll) - ((4F/(float)tileEntity.filters.size()))*scroll); + return 0; } @Override @@ -79,482 +111,529 @@ public class GuiLogisticalSorter extends GuiMekanism { super.updateScreen(); - if(stackSwitch > 0) - { + // Decrease timer for stack display rotation + if( stackSwitch > 0 ) stackSwitch--; - } - if(stackSwitch == 0) + // Update displayed stacks + if( stackSwitch == 0 ) { - for(Map.Entry entry : oreDictStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) + for( final Map.Entry< TOreDictFilter, StackData > entry : oreDictStacks.entrySet() ) + if( entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0 ) { - if(entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size()-1) - { + if( entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1 ) entry.getValue().stackIndex = 0; - } - else if(entry.getValue().stackIndex < entry.getValue().iterStacks.size()-1) - { - entry.getValue().stackIndex++; - } + else + if( entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1 ) + entry.getValue().stackIndex++; - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); + entry.getValue().renderStack = entry.getValue().iterStacks.get( entry.getValue().stackIndex ); } - } - - for(Map.Entry entry : modIDStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) + + for( final Map.Entry< TModIDFilter, StackData > entry : modIDStacks.entrySet() ) + if( entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0 ) { - if(entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size()-1) - { + if( entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1 ) entry.getValue().stackIndex = 0; - } - else if(entry.getValue().stackIndex < entry.getValue().iterStacks.size()-1) - { - entry.getValue().stackIndex++; - } + else + if( entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1 ) + entry.getValue().stackIndex++; - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); + entry.getValue().renderStack = entry.getValue().iterStacks.get( entry.getValue().stackIndex ); } - } stackSwitch = 20; } - else { - for(Map.Entry entry : oreDictStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) - { - entry.getValue().renderStack = null; - } - } - - for(Map.Entry entry : modIDStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) - { - entry.getValue().renderStack = null; - } - } - } - - Set oreDictFilters = new HashSet(); - Set modIDFilters = new HashSet(); - - for(int i = 0; i < 4; i++) + else { - if(tileEntity.filters.get(getFilterIndex()+i) instanceof TOreDictFilter) - { - oreDictFilters.add((TOreDictFilter)tileEntity.filters.get(getFilterIndex()+i)); - } - else if(tileEntity.filters.get(getFilterIndex()+i) instanceof TModIDFilter) - { - modIDFilters.add((TModIDFilter)tileEntity.filters.get(getFilterIndex()+i)); - } + for( final Map.Entry< TOreDictFilter, StackData > entry : oreDictStacks.entrySet() ) + if( entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0 ) + entry.getValue().renderStack = null; + + for( final Map.Entry< TModIDFilter, StackData > entry : modIDStacks.entrySet() ) + if( entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0 ) + entry.getValue().renderStack = null; } - for(TransporterFilter filter : tileEntity.filters) - { - if(filter instanceof TOreDictFilter && !oreDictFilters.contains(filter)) + final Set< TOreDictFilter > oreDictFilters = new HashSet< TOreDictFilter >(); + final Set< TModIDFilter > modIDFilters = new HashSet< TModIDFilter >(); + + for( int i = 0; i < 4; i++ ) + if( tileEntity.filters.get( getFilterIndex() + i ) instanceof TOreDictFilter ) + oreDictFilters.add( (TOreDictFilter)tileEntity.filters.get( getFilterIndex() + i ) ); + else + if( tileEntity.filters.get( getFilterIndex() + i ) instanceof TModIDFilter ) + modIDFilters.add( (TModIDFilter)tileEntity.filters.get( getFilterIndex() + i ) ); + + for( final TransporterFilter filter : tileEntity.filters ) + if( filter instanceof TOreDictFilter && !oreDictFilters.contains( filter ) ) { - if(oreDictStacks.containsKey(filter)) - { - oreDictStacks.remove(filter); - } + if( oreDictStacks.containsKey( filter ) ) + oreDictStacks.remove( filter ); } - else if(filter instanceof TModIDFilter && !modIDFilters.contains(filter)) - { - if(modIDStacks.containsKey(filter)) - { - modIDStacks.remove(filter); - } - } - } + else + if( filter instanceof TModIDFilter && !modIDFilters.contains( filter ) ) + if( modIDStacks.containsKey( filter ) ) + modIDStacks.remove( filter ); } @Override - public void mouseClicked(int mouseX, int mouseY, int button) + public void mouseClicked( int mouseX, int mouseY, int mouseBtn ) { - super.mouseClicked(mouseX, mouseY, button); + super.mouseClicked( mouseX, mouseY, mouseBtn ); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; - if(button == 0) + if( mouseBtn == 0 ) { - if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) - { - if(tileEntity.filters.size()>4) + // Check for scrollbar interaction + if( xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 && yAxis <= getScroll() + 18 + 15 ) + if( needsScrollBars() ) { - dragOffset = yAxis - (getScroll()+18); + dragOffset = yAxis - ( getScroll() + 18 ); isDragging = true; } - else { + else scroll = 0; - } - } - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) + // Check for filter interaction + for( int i = 0; i < 4; i++ ) + if( tileEntity.filters.get( getFilterIndex() + i ) != null ) { - int yStart = i*29 + 18; + final int yStart = i * 29 + 18; - if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29) + if( xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart + 29 ) { - TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i); + // Check for sorting button + final int arrowX = filterX + filterW - 12; + if( getFilterIndex() + i > 0 ) + if( xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20 ) + { + // Process up button click + final ArrayList data = new ArrayList(); + data.add( 3 ); + data.add( getFilterIndex() + i ); - if(filter instanceof TItemStackFilter) + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "gui.button.press" ); + return; + } + if( getFilterIndex() + i < tileEntity.filters.size() - 1 ) + if( xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27 ) + { + // Process down button click + final ArrayList data = new ArrayList(); + data.add( 4 ); + data.add( getFilterIndex() + i ); + + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "gui.button.press" ); + return; + } + + final TransporterFilter filter = tileEntity.filters.get( getFilterIndex() + i ); + + if( filter instanceof TItemStackFilter ) { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 1, getFilterIndex()+i, 0)); - } - else if(filter instanceof TOreDictFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 2, getFilterIndex()+i, 0)); - } - else if(filter instanceof TMaterialFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 3, getFilterIndex()+i, 0)); - } - else if(filter instanceof TModIDFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 5, getFilterIndex()+i, 0)); + SoundHandler.playSound( "gui.button.press" ); + Mekanism.packetHandler.sendToServer( new LogisticalSorterGuiMessage( SorterGuiPacket.SERVER_INDEX, Coord4D + .get( tileEntity ), 1, getFilterIndex() + i, 0 ) ); } + else + if( filter instanceof TOreDictFilter ) + { + SoundHandler.playSound( "gui.button.press" ); + Mekanism.packetHandler.sendToServer( new LogisticalSorterGuiMessage( SorterGuiPacket.SERVER_INDEX, Coord4D + .get( tileEntity ), 2, getFilterIndex() + i, 0 ) ); + } + else + if( filter instanceof TMaterialFilter ) + { + SoundHandler.playSound( "gui.button.press" ); + Mekanism.packetHandler.sendToServer( new LogisticalSorterGuiMessage( SorterGuiPacket.SERVER_INDEX, Coord4D + .get( tileEntity ), 3, getFilterIndex() + i, 0 ) ); + } + else + if( filter instanceof TModIDFilter ) + { + SoundHandler.playSound( "gui.button.press" ); + Mekanism.packetHandler.sendToServer( new LogisticalSorterGuiMessage( SorterGuiPacket.SERVER_INDEX, Coord4D + .get( tileEntity ), 5, getFilterIndex() + i, 0 ) ); + } } } + + // Check for auto eject button + if( xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124 ) + { + final ArrayList data = new ArrayList(); + data.add( 1 ); + + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "gui.button.press" ); } - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) + // Check for round robin button + if( xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98 ) { - ArrayList data = new ArrayList(); - data.add(1); + final ArrayList data = new ArrayList(); + data.add( 2 ); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - ArrayList data = new ArrayList(); - data.add(2); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "gui.button.press" ); } } - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } + if( Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) && mouseBtn == 0 ) + mouseBtn = 2; - if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) + // Check for default colour button + if( xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153 ) { - ArrayList data = new ArrayList(); - data.add(0); - data.add(button); + final ArrayList data = new ArrayList(); + data.add( 0 ); + data.add( mouseBtn ); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("mekanism:etc.Ding"); + Mekanism.packetHandler.sendToServer( new TileEntityMessage( Coord4D.get( tileEntity ), data ) ); + SoundHandler.playSound( "mekanism:etc.Ding" ); } } @Override - protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) + protected void mouseClickMove( int mouseX, int mouseY, int button, long ticks ) { - super.mouseClickMove(mouseX, mouseY, button, ticks); + super.mouseClickMove( mouseX, mouseY, button, ticks ); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; - if(isDragging) - { - scroll = Math.min(Math.max((float)(yAxis-18-dragOffset)/123F, 0), 1); - } + if( isDragging ) + scroll = Math.min( Math.max( ( yAxis - 18 - dragOffset ) / 123F, 0 ), 1 ); } @Override - protected void mouseMovedOrUp(int mouseX, int mouseY, int type) + protected void mouseMovedOrUp( int mouseX, int mouseY, int type ) { - super.mouseMovedOrUp(mouseX, mouseY, type); + super.mouseMovedOrUp( mouseX, mouseY, type ); - if(type == 0 && isDragging) + if( type == 0 && isDragging ) { dragOffset = 0; isDragging = false; } } + /** + * Handles mouse input. + */ + @Override + public void handleMouseInput() + { + super.handleMouseInput(); + int i = Mouse.getEventDWheel(); + + if( i != 0 && needsScrollBars() ) + { + final int j = tileEntity.filters.size() - 4; + + if( i > 0 ) + i = 1; + + if( i < 0 ) + i = -1; + + scroll = (float)( scroll - (double)i / (double)j ); + + if( scroll < 0.0F ) + scroll = 0.0F; + + if( scroll > 1.0F ) + scroll = 1.0F; + } + } + @Override public void initGui() { super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - + // Add buttons to gui buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 56, guiHeight + 136, 96, 20, MekanismUtils.localize("gui.newFilter"))); + buttonList.add( new GuiButton( BUTTON_NEW, guiLeft + 56, guiTop + 136, 96, 20, MekanismUtils.localize( "gui.newFilter" ) ) ); } @Override - protected void actionPerformed(GuiButton guibutton) + protected void actionPerformed( GuiButton guibutton ) { - super.actionPerformed(guibutton); + super.actionPerformed( guibutton ); - if(guibutton.id == 0) - { - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0)); - } + if( guibutton.id == BUTTON_NEW ) + Mekanism.packetHandler.sendToServer( new LogisticalSorterGuiMessage( SorterGuiPacket.SERVER, Coord4D.get( tileEntity ), 4, 0, 0 ) ); } @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY ) { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; - fontRendererObj.drawString(tileEntity.getInventoryName(), 43, 6, 0x404040); + // Write to info display + fontRendererObj.drawString( tileEntity.getInventoryName(), 43, 6, 0x404040 ); - fontRendererObj.drawString(MekanismUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00); - fontRendererObj.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); + fontRendererObj.drawString( MekanismUtils.localize( "gui.filters" ) + ":", 11, 19, 0x00CD00 ); + fontRendererObj.drawString( "T: " + tileEntity.filters.size(), 11, 28, 0x00CD00 ); - fontRendererObj.drawString("RR:", 12, 74, 0x00CD00); - fontRendererObj.drawString(MekanismUtils.localize("gui." + (tileEntity.roundRobin ? "on" : "off")), 27, 86, 0x00CD00); + fontRendererObj.drawString( "RR:", 12, 74, 0x00CD00 ); + fontRendererObj.drawString( MekanismUtils.localize( "gui." + ( tileEntity.roundRobin ? "on" : "off" ) ), 27, 86, 0x00CD00 ); - fontRendererObj.drawString(MekanismUtils.localize("gui.logisticalSorter.auto") + ":", 12, 100, 0x00CD00); - fontRendererObj.drawString(MekanismUtils.localize("gui." + (tileEntity.autoEject ? "on" : "off")), 27, 112, 0x00CD00); + fontRendererObj.drawString( MekanismUtils.localize( "gui.logisticalSorter.auto" ) + ":", 12, 100, 0x00CD00 ); + fontRendererObj.drawString( MekanismUtils.localize( "gui." + ( tileEntity.autoEject ? "on" : "off" ) ), 27, 112, 0x00CD00 ); - fontRendererObj.drawString(MekanismUtils.localize("gui.logisticalSorter.default") + ":", 12, 126, 0x00CD00); + fontRendererObj.drawString( MekanismUtils.localize( "gui.logisticalSorter.default" ) + ":", 12, 126, 0x00CD00 ); - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) + // Draw filters + for( int i = 0; i < 4; i++ ) + if( tileEntity.filters.get( getFilterIndex() + i ) != null ) { - TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i); - int yStart = i*29 + 18; + final TransporterFilter filter = tileEntity.filters.get( getFilterIndex() + i ); + final int yStart = i * filterH + filterY; - if(filter instanceof TItemStackFilter) + if( filter instanceof TItemStackFilter ) { - TItemStackFilter itemFilter = (TItemStackFilter)filter; + final TItemStackFilter itemFilter = (TItemStackFilter)filter; - if(itemFilter.itemType != null) + if( itemFilter.itemType != null ) { GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable( GL11.GL_LIGHTING ); + itemRender.renderItemAndEffectIntoGUI( fontRendererObj, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3 ); + GL11.glDisable( GL11.GL_LIGHTING ); GL11.glPopMatrix(); } - fontRendererObj.drawString(MekanismUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : MekanismUtils.localize("gui.none"), 78, yStart + 11, 0x404040); + fontRendererObj.drawString( MekanismUtils.localize( "gui.itemFilter" ), 78, yStart + 2, 0x404040 ); + fontRendererObj.drawString( filter.color != null ? filter.color.getName() : MekanismUtils.localize( "gui.none" ), 78, + yStart + 11, 0x404040 ); } - else if(filter instanceof TOreDictFilter) - { - TOreDictFilter oreFilter = (TOreDictFilter)filter; - - if(!oreDictStacks.containsKey(oreFilter)) + else + if( filter instanceof TOreDictFilter ) { - updateStackList(oreFilter); + final TOreDictFilter oreFilter = (TOreDictFilter)filter; + + if( !oreDictStacks.containsKey( oreFilter ) ) + updateStackList( oreFilter ); + + if( oreDictStacks.get( filter ).renderStack != null ) + try + { + GL11.glPushMatrix(); + GL11.glEnable( GL11.GL_LIGHTING ); + itemRender.renderItemAndEffectIntoGUI( fontRendererObj, mc.getTextureManager(), + oreDictStacks.get( filter ).renderStack, 59, yStart + 3 ); + GL11.glDisable( GL11.GL_LIGHTING ); + GL11.glPopMatrix(); + } + catch( final Exception e ) + {} + + fontRendererObj.drawString( MekanismUtils.localize( "gui.oredictFilter" ), 78, yStart + 2, 0x404040 ); + fontRendererObj.drawString( filter.color != null ? filter.color.getName() : MekanismUtils.localize( "gui.none" ), 78, + yStart + 11, 0x404040 ); } + else + if( filter instanceof TMaterialFilter ) + { + final TMaterialFilter itemFilter = (TMaterialFilter)filter; - if(oreDictStacks.get(filter).renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), oreDictStacks.get(filter).renderStack, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } + if( itemFilter.materialItem != null ) + { + GL11.glPushMatrix(); + GL11.glEnable( GL11.GL_LIGHTING ); + itemRender.renderItemAndEffectIntoGUI( fontRendererObj, mc.getTextureManager(), itemFilter.materialItem, 59, + yStart + 3 ); + GL11.glDisable( GL11.GL_LIGHTING ); + GL11.glPopMatrix(); + } - fontRendererObj.drawString(MekanismUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : MekanismUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } - else if(filter instanceof TMaterialFilter) - { - TMaterialFilter itemFilter = (TMaterialFilter)filter; + fontRendererObj.drawString( MekanismUtils.localize( "gui.materialFilter" ), 78, yStart + 2, 0x404040 ); + fontRendererObj.drawString( filter.color != null ? filter.color.getName() : MekanismUtils.localize( "gui.none" ), 78, + yStart + 11, 0x404040 ); + } + else + if( filter instanceof TModIDFilter ) + { + final TModIDFilter modFilter = (TModIDFilter)filter; - if(itemFilter.materialItem != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.materialItem, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + if( !modIDStacks.containsKey( modFilter ) ) + updateStackList( modFilter ); - fontRendererObj.drawString(MekanismUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : MekanismUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } - else if(filter instanceof TModIDFilter) - { - TModIDFilter modFilter = (TModIDFilter)filter; + if( modIDStacks.get( filter ).renderStack != null ) + try + { + GL11.glPushMatrix(); + GL11.glEnable( GL11.GL_LIGHTING ); + itemRender.renderItemAndEffectIntoGUI( fontRendererObj, mc.getTextureManager(), + modIDStacks.get( filter ).renderStack, 59, yStart + 3 ); + GL11.glDisable( GL11.GL_LIGHTING ); + GL11.glPopMatrix(); + } + catch( final Exception e ) + {} - if(!modIDStacks.containsKey(modFilter)) - { - updateStackList(modFilter); - } + fontRendererObj.drawString( MekanismUtils.localize( "gui.modIDFilter" ), 78, yStart + 2, 0x404040 ); + fontRendererObj.drawString( filter.color != null ? filter.color.getName() : MekanismUtils.localize( "gui.none" ), 78, + yStart + 11, 0x404040 ); + } - if(modIDStacks.get(filter).renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), modIDStacks.get(filter).renderStack, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } - - fontRendererObj.drawString(MekanismUtils.localize("gui.modIDFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : MekanismUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } + // Draw hovertext for sorting buttons + final int arrowX = filterX + filterW - 12; + if( getFilterIndex() + i > 0 ) + if( xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20 ) + drawCreativeTabHoveringText( MekanismUtils.localize( "gui.moveUp" ), xAxis, yAxis ); + if( getFilterIndex() + i < tileEntity.filters.size() - 1 ) + if( xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27 ) + drawCreativeTabHoveringText( MekanismUtils.localize( "gui.moveDown" ), xAxis, yAxis ); } - } - if(tileEntity.color != null) + if( tileEntity.color != null ) { GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + GL11.glColor4f( 1, 1, 1, 1 ); + GL11.glEnable( GL11.GL_LIGHTING ); + GL11.glEnable( GL12.GL_RESCALE_NORMAL ); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(13, 137, MekanismRenderer.getColorIcon(tileEntity.color), 16, 16); + mc.getTextureManager().bindTexture( MekanismRenderer.getBlocksTexture() ); + itemRender.renderIcon( 13, 137, MekanismRenderer.getColorIcon( tileEntity.color ), 16, 16 ); - GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable( GL11.GL_LIGHTING ); GL11.glPopMatrix(); } - if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) - { - if(tileEntity.color != null) - { - drawCreativeTabHoveringText(tileEntity.color.getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(MekanismUtils.localize("gui.none"), xAxis, yAxis); - } - } + // Draw tooltips for buttons + if( xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153 ) + if( tileEntity.color != null ) + drawCreativeTabHoveringText( tileEntity.color.getName(), xAxis, yAxis ); + else + drawCreativeTabHoveringText( MekanismUtils.localize( "gui.none" ), xAxis, yAxis ); - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) - { - drawCreativeTabHoveringText(MekanismUtils.localize("gui.autoEject"), xAxis, yAxis); - } + if( xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124 ) + drawCreativeTabHoveringText( MekanismUtils.localize( "gui.autoEject" ), xAxis, yAxis ); - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - drawCreativeTabHoveringText(MekanismUtils.localize("gui.logisticalSorter.roundRobin"), xAxis, yAxis); - } + if( xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98 ) + drawCreativeTabHoveringText( MekanismUtils.localize( "gui.logisticalSorter.roundRobin" ), xAxis, yAxis ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + super.drawGuiContainerForegroundLayer( mouseX, mouseY ); } @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + protected void drawGuiContainerBackgroundLayer( float partialTick, int mouseX, int mouseY ) { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + super.drawGuiContainerBackgroundLayer( partialTick, mouseX, mouseY ); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + // Draw main gui background + mc.renderEngine.bindTexture( MekanismUtils.getResource( ResourceType.GUI, "GuiLogisticalSorter.png" ) ); + GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); + drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize ); - drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15); + // Draw scrollbar + drawTexturedModalRect( guiLeft + scrollX, guiTop + scrollY + getScroll(), 232 + ( needsScrollBars() ? 0 : 12 ), 0, 12, 15 ); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) + // Draw filter backgrounds + for( int i = 0; i < 4; i++ ) + if( tileEntity.filters.get( getFilterIndex() + i ) != null ) { - TransporterFilter filter = tileEntity.filters.get(getFilterIndex()+i); - int yStart = i*29 + 18; + final TransporterFilter filter = tileEntity.filters.get( getFilterIndex() + i ); + final int yStart = i * filterH + filterY; - boolean mouseOver = xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29; + // Flag for mouse over this filter + boolean mouseOver = xAxis >= filterX && xAxis <= filterX + filterW && yAxis >= yStart && yAxis <= yStart + filterH; - if(filter instanceof TItemStackFilter) - { - MekanismRenderer.color(EnumColor.INDIGO, 1.0F, 2.5F); - } - else if(filter instanceof TOreDictFilter) - { - MekanismRenderer.color(EnumColor.BRIGHT_GREEN, 1.0F, 2.5F); - } - else if(filter instanceof TMaterialFilter) - { - MekanismRenderer.color(EnumColor.PURPLE, 1.0F, 4F); - } - else if(filter instanceof TModIDFilter) - { - MekanismRenderer.color(EnumColor.PINK, 1.0F, 2.5F); - } - - drawTexturedModalRect(guiWidth + 56, guiHeight + yStart, mouseOver ? 0 : 96, 166, 96, 29); + // Change colour based on filter type + if( filter instanceof TItemStackFilter ) + MekanismRenderer.color( EnumColor.INDIGO, 1.0F, 2.5F ); + else + if( filter instanceof TOreDictFilter ) + MekanismRenderer.color( EnumColor.BRIGHT_GREEN, 1.0F, 2.5F ); + else + if( filter instanceof TMaterialFilter ) + MekanismRenderer.color( EnumColor.PURPLE, 1.0F, 4F ); + else + if( filter instanceof TModIDFilter ) + MekanismRenderer.color( EnumColor.PINK, 1.0F, 2.5F ); + + drawTexturedModalRect( guiLeft + filterX, guiTop + yStart, mouseOver ? 0 : filterW, 166, filterW, filterH ); MekanismRenderer.resetColor(); + + // Draw sort buttons + final int arrowX = filterX + filterW - 12; + if( getFilterIndex() + i > 0 ) + { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20; + drawTexturedModalRect( guiLeft + arrowX, guiTop + yStart + 14, 190, mouseOver ? 143 : 115, 11, 7 ); + } + if( getFilterIndex() + i < tileEntity.filters.size() - 1 ) + { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27; + drawTexturedModalRect( guiLeft + arrowX, guiTop + yStart + 21, 190, mouseOver ? 157 : 129, 11, 7 ); + } } - } - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) - { - drawTexturedModalRect(guiWidth + 12, guiHeight + 110, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 12, guiHeight + 110, 176, 14, 14, 14); - } + // Draw gui buttons + if( xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124 ) + drawTexturedModalRect( guiLeft + 12, guiTop + 110, 176, 0, 14, 14 ); + else + drawTexturedModalRect( guiLeft + 12, guiTop + 110, 176, 14, 14, 14 ); - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - drawTexturedModalRect(guiWidth + 12, guiHeight + 84, 176 + 14, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 12, guiHeight + 84, 176 + 14, 14, 14, 14); - } + if( xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98 ) + drawTexturedModalRect( guiLeft + 12, guiTop + 84, 176 + 14, 0, 14, 14 ); + else + drawTexturedModalRect( guiLeft + 12, guiTop + 84, 176 + 14, 14, 14, 14 ); } - private void updateStackList(TOreDictFilter filter) + private void updateStackList( TOreDictFilter filter ) { - if(!oreDictStacks.containsKey(filter)) - { - oreDictStacks.put(filter, new StackData()); - } - - oreDictStacks.get(filter).iterStacks = OreDictCache.getOreDictStacks(filter.oreDictName, false); + if( !oreDictStacks.containsKey( filter ) ) + oreDictStacks.put( filter, new StackData() ); + + oreDictStacks.get( filter ).iterStacks = OreDictCache.getOreDictStacks( filter.oreDictName, false ); stackSwitch = 0; updateScreen(); - oreDictStacks.get(filter).stackIndex = -1; + oreDictStacks.get( filter ).stackIndex = -1; } - - private void updateStackList(TModIDFilter filter) + + private void updateStackList( TModIDFilter filter ) { - if(!modIDStacks.containsKey(filter)) - { - modIDStacks.put(filter, new StackData()); - } - - modIDStacks.get(filter).iterStacks = OreDictCache.getModIDStacks(filter.modID, false); + if( !modIDStacks.containsKey( filter ) ) + modIDStacks.put( filter, new StackData() ); + + modIDStacks.get( filter ).iterStacks = OreDictCache.getModIDStacks( filter.modID, false ); stackSwitch = 0; updateScreen(); - modIDStacks.get(filter).stackIndex = -1; + modIDStacks.get( filter ).stackIndex = -1; } public static class StackData { - public List iterStacks; - public int stackIndex; - public ItemStack renderStack; + public List< ItemStack > iterStacks; + public int stackIndex; + public ItemStack renderStack; + } + + /** + * returns true if there are more filters than can fit in the gui + */ + private boolean needsScrollBars() + { + return tileEntity.filters.size() > 4; } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/HashList.java b/src/main/java/mekanism/common/HashList.java index 3c100f242..6d9305850 100644 --- a/src/main/java/mekanism/common/HashList.java +++ b/src/main/java/mekanism/common/HashList.java @@ -3,6 +3,8 @@ package mekanism.common; import java.util.ArrayList; import java.util.Iterator; +import mekanism.common.content.transporter.TransporterFilter; + public class HashList implements Iterable { private ArrayList list = new ArrayList(256); @@ -90,6 +92,19 @@ public class HashList implements Iterable { return list.size(); } + + public void swap( int source, int target ) + { + // Make sure both source and target ar legal values + if( source == target ) return; + if( source < 0 || target < 0 ) return; + if( source >= list.size() || target >= list.size() ) return; + + // Perform swap + T temp = list.get( source ); + list.set( source, list.get( target ) ); + list.set( target, temp ); + } @Override public int hashCode() diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index 62d6618c6..750469e16 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -741,6 +741,20 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I { inverse = !inverse; } + else if(type == 11) + { + // Move filter up + int filterIndex = dataStream.readInt(); + filters.swap( filterIndex, filterIndex - 1 ); + openInventory(); + } + else if(type == 12) + { + // Move filter down + int filterIndex = dataStream.readInt(); + filters.swap( filterIndex, filterIndex + 1 ); + openInventory(); + } MekanismUtils.saveChunk(this); diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index ce1677d40..43b5d0aed 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -3,6 +3,8 @@ package mekanism.common.tile; import java.util.ArrayList; import java.util.EnumSet; +import com.sun.media.jfxmedia.logging.Logger; + import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IFilterAccess; @@ -23,7 +25,6 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.InventoryUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.TransporterUtils; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.IInventory; @@ -33,7 +34,6 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.ForgeDirection; - import io.netty.buffer.ByteBuf; public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, IFilterAccess, ISustainedData @@ -292,7 +292,20 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen roundRobin = !roundRobin; rrIndex = 0; } - + else if(type == 3) + { + // Move filter up + int filterIndex = dataStream.readInt(); + filters.swap( filterIndex, filterIndex - 1 ); + openInventory(); + } + else if(type == 4) + { + // Move filter down + int filterIndex = dataStream.readInt(); + filters.swap( filterIndex, filterIndex + 1 ); + openInventory(); + } return; } @@ -461,7 +474,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen return stack; } - + @Override public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { diff --git a/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png b/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png index bc6c516fe..eadb5f8f1 100644 Binary files a/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png and b/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.png differ diff --git a/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.xcf b/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.xcf new file mode 100644 index 000000000..003e71d63 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/GuiDigitalMinerConfig.xcf differ diff --git a/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.png b/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.png index 219c0385e..229a91541 100644 Binary files a/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.png and b/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.png differ diff --git a/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.xcf b/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.xcf new file mode 100644 index 000000000..9ec61c0a4 Binary files /dev/null and b/src/main/resources/assets/mekanism/gui/GuiLogisticalSorter.xcf differ diff --git a/src/main/resources/assets/mekanism/lang/en_US.lang b/src/main/resources/assets/mekanism/lang/en_US.lang index dcef55e0a..a1f4bee47 100644 --- a/src/main/resources/assets/mekanism/lang/en_US.lang +++ b/src/main/resources/assets/mekanism/lang/en_US.lang @@ -477,6 +477,8 @@ gui.toggleCooling=Toggle Cooling Measurements gui.coolingMeasurements=Active cooling gui.redstoneOutputMode=Redstone mode gui.entityDetection=Entity Detection +gui.moveUp=Move Up +gui.moveDown=Move Down gui.reactor.injectionRate=Injection Rate