Fixed negative item bug
This commit is contained in:
@@ -514,6 +514,7 @@ public class Control extends Module{
|
|||||||
|
|
||||||
public void removeItem(ItemStack req){
|
public void removeItem(ItemStack req){
|
||||||
items[req.item.id] -= req.amount;
|
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;
|
shouldUpdateItems = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,11 +123,7 @@ public class NetServer extends Module{
|
|||||||
packet.playerid = connections.get(id).id;
|
packet.playerid = connections.get(id).id;
|
||||||
|
|
||||||
Recipe recipe = Recipes.getByResult(Block.getByID(packet.block));
|
Recipe recipe = Recipes.getByResult(Block.getByID(packet.block));
|
||||||
if (recipe != null) {
|
if (recipe != null) Vars.control.removeItems(recipe.requirements);
|
||||||
for (ItemStack stack : recipe.requirements) {
|
|
||||||
Vars.control.removeItem(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Net.sendExcept(id, packet, SendMode.tcp);
|
Net.sendExcept(id, packet, SendMode.tcp);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user