From fc571750563b70b070b6f8e00a8b641c5f9c476a Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 22 Jan 2018 14:43:34 -0500 Subject: [PATCH] Fixed negative item bug --- core/src/io/anuke/mindustry/core/Control.java | 1 + core/src/io/anuke/mindustry/core/NetServer.java | 6 +----- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index 20fa81eba7..e6e4979f77 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -514,6 +514,7 @@ public class Control extends Module{ public void removeItem(ItemStack req){ items[req.item.id] -= req.amount; + if(items[req.item.id] < 0) items[req.item.id] = 0; //prevents negative item glitches in multiplayer shouldUpdateItems = true; } diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 80d088db1a..ba038a08a0 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -123,11 +123,7 @@ public class NetServer extends Module{ packet.playerid = connections.get(id).id; Recipe recipe = Recipes.getByResult(Block.getByID(packet.block)); - if (recipe != null) { - for (ItemStack stack : recipe.requirements) { - Vars.control.removeItem(stack); - } - } + if (recipe != null) Vars.control.removeItems(recipe.requirements); Net.sendExcept(id, packet, SendMode.tcp); });