use of io.anuke.mindustry.resource.Item in project Mindustry by Anuken.
the class Junction method update.
@Override
public void update(Tile tile) {
JunctionEntity entity = tile.entity();
for (int i = 0; i < 2; i++) {
Buffer buffer = (i == 0 ? entity.bx : entity.by);
if (buffer.index > 0) {
if (buffer.index > buffer.items.length)
buffer.index = buffer.items.length;
long l = buffer.items[0];
float time = NumberUtils.intBitsToFloat(Bits.getLeftInt(l));
if (Timers.time() >= time + speed || Timers.time() < time) {
int val = Bits.getRightInt(l);
Item item = Item.getByID(Bits.getLeftShort(val));
int direction = Bits.getRightShort(val);
Tile dest = tile.getNearby(direction);
if (dest == null || !dest.block().acceptItem(item, dest, tile))
continue;
dest.block().handleItem(item, dest, tile);
System.arraycopy(buffer.items, 1, buffer.items, 0, buffer.index - 1);
buffer.index--;
}
}
}
}
Aggregations