mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Port 32b040353 and keep track of active modes via uuid's instead of names (#5348)
This commit is contained in:
1 parent
610d65f522
commit
5a2a902366
11 files changed
+109
-96
No files matched your search
@@ -12,6 +12,6 @@ public class ClientPlayerTracker {
|
||||
@SubscribeEvent
|
||||
public void onPlayerChangedDimension(PlayerChangedDimensionEvent event) {
|
||||
Mekanism.playerState.clearPlayer(event.player);
|
||||
Mekanism.freeRunnerOn.remove(event.player.getName());
|
||||
Mekanism.freeRunnerOn.remove(event.player.getUniqueID());
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class ClientTickHandler {
|
||||
|
||||
public static boolean isFreeRunnerOn(EntityPlayer player) {
|
||||
if (player != mc.player) {
|
||||
return Mekanism.freeRunnerOn.contains(player.getName());
|
||||
return Mekanism.freeRunnerOn.contains(player.getUniqueID());
|
||||
}
|
||||
|
||||
ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
@@ -129,8 +129,7 @@ public class ClientTickHandler {
|
||||
ItemFreeRunners freeRunners = (ItemFreeRunners) stack.getItem();
|
||||
|
||||
/*freeRunners.getEnergy(stack) > 0 && */
|
||||
return freeRunners.getMode(stack)
|
||||
== ItemFreeRunners.FreeRunnerMode.NORMAL;
|
||||
return freeRunners.getMode(stack) == ItemFreeRunners.FreeRunnerMode.NORMAL;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -204,16 +203,16 @@ public class ClientTickHandler {
|
||||
initHoliday = true;
|
||||
}
|
||||
|
||||
if (Mekanism.freeRunnerOn.contains(mc.player.getName()) != isFreeRunnerOn(mc.player)) {
|
||||
if (Mekanism.freeRunnerOn.contains(mc.player.getUniqueID()) != isFreeRunnerOn(mc.player)) {
|
||||
if (isFreeRunnerOn(mc.player) && mc.currentScreen == null) {
|
||||
Mekanism.freeRunnerOn.add(mc.player.getName());
|
||||
Mekanism.freeRunnerOn.add(mc.player.getUniqueID());
|
||||
} else {
|
||||
Mekanism.freeRunnerOn.remove(mc.player.getName());
|
||||
Mekanism.freeRunnerOn.remove(mc.player.getUniqueID());
|
||||
}
|
||||
|
||||
Mekanism.packetHandler.sendToServer(
|
||||
new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.UPDATE,
|
||||
mc.player.getName(), isFreeRunnerOn(mc.player)));
|
||||
mc.player.getUniqueID(), isFreeRunnerOn(mc.player)));
|
||||
}
|
||||
|
||||
ItemStack bootStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
@@ -228,9 +227,9 @@ public class ClientTickHandler {
|
||||
|
||||
// Update player's state for various items; this also automatically notifies server if something changed and
|
||||
// kicks off sounds as necessary
|
||||
Mekanism.playerState.setJetpackState(mc.player.getName(), isJetpackActive(mc.player), true);
|
||||
Mekanism.playerState.setGasmaskState(mc.player.getName(), isGasMaskOn(mc.player), true);
|
||||
Mekanism.playerState.setFlamethrowerState(mc.player.getName(), isFlamethrowerOn(mc.player), true);
|
||||
Mekanism.playerState.setJetpackState(mc.player.getUniqueID(), isJetpackActive(mc.player), true);
|
||||
Mekanism.playerState.setGasmaskState(mc.player.getUniqueID(), isGasMaskOn(mc.player), true);
|
||||
Mekanism.playerState.setFlamethrowerState(mc.player.getUniqueID(), isFlamethrowerOn(mc.player), true);
|
||||
|
||||
for (Iterator<Entry<EntityPlayer, TeleportData>> iter = portableTeleports.entrySet().iterator();
|
||||
iter.hasNext(); ) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mekanism.client.render;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismAPI;
|
||||
@@ -121,8 +122,8 @@ public class RenderTickHandler {
|
||||
|
||||
// Traverse a copy of jetpack state and do animations
|
||||
// TODO: This means we're making a full copy of the state per render....might need to revisit
|
||||
for (String s : Mekanism.playerState.getActiveJetpacks()) {
|
||||
EntityPlayer p = mc.world.getPlayerEntityByName(s);
|
||||
for (UUID uuid : Mekanism.playerState.getActiveJetpacks()) {
|
||||
EntityPlayer p = mc.world.getPlayerEntityByUUID(uuid);
|
||||
|
||||
if (p == null) {
|
||||
continue;
|
||||
@@ -168,8 +169,8 @@ public class RenderTickHandler {
|
||||
// Traverse a copy of gasmask state and do animations
|
||||
// TODO: This means we're making a full copy of the state per render....might need to revisit
|
||||
if (world.getWorldTime() % 4 == 0) {
|
||||
for (String s : Mekanism.playerState.getActiveGasmasks()) {
|
||||
EntityPlayer p = mc.world.getPlayerEntityByName(s);
|
||||
for (UUID uuid : Mekanism.playerState.getActiveGasmasks()) {
|
||||
EntityPlayer p = mc.world.getPlayerEntityByUUID(uuid);
|
||||
|
||||
if (p == null || !p.isInWater()) {
|
||||
continue;
|
||||
|
||||
@@ -43,13 +43,13 @@ public class CommonPlayerTracker {
|
||||
@SubscribeEvent
|
||||
public void onPlayerLogoutEvent(PlayerLoggedOutEvent event) {
|
||||
Mekanism.playerState.clearPlayer(event.player);
|
||||
Mekanism.freeRunnerOn.remove(event.player.getName());
|
||||
Mekanism.freeRunnerOn.remove(event.player.getUniqueID());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPlayerDimChangedEvent(PlayerChangedDimensionEvent event) {
|
||||
Mekanism.playerState.clearPlayer(event.player);
|
||||
Mekanism.freeRunnerOn.remove(event.player.getName());
|
||||
Mekanism.freeRunnerOn.remove(event.player.getUniqueID());
|
||||
|
||||
if (!event.player.world.isRemote) {
|
||||
Mekanism.packetHandler.sendTo(JetpackDataMessage.FULL(Mekanism.playerState.getActiveJetpacks()),
|
||||
|
||||
@@ -199,7 +199,7 @@ public class Mekanism {
|
||||
public static final String MOD_NAME = "Mekanism";
|
||||
public static final String LOG_TAG = '[' + MOD_NAME + ']';
|
||||
public static final PlayerState playerState = new PlayerState();
|
||||
public static final Set<String> freeRunnerOn = new HashSet<>();
|
||||
public static final Set<UUID> freeRunnerOn = new HashSet<>();
|
||||
/**
|
||||
* Mekanism Packet Pipeline
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@ package mekanism.common;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.network.PacketBoxBlacklist;
|
||||
@@ -313,4 +315,14 @@ public class PacketHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static UUID readUUID(ByteBuf dataStream) {
|
||||
return new UUID(dataStream.readLong(), dataStream.readLong());
|
||||
}
|
||||
|
||||
public static void writeUUID(ByteBuf dataStream, UUID uuid) {
|
||||
dataStream.writeLong(uuid.getMostSignificantBits());
|
||||
dataStream.writeLong(uuid.getLeastSignificantBits());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package mekanism.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.network.PacketFlamethrowerData.FlamethrowerDataMessage;
|
||||
@@ -13,9 +14,9 @@ import net.minecraft.world.World;
|
||||
|
||||
public class PlayerState {
|
||||
|
||||
private Set<String> activeJetpacks = new HashSet<>();
|
||||
private Set<String> activeGasmasks = new HashSet<>();
|
||||
private Set<String> activeFlamethrowers = new HashSet<>();
|
||||
private Set<UUID> activeJetpacks = new HashSet<>();
|
||||
private Set<UUID> activeGasmasks = new HashSet<>();
|
||||
private Set<UUID> activeFlamethrowers = new HashSet<>();
|
||||
|
||||
private World world;
|
||||
|
||||
@@ -26,9 +27,9 @@ public class PlayerState {
|
||||
}
|
||||
|
||||
public void clearPlayer(EntityPlayer p) {
|
||||
activeJetpacks.remove(p.getName());
|
||||
activeGasmasks.remove(p.getName());
|
||||
activeFlamethrowers.remove(p.getName());
|
||||
activeJetpacks.remove(p.getUniqueID());
|
||||
activeGasmasks.remove(p.getUniqueID());
|
||||
activeFlamethrowers.remove(p.getUniqueID());
|
||||
}
|
||||
|
||||
public void init(World world) {
|
||||
@@ -41,28 +42,28 @@ public class PlayerState {
|
||||
//
|
||||
// ----------------------
|
||||
|
||||
public void setJetpackState(String playerId, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeJetpacks.contains(playerId);
|
||||
public void setJetpackState(UUID uuid, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeJetpacks.contains(uuid);
|
||||
boolean changed = (alreadyActive != isActive);
|
||||
|
||||
if (alreadyActive && !isActive) {
|
||||
// On -> off
|
||||
activeJetpacks.remove(playerId);
|
||||
activeJetpacks.remove(uuid);
|
||||
} else if (!alreadyActive && isActive) {
|
||||
// Off -> on
|
||||
activeJetpacks.add(playerId);
|
||||
activeJetpacks.add(uuid);
|
||||
}
|
||||
|
||||
// If something changed and we're in a remote world, take appropriate action
|
||||
if (changed && world.isRemote) {
|
||||
// If the player is the "local" player, we need to tell the server the state has changed
|
||||
if (isLocal) {
|
||||
Mekanism.packetHandler.sendToServer(PacketJetpackData.JetpackDataMessage.UPDATE(playerId, isActive));
|
||||
Mekanism.packetHandler.sendToServer(PacketJetpackData.JetpackDataMessage.UPDATE(uuid, isActive));
|
||||
}
|
||||
|
||||
// Start a sound playing if the person is now flying
|
||||
if (isActive && MekanismConfig.client.enablePlayerSounds) {
|
||||
SoundHandler.startSound(world.getPlayerEntityByName(playerId), "jetpack");
|
||||
SoundHandler.startSound(world.getPlayerEntityByUUID(uuid), "jetpack");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,12 +72,12 @@ public class PlayerState {
|
||||
return activeJetpacks.contains(p.getName());
|
||||
}
|
||||
|
||||
public Set<String> getActiveJetpacks() {
|
||||
public Set<UUID> getActiveJetpacks() {
|
||||
return activeJetpacks;
|
||||
}
|
||||
|
||||
public void setActiveJetpacks(Set<String> newActiveJetpacks) {
|
||||
for (String activeUser : newActiveJetpacks) {
|
||||
public void setActiveJetpacks(Set<UUID> newActiveJetpacks) {
|
||||
for (UUID activeUser : newActiveJetpacks) {
|
||||
setJetpackState(activeUser, true, false);
|
||||
}
|
||||
}
|
||||
@@ -87,14 +88,14 @@ public class PlayerState {
|
||||
//
|
||||
// ----------------------
|
||||
|
||||
public void setGasmaskState(String playerId, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeGasmasks.contains(playerId);
|
||||
public void setGasmaskState(UUID uuid, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeGasmasks.contains(uuid);
|
||||
boolean changed = (alreadyActive != isActive);
|
||||
|
||||
if (alreadyActive && !isActive) {
|
||||
activeGasmasks.remove(playerId); // On -> off
|
||||
activeGasmasks.remove(uuid); // On -> off
|
||||
} else if (!alreadyActive && isActive) {
|
||||
activeGasmasks.add(playerId); // Off -> on
|
||||
activeGasmasks.add(uuid); // Off -> on
|
||||
}
|
||||
|
||||
// If something changed and we're in a remote world, take appropriate action
|
||||
@@ -102,26 +103,26 @@ public class PlayerState {
|
||||
// If the player is the "local" player, we need to tell the server the state has changed
|
||||
if (isLocal) {
|
||||
Mekanism.packetHandler
|
||||
.sendToServer(PacketScubaTankData.ScubaTankDataMessage.UPDATE(playerId, isActive));
|
||||
.sendToServer(PacketScubaTankData.ScubaTankDataMessage.UPDATE(uuid, isActive));
|
||||
}
|
||||
|
||||
// Start a sound playing if the person is now using a gasmask
|
||||
if (isActive && MekanismConfig.client.enablePlayerSounds) {
|
||||
SoundHandler.startSound(world.getPlayerEntityByName(playerId), "gasmask");
|
||||
SoundHandler.startSound(world.getPlayerEntityByUUID(uuid), "gasmask");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isGasmaskOn(EntityPlayer p) {
|
||||
return activeGasmasks.contains(p.getName());
|
||||
return activeGasmasks.contains(p.getUniqueID());
|
||||
}
|
||||
|
||||
public Set<String> getActiveGasmasks() {
|
||||
public Set<UUID> getActiveGasmasks() {
|
||||
return activeGasmasks;
|
||||
}
|
||||
|
||||
public void setActiveGasmasks(Set<String> newActiveGasmasks) {
|
||||
for (String activeUser : newActiveGasmasks) {
|
||||
public void setActiveGasmasks(Set<UUID> newActiveGasmasks) {
|
||||
for (UUID activeUser : newActiveGasmasks) {
|
||||
setGasmaskState(activeUser, true, false);
|
||||
}
|
||||
}
|
||||
@@ -132,14 +133,14 @@ public class PlayerState {
|
||||
//
|
||||
// ----------------------
|
||||
|
||||
public void setFlamethrowerState(String playerId, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeFlamethrowers.contains(playerId);
|
||||
public void setFlamethrowerState(UUID uuid, boolean isActive, boolean isLocal) {
|
||||
boolean alreadyActive = activeFlamethrowers.contains(uuid);
|
||||
boolean changed = (alreadyActive != isActive);
|
||||
|
||||
if (alreadyActive && !isActive) {
|
||||
activeFlamethrowers.remove(playerId); // On -> off
|
||||
activeFlamethrowers.remove(uuid); // On -> off
|
||||
} else if (!alreadyActive && isActive) {
|
||||
activeFlamethrowers.add(playerId); // Off -> on
|
||||
activeFlamethrowers.add(uuid); // Off -> on
|
||||
}
|
||||
|
||||
// If something changed and we're in a remote world, take appropriate action
|
||||
@@ -147,18 +148,18 @@ public class PlayerState {
|
||||
// If the player is the "local" player, we need to tell the server the state has changed
|
||||
if (isLocal) {
|
||||
Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(FlamethrowerPacket.UPDATE, null,
|
||||
playerId, isActive));
|
||||
uuid, isActive));
|
||||
}
|
||||
|
||||
// Start a sound playing if the person is now using a flamethrower
|
||||
if (isActive && MekanismConfig.client.enablePlayerSounds) {
|
||||
SoundHandler.startSound(world.getPlayerEntityByName(playerId), "flamethrower");
|
||||
SoundHandler.startSound(world.getPlayerEntityByUUID(uuid), "flamethrower");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFlamethrowerOn(EntityPlayer p) {
|
||||
return activeFlamethrowers.contains(p.getName());
|
||||
return activeFlamethrowers.contains(p.getUniqueID());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemFlamethrower;
|
||||
@@ -18,10 +19,9 @@ public class PacketFlamethrowerData implements IMessageHandler<FlamethrowerDataM
|
||||
public IMessage onMessage(FlamethrowerDataMessage message, MessageContext context) {
|
||||
// Queue up the processing on the central thread
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
PacketHandler.handlePacket(
|
||||
() -> {
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.packetType == FlamethrowerPacket.UPDATE) {
|
||||
Mekanism.playerState.setFlamethrowerState(message.username, message.value, false);
|
||||
Mekanism.playerState.setFlamethrowerState(message.uuid, message.value, false);
|
||||
|
||||
// If we got this packet on the server, resend out to all clients in same dimension
|
||||
// TODO: Why is this a dimensional thing?!
|
||||
@@ -49,18 +49,17 @@ public class PacketFlamethrowerData implements IMessageHandler<FlamethrowerDataM
|
||||
public FlamethrowerPacket packetType;
|
||||
|
||||
public EnumHand currentHand;
|
||||
public String username;
|
||||
public UUID uuid;
|
||||
public boolean value;
|
||||
|
||||
public FlamethrowerDataMessage() {
|
||||
}
|
||||
|
||||
public FlamethrowerDataMessage(
|
||||
FlamethrowerPacket type, EnumHand hand, String name, boolean state) {
|
||||
public FlamethrowerDataMessage(FlamethrowerPacket type, EnumHand hand, UUID uuid, boolean state) {
|
||||
packetType = type;
|
||||
|
||||
if (type == FlamethrowerPacket.UPDATE) {
|
||||
username = name;
|
||||
this.uuid = uuid;
|
||||
value = state;
|
||||
} else if (type == FlamethrowerPacket.MODE) {
|
||||
currentHand = hand;
|
||||
@@ -72,7 +71,7 @@ public class PacketFlamethrowerData implements IMessageHandler<FlamethrowerDataM
|
||||
dataStream.writeInt(packetType.ordinal());
|
||||
|
||||
if (packetType == FlamethrowerPacket.UPDATE) {
|
||||
PacketHandler.writeString(dataStream, username);
|
||||
PacketHandler.writeUUID(dataStream, uuid);
|
||||
dataStream.writeBoolean(value);
|
||||
} else {
|
||||
dataStream.writeInt(currentHand.ordinal());
|
||||
@@ -84,7 +83,7 @@ public class PacketFlamethrowerData implements IMessageHandler<FlamethrowerDataM
|
||||
packetType = FlamethrowerPacket.values()[dataStream.readInt()];
|
||||
|
||||
if (packetType == FlamethrowerPacket.UPDATE) {
|
||||
username = PacketHandler.readString(dataStream);
|
||||
uuid = PacketHandler.readUUID(dataStream);
|
||||
value = dataStream.readBoolean();
|
||||
} else if (packetType == FlamethrowerPacket.MODE) {
|
||||
currentHand = EnumHand.values()[dataStream.readInt()];
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.UUID;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemFreeRunners;
|
||||
@@ -20,14 +21,14 @@ public class PacketFreeRunnerData implements IMessageHandler<PacketFreeRunnerDat
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.packetType == FreeRunnerPacket.UPDATE) {
|
||||
if (message.value) {
|
||||
Mekanism.freeRunnerOn.add(message.username);
|
||||
Mekanism.freeRunnerOn.add(message.uuid);
|
||||
} else {
|
||||
Mekanism.freeRunnerOn.remove(message.username);
|
||||
Mekanism.freeRunnerOn.remove(message.uuid);
|
||||
}
|
||||
|
||||
if (!entityPlayer.world.isRemote) {
|
||||
Mekanism.packetHandler.sendToDimension(
|
||||
new FreeRunnerDataMessage(FreeRunnerPacket.UPDATE, message.username, message.value),
|
||||
new FreeRunnerDataMessage(FreeRunnerPacket.UPDATE, message.uuid, message.value),
|
||||
entityPlayer.world.provider.getDimension());
|
||||
}
|
||||
} else if (message.packetType == FreeRunnerPacket.MODE) {
|
||||
@@ -56,18 +57,18 @@ public class PacketFreeRunnerData implements IMessageHandler<PacketFreeRunnerDat
|
||||
|
||||
public FreeRunnerPacket packetType;
|
||||
|
||||
public String username;
|
||||
public UUID uuid;
|
||||
public boolean value;
|
||||
|
||||
public FreeRunnerDataMessage() {
|
||||
}
|
||||
|
||||
public FreeRunnerDataMessage(FreeRunnerPacket packetType, String username, boolean value) {
|
||||
public FreeRunnerDataMessage(FreeRunnerPacket packetType, UUID uuid, boolean value) {
|
||||
this.packetType = packetType;
|
||||
this.value = value;
|
||||
|
||||
if (packetType == FreeRunnerPacket.UPDATE) {
|
||||
this.username = username;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,14 +79,14 @@ public class PacketFreeRunnerData implements IMessageHandler<PacketFreeRunnerDat
|
||||
if (packetType == FreeRunnerPacket.MODE) {
|
||||
buf.writeBoolean(value);
|
||||
} else if (packetType == FreeRunnerPacket.UPDATE) {
|
||||
PacketHandler.writeString(buf, username);
|
||||
PacketHandler.writeUUID(buf, uuid);
|
||||
buf.writeBoolean(value);
|
||||
} else if (packetType == FreeRunnerPacket.FULL) {
|
||||
buf.writeInt(Mekanism.freeRunnerOn.size());
|
||||
|
||||
synchronized (Mekanism.freeRunnerOn) {
|
||||
for (String usernameToSend : Mekanism.freeRunnerOn) {
|
||||
PacketHandler.writeString(buf, usernameToSend);
|
||||
for (UUID uuidToSend : Mekanism.freeRunnerOn) {
|
||||
PacketHandler.writeUUID(buf, uuidToSend);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +99,7 @@ public class PacketFreeRunnerData implements IMessageHandler<PacketFreeRunnerDat
|
||||
if (packetType == FreeRunnerPacket.MODE) {
|
||||
value = buf.readBoolean();
|
||||
} else if (packetType == FreeRunnerPacket.UPDATE) {
|
||||
username = PacketHandler.readString(buf);
|
||||
uuid = PacketHandler.readUUID(buf);
|
||||
value = buf.readBoolean();
|
||||
} else if (packetType == FreeRunnerPacket.FULL) {
|
||||
Mekanism.freeRunnerOn.clear();
|
||||
@@ -106,7 +107,7 @@ public class PacketFreeRunnerData implements IMessageHandler<PacketFreeRunnerDat
|
||||
int amount = buf.readInt();
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Mekanism.freeRunnerOn.add(PacketHandler.readString(buf));
|
||||
Mekanism.freeRunnerOn.add(PacketHandler.readUUID(buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.network;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemJetpack;
|
||||
@@ -21,10 +22,9 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
|
||||
public IMessage onMessage(JetpackDataMessage message, MessageContext context) {
|
||||
// Queue up the processing on the central thread
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
PacketHandler.handlePacket(
|
||||
() -> {
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.packetType == JetpackPacket.UPDATE) {
|
||||
Mekanism.playerState.setJetpackState(message.username, message.value, false);
|
||||
Mekanism.playerState.setJetpackState(message.uuid, message.value, false);
|
||||
|
||||
// If we got this packet on the server, propagate it out to all players in the same
|
||||
// dimension
|
||||
@@ -61,9 +61,9 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
|
||||
|
||||
protected JetpackPacket packetType;
|
||||
|
||||
protected Set<String> activeJetpacks;
|
||||
protected Set<UUID> activeJetpacks;
|
||||
|
||||
protected String username;
|
||||
protected UUID uuid;
|
||||
protected boolean value;
|
||||
|
||||
public JetpackDataMessage() {
|
||||
@@ -79,14 +79,14 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
|
||||
return m;
|
||||
}
|
||||
|
||||
public static JetpackDataMessage UPDATE(String name, boolean state) {
|
||||
public static JetpackDataMessage UPDATE(UUID uuid, boolean state) {
|
||||
JetpackDataMessage m = new JetpackDataMessage(JetpackPacket.UPDATE);
|
||||
m.username = name;
|
||||
m.uuid = uuid;
|
||||
m.value = state;
|
||||
return m;
|
||||
}
|
||||
|
||||
public static JetpackDataMessage FULL(Set<String> activeNames) {
|
||||
public static JetpackDataMessage FULL(Set<UUID> activeNames) {
|
||||
JetpackDataMessage m = new JetpackDataMessage(JetpackPacket.FULL);
|
||||
m.activeJetpacks = activeNames;
|
||||
return m;
|
||||
@@ -99,12 +99,12 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
|
||||
if (packetType == JetpackPacket.MODE) {
|
||||
dataStream.writeBoolean(value);
|
||||
} else if (packetType == JetpackPacket.UPDATE) {
|
||||
PacketHandler.writeString(dataStream, username);
|
||||
PacketHandler.writeUUID(dataStream, uuid);
|
||||
dataStream.writeBoolean(value);
|
||||
} else if (packetType == JetpackPacket.FULL) {
|
||||
dataStream.writeInt(activeJetpacks.size());
|
||||
for (String username : activeJetpacks) {
|
||||
PacketHandler.writeString(dataStream, username);
|
||||
for (UUID uuid : activeJetpacks) {
|
||||
PacketHandler.writeUUID(dataStream, uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,14 +116,14 @@ public class PacketJetpackData implements IMessageHandler<JetpackDataMessage, IM
|
||||
if (packetType == JetpackPacket.MODE) {
|
||||
value = dataStream.readBoolean();
|
||||
} else if (packetType == JetpackPacket.UPDATE) {
|
||||
username = PacketHandler.readString(dataStream);
|
||||
uuid = PacketHandler.readUUID(dataStream);
|
||||
value = dataStream.readBoolean();
|
||||
} else if (packetType == JetpackPacket.FULL) {
|
||||
activeJetpacks = new HashSet<>();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
activeJetpacks.add(PacketHandler.readString(dataStream));
|
||||
activeJetpacks.add(PacketHandler.readUUID(dataStream));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.network;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.item.ItemScubaTank;
|
||||
@@ -20,10 +21,9 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
|
||||
public IMessage onMessage(ScubaTankDataMessage message, MessageContext context) {
|
||||
// Queue up processing on the central thread
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
PacketHandler.handlePacket(
|
||||
() -> {
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.packetType == ScubaTankPacket.UPDATE) {
|
||||
Mekanism.playerState.setGasmaskState(message.username, message.value, false);
|
||||
Mekanism.playerState.setGasmaskState(message.uuid, message.value, false);
|
||||
|
||||
// If we got this on the server, relay out to all players in the same dimension
|
||||
// TODO: Why is this a dimensional thing?!
|
||||
@@ -55,9 +55,9 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
|
||||
|
||||
protected ScubaTankPacket packetType;
|
||||
|
||||
protected Set<String> activeGasmasks;
|
||||
protected Set<UUID> activeGasmasks;
|
||||
|
||||
protected String username;
|
||||
protected UUID uuid;
|
||||
protected boolean value;
|
||||
|
||||
public ScubaTankDataMessage() {
|
||||
@@ -73,14 +73,14 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
|
||||
return m;
|
||||
}
|
||||
|
||||
public static ScubaTankDataMessage UPDATE(String name, boolean state) {
|
||||
public static ScubaTankDataMessage UPDATE(UUID uuid, boolean state) {
|
||||
ScubaTankDataMessage m = new ScubaTankDataMessage(ScubaTankPacket.UPDATE);
|
||||
m.username = name;
|
||||
m.uuid = uuid;
|
||||
m.value = state;
|
||||
return m;
|
||||
}
|
||||
|
||||
public static ScubaTankDataMessage FULL(Set<String> activeNames) {
|
||||
public static ScubaTankDataMessage FULL(Set<UUID> activeNames) {
|
||||
ScubaTankDataMessage m = new ScubaTankDataMessage((ScubaTankPacket.FULL));
|
||||
m.activeGasmasks = activeNames;
|
||||
return m;
|
||||
@@ -93,12 +93,12 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
|
||||
if (packetType == ScubaTankPacket.MODE) {
|
||||
dataStream.writeBoolean(value);
|
||||
} else if (packetType == ScubaTankPacket.UPDATE) {
|
||||
PacketHandler.writeString(dataStream, username);
|
||||
PacketHandler.writeUUID(dataStream, uuid);
|
||||
dataStream.writeBoolean(value);
|
||||
} else if (packetType == ScubaTankPacket.FULL) {
|
||||
dataStream.writeInt(activeGasmasks.size());
|
||||
for (String name : activeGasmasks) {
|
||||
PacketHandler.writeString(dataStream, name);
|
||||
for (UUID uuid : activeGasmasks) {
|
||||
PacketHandler.writeUUID(dataStream, uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,14 +110,14 @@ public class PacketScubaTankData implements IMessageHandler<ScubaTankDataMessage
|
||||
if (packetType == ScubaTankPacket.MODE) {
|
||||
value = dataStream.readBoolean();
|
||||
} else if (packetType == ScubaTankPacket.UPDATE) {
|
||||
username = PacketHandler.readString(dataStream);
|
||||
uuid = PacketHandler.readUUID(dataStream);
|
||||
value = dataStream.readBoolean();
|
||||
} else if (packetType == ScubaTankPacket.FULL) {
|
||||
activeGasmasks = new HashSet<>();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
activeGasmasks.add(PacketHandler.readString(dataStream));
|
||||
activeGasmasks.add(PacketHandler.readUUID(dataStream));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user