Implemented ammo ressuplying

This commit is contained in:
Anuken
2018-04-24 21:38:57 -04:00
parent 8581213126
commit deefab8a5b
25 changed files with 259 additions and 114 deletions

View File

@@ -63,8 +63,7 @@ public class NetEvents {
public static void handleWeaponSwitch(){
WeaponSwitchPacket packet = new WeaponSwitchPacket();
packet.left = Vars.player.weaponLeft.id;
packet.right = Vars.player.weaponRight.id;
packet.weapon = Vars.player.weapon.id;
packet.playerid = Vars.player.id;
Net.send(packet, SendMode.tcp);
}

View File

@@ -123,7 +123,7 @@ public class NetworkIO {
control.upgrades().getWeapons().add(Upgrade.getByID(stream.readByte()));
}
player.weaponLeft = player.weaponRight = control.upgrades().getWeapons().peek();
player.weapon = control.upgrades().getWeapons().peek();
Entities.clear();
player.id = pid;

View File

@@ -376,20 +376,18 @@ public class Packets {
public static class WeaponSwitchPacket implements Packet{
public int playerid;
public byte left, right;
public byte weapon;
@Override
public void write(ByteBuffer buffer) {
buffer.putInt(playerid);
buffer.put(left);
buffer.put(right);
buffer.put(weapon);
}
@Override
public void read(ByteBuffer buffer) {
playerid = buffer.getInt();
left = buffer.get();
right = buffer.get();
weapon = buffer.get();
}
}