From 989034c7996732b7b38407af2172132d0363a3a1 Mon Sep 17 00:00:00 2001 From: Skybbles // L5474 Date: Mon, 3 Dec 2018 12:46:31 -0500 Subject: [PATCH] Made Unloader have the same "memory" as the sorter (#366) I implemented the same 'memory' feature as the sorter's, introduced in b62. It's sort of under the 'sorter' category in terms of features, so I thought it would be logical to do so. --- .../world/blocks/storage/SortedUnloader.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java index 222efc9c4b..a0e1545255 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/SortedUnloader.java @@ -17,15 +17,22 @@ import java.io.DataOutput; import java.io.IOException; import static io.anuke.mindustry.Vars.content; +import static io.anuke.mindustry.Vars.threads; public class SortedUnloader extends Unloader implements SelectionTrait{ protected float speed = 1f; + private static Item lastItem; public SortedUnloader(String name){ super(name); configurable = true; } + @Override + public void playerPlaced(Tile tile){ + threads.runDelay(() -> Call.setSortedUnloaderItem(null, tile, lastItem)); + } + @Remote(targets = Loc.both, called = Loc.both, forward = true) public static void setSortedUnloaderItem(Player player, Tile tile, Item item){ SortedUnloaderEntity entity = tile.entity(); @@ -65,7 +72,10 @@ public class SortedUnloader extends Unloader implements SelectionTrait{ @Override public void buildTable(Tile tile, Table table){ SortedUnloaderEntity entity = tile.entity(); - buildItemTable(table, () -> entity.sortItem, item -> Call.setSortedUnloaderItem(null, tile, item)); + buildItemTable(table, () -> entity.sortItem, item -> { + lastItem = item; + Call.setSortedUnloaderItem(null, tile, item); + }); } @Override