From 2683c748005df91ec4c30b56d0918411eeab13f2 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Tue, 28 Jan 2020 11:10:23 +0100 Subject: [PATCH] Avoid assigning new object? --- core/src/mindustry/world/modules/ItemModule.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/world/modules/ItemModule.java b/core/src/mindustry/world/modules/ItemModule.java index 127edeccac..3fe28f90a9 100644 --- a/core/src/mindustry/world/modules/ItemModule.java +++ b/core/src/mindustry/world/modules/ItemModule.java @@ -74,14 +74,13 @@ public class ItemModule extends BlockModule{ } public Item take(){ - Item took = first(); + if(first() == null) return null; - if(took != null){ - items[first().id]--; - total--; - } + int id = first().id; + items[id]--; + total--; - return took; + return content.item(id); } public int get(Item item){