Experimental sync changes

This commit is contained in:
Anuken
2018-02-12 18:10:14 -05:00
parent 86a4ff971c
commit 4d54e5c0e1
10 changed files with 62 additions and 10 deletions

View File

@@ -137,4 +137,11 @@ public class NetEvents {
packet.itemid = (byte)item.id;
Net.send(packet, SendMode.udp);
}
public static void handleItemAdd(Tile tile, Item item){
ItemAddPacket packet = new ItemAddPacket();
packet.position = tile.packedPosition();
packet.itemid = (byte)item.id;
Net.send(packet, SendMode.udp);
}
}

View File

@@ -522,4 +522,21 @@ public class Packets {
itemid = buffer.get();
}
}
public static class ItemAddPacket implements Packet{
public int position;
public byte itemid;
@Override
public void write(ByteBuffer buffer) {
buffer.putInt(position);
buffer.put(itemid);
}
@Override
public void read(ByteBuffer buffer) {
position = buffer.getInt();
itemid = buffer.get();
}
}
}

View File

@@ -38,7 +38,8 @@ public class Registrator {
CustomMapPacket.class,
MapAckPacket.class,
EntitySpawnPacket.class,
ItemTransferPacket.class
ItemTransferPacket.class,
ItemAddPacket.class,
};
private static ObjectIntMap<Class<?>> ids = new ObjectIntMap<>();