Experimental new block sync system
This commit is contained in:
@@ -6,12 +6,14 @@ import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.net.Net.SendMode;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.netCommon;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class NetEvents {
|
||||
|
||||
@@ -127,4 +129,12 @@ public class NetEvents {
|
||||
packet.y = (short)y;
|
||||
Net.send(packet, SendMode.tcp);
|
||||
}
|
||||
|
||||
public static void handleTransfer(Tile tile, byte rotation, Item item){
|
||||
ItemTransferPacket packet = new ItemTransferPacket();
|
||||
packet.position = tile.packedPosition();
|
||||
packet.rotation = rotation;
|
||||
packet.itemid = (byte)item.id;
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,4 +500,24 @@ public class Packets {
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) { }
|
||||
}
|
||||
|
||||
public static class ItemTransferPacket implements Packet{
|
||||
public int position;
|
||||
public byte rotation;
|
||||
public byte itemid;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.putInt(position);
|
||||
buffer.put(rotation);
|
||||
buffer.put(itemid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
position = buffer.getInt();
|
||||
rotation = buffer.get();
|
||||
itemid = buffer.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class Registrator {
|
||||
CustomMapPacket.class,
|
||||
MapAckPacket.class,
|
||||
EntitySpawnPacket.class,
|
||||
ItemTransferPacket.class
|
||||
};
|
||||
private static ObjectIntMap<Class<?>> ids = new ObjectIntMap<>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user