From 9897e200a881fb3de1601b4430ea2909e7ab3929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Skrz=C4=99tnicki?= Date: Tue, 2 Jan 2018 23:19:27 +0100 Subject: [PATCH 1/2] Implement outbound queue limits. Fixes infinite status bar issue. Lowered timer to 5 to make it drain more quickly - makes sense given the production is instant. --- .../world/blocks/types/production/Crafter.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java index d18a6947fa..f53c6529f9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java @@ -37,7 +37,7 @@ public class Crafter extends Block{ @Override public void update(Tile tile){ - if(tile.entity.timer.get(timerDump, 15) && tile.entity.hasItem(result)){ + if(tile.entity.timer.get(timerDump, 5) && tile.entity.hasItem(result)){ tryDump(tile, -1, result); } @@ -46,7 +46,13 @@ public class Crafter extends Block{ return; } } - + + // crafter full - it has to be emptied before it can craft again. + if(tile.entity.getItem(result) >= capacity) + { + return; + } + for(Item item : requirements){ tile.entity.removeItem(item, 1); } @@ -67,8 +73,10 @@ public class Crafter extends Block{ @Override public void drawSelect(Tile tile){ - float fract = (float)tile.entity.totalItems()/((requirements.length-1) *capacity); - + // each req item has its input buffer + 1 buffer for output. + int totalCapacity = (requirements.length + 1) * capacity; + float fract = ((float)tile.entity.totalItems())/totalCapacity; + Vars.renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 6, fract); } } From eed70fe63c05ed6a121476147f5ba55e8ca0a2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Skrz=C4=99tnicki?= Date: Tue, 2 Jan 2018 23:38:45 +0100 Subject: [PATCH 2/2] formatting --- .../mindustry/world/blocks/types/production/Crafter.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java index f53c6529f9..368d6df053 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Crafter.java @@ -18,7 +18,7 @@ public class Crafter extends Block{ protected Item[] requirements; protected Item result; - int capacity = 20; + int capacity = 20; public Crafter(String name) { super(name); @@ -48,8 +48,7 @@ public class Crafter extends Block{ } // crafter full - it has to be emptied before it can craft again. - if(tile.entity.getItem(result) >= capacity) - { + if(tile.entity.getItem(result) >= capacity){ return; }