From 52f352bf9424317b15af1a591c2af27bd9609329 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 30 Mar 2019 10:16:48 -0400 Subject: [PATCH] Fixed nondeterministic drill item sorting --- core/src/io/anuke/mindustry/content/Items.java | 8 ++++---- .../mindustry/world/blocks/production/Drill.java | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/core/src/io/anuke/mindustry/content/Items.java b/core/src/io/anuke/mindustry/content/Items.java index e1500f5706..6a7249a936 100644 --- a/core/src/io/anuke/mindustry/content/Items.java +++ b/core/src/io/anuke/mindustry/content/Items.java @@ -34,6 +34,10 @@ public class Items implements ContentList{ cost = 1f; }}; + sand = new Item("sand", Color.valueOf("f7cba4")){{ + + }}; + coal = new Item("coal", Color.valueOf("272727")){{ explosiveness = 0.4f; flammability = 1f; @@ -84,10 +88,6 @@ public class Items implements ContentList{ flammability = 1.05f; }}; - sand = new Item("sand", Color.valueOf("f7cba4")){{ - - }}; - blastCompound = new Item("blast-compound", Color.valueOf("ff795e")){{ flammability = 0.4f; explosiveness = 1.2f; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java index 7b4713aeb7..2c55e6e9ce 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -3,17 +3,17 @@ package io.anuke.mindustry.world.blocks.production; import io.anuke.arc.Core; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectIntMap; -import io.anuke.arc.util.Strings; -import io.anuke.mindustry.entities.Effects; -import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; +import io.anuke.arc.util.Strings; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.content.Liquids; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.Effects.Effect; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Pal; @@ -182,8 +182,13 @@ public class Drill extends Block{ itemArray.add(item); } - itemArray.sort((item1, item2) -> Integer.compare(oreCount.get(item1, 0), oreCount.get(item2, 0))); - itemArray.sort((item1, item2) -> Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material)); + itemArray.sort((item1, item2) -> { + int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material); + if(type != 0) return type; + int count = Integer.compare(oreCount.get(item1, 0), oreCount.get(item2, 0)); + if(count != 0) return count; + return Integer.compare(item1.id, item2.id); + }); if(itemArray.size == 0){ return;