Actually sync ItemTurret's ammo (#5154)

This commit is contained in:
Leonid Skorospelov
2021-04-25 16:06:45 +03:00
committed by GitHub
parent 8cd7e1c307
commit 6eea8bebdf

View File

@@ -165,14 +165,16 @@ public class ItemTurret extends Turret{
@Override
public void read(Reads read, byte revision){
super.read(read, revision);
ammo.clear();
totalAmmo = 0;
int amount = read.ub();
for(int i = 0; i < amount; i++){
Item item = Vars.content.item(revision < 2 ? read.ub() : read.s());
short a = read.s();
totalAmmo += a;
//only add ammo if this is a valid ammo type
if(item != null && ammoTypes.containsKey(item)){
totalAmmo += a;
ammo.add(new ItemEntry(item, a));
}
}