Fixed #1601
This commit is contained in:
@@ -9,6 +9,8 @@ import mindustry.world.meta.BlockGroup;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
import static mindustry.Vars.world;
|
||||||
|
|
||||||
public class OverflowGate extends Block{
|
public class OverflowGate extends Block{
|
||||||
public float speed = 1f;
|
public float speed = 1f;
|
||||||
public boolean invert = false;
|
public boolean invert = false;
|
||||||
@@ -125,19 +127,24 @@ public class OverflowGate extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte version(){
|
public byte version(){
|
||||||
return 2;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutput stream) throws IOException{
|
public void write(DataOutput stream) throws IOException{
|
||||||
super.write(stream);
|
super.write(stream);
|
||||||
|
stream.writeInt(lastInput == null ? Pos.invalid : lastInput.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(DataInput stream, byte revision) throws IOException{
|
public void read(DataInput stream, byte revision) throws IOException{
|
||||||
super.read(stream, revision);
|
super.read(stream, revision);
|
||||||
|
|
||||||
if(revision == 1){
|
if(revision == 1){
|
||||||
new DirectionalItemBuffer(25, 50f).read(stream);
|
new DirectionalItemBuffer(25, 50f).read(stream);
|
||||||
|
}else if(revision == 3){
|
||||||
|
lastInput = world.tile(stream.readInt());
|
||||||
|
lastItem = items.first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package mindustry.world.modules;
|
package mindustry.world.modules;
|
||||||
|
|
||||||
import mindustry.type.Item;
|
import mindustry.type.*;
|
||||||
import mindustry.type.ItemStack;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
|
|
||||||
import static mindustry.Vars.content;
|
import static mindustry.Vars.content;
|
||||||
|
|
||||||
@@ -69,15 +68,24 @@ public class ItemModule extends BlockModule{
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item first(){
|
||||||
|
for(int i = 0; i < items.length; i++){
|
||||||
|
if(items[i] > 0){
|
||||||
|
return content.item(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Item take(){
|
public Item take(){
|
||||||
for(int i = 0; i < items.length; i++){
|
for(int i = 0; i < items.length; i++){
|
||||||
int index = (i + takeRotation);
|
int index = (i + takeRotation);
|
||||||
if(index >= items.length) index -= items.length; //conditional instead of mod
|
if(index >= items.length) index -= items.length;
|
||||||
if(items[index] > 0){
|
if(items[index] > 0){
|
||||||
items[index] --;
|
items[index] --;
|
||||||
total --;
|
total --;
|
||||||
takeRotation = index + 1;
|
takeRotation = index + 1;
|
||||||
return content.item(index % items.length);
|
return content.item(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=f1178ca09b4d0b29e23f6443e73f8daf4a4b7329
|
archash=0b2f044e5955ff700650eebecfb3dfcb629d7a8b
|
||||||
|
|||||||
Reference in New Issue
Block a user