Completely borked liquid/power/inventory system
This commit is contained in:
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -128,29 +127,6 @@ public class NetEvents {
|
||||
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);
|
||||
}
|
||||
|
||||
public static void handleItemSet(Tile tile, Item item, byte amount){
|
||||
ItemSetPacket packet = new ItemSetPacket();
|
||||
packet.position = tile.packedPosition();
|
||||
packet.itemid = (byte)item.id;
|
||||
packet.amount = amount;
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
|
||||
public static void handleOffload(Tile tile, Item item){
|
||||
ItemOffloadPacket packet = new ItemOffloadPacket();
|
||||
packet.position = tile.packedPosition();
|
||||
packet.itemid = (byte)item.id;
|
||||
Net.send(packet, SendMode.udp);
|
||||
}
|
||||
|
||||
public static void handleAdminSet(Player player, boolean admin){
|
||||
PlayerAdminPacket packet = new PlayerAdminPacket();
|
||||
packet.admin = admin;
|
||||
|
||||
@@ -191,10 +191,9 @@ public class NetworkIO {
|
||||
stream.writeByte(tile.getExtra());
|
||||
stream.writeShort((short)tile.entity.health); //health
|
||||
|
||||
//items
|
||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||
stream.writeInt(tile.entity.items[i]);
|
||||
}
|
||||
if(tile.entity.inventory != null) tile.entity.inventory.write(stream);
|
||||
if(tile.entity.power != null) tile.entity.power.write(stream);
|
||||
if(tile.entity.liquid != null) tile.entity.liquid.write(stream);
|
||||
|
||||
//timer data
|
||||
|
||||
@@ -326,9 +325,9 @@ public class NetworkIO {
|
||||
|
||||
tile.entity.health = health;
|
||||
|
||||
for(int j = 0; j < tile.entity.items.length; j ++){
|
||||
tile.entity.items[j] = stream.readInt();
|
||||
}
|
||||
if(tile.entity.inventory != null) tile.entity.inventory.read(stream);
|
||||
if(tile.entity.power != null) tile.entity.power.read(stream);
|
||||
if(tile.entity.liquid != null) tile.entity.liquid.read(stream);
|
||||
|
||||
byte timers = stream.readByte();
|
||||
for(int time = 0; time < timers; time ++){
|
||||
|
||||
@@ -504,62 +504,6 @@ public class Packets {
|
||||
public void read(ByteBuffer buffer) { }
|
||||
}
|
||||
|
||||
public static class ItemTransferPacket implements Packet, UnimportantPacket{
|
||||
public int position;
|
||||
public byte rotation;
|
||||
public byte itemid;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.putInt((rotation) | (position << 2));
|
||||
buffer.put(itemid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
int i = buffer.getInt();
|
||||
rotation = (byte)(i & 0x3);
|
||||
position = i >> 2;
|
||||
itemid = buffer.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemSetPacket implements Packet, UnimportantPacket{
|
||||
public int position;
|
||||
public byte itemid, amount;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.putInt(position);
|
||||
buffer.put(itemid);
|
||||
buffer.put(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
position = buffer.getInt();
|
||||
itemid = buffer.get();
|
||||
amount = buffer.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemOffloadPacket 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();
|
||||
}
|
||||
}
|
||||
|
||||
public static class NetErrorPacket implements Packet{
|
||||
public String message;
|
||||
|
||||
|
||||
@@ -38,9 +38,6 @@ public class Registrator {
|
||||
CustomMapPacket.class,
|
||||
MapAckPacket.class,
|
||||
EntitySpawnPacket.class,
|
||||
ItemTransferPacket.class,
|
||||
ItemSetPacket.class,
|
||||
ItemOffloadPacket.class,
|
||||
NetErrorPacket.class,
|
||||
PlayerAdminPacket.class,
|
||||
AdministerRequestPacket.class,
|
||||
|
||||
Reference in New Issue
Block a user