Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
Dimension Name -> World Name
Dieser Commit ist enthalten in:
Ursprung
2a8c7334a9
Commit
ec2f118d80
@ -6,7 +6,7 @@ import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
|||||||
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.chat.TranslatableRewriter1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.chat.TranslatableRewriter1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.DimensionNameTracker;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.BlockItemPackets1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.BlockItemPackets1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.storage.PlayerSneakStorage;
|
||||||
@ -182,7 +182,7 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol<ClientboundPackets1_
|
|||||||
user.put(new EntityTracker(user));
|
user.put(new EntityTracker(user));
|
||||||
}
|
}
|
||||||
user.put(new PlayerSneakStorage(user));
|
user.put(new PlayerSneakStorage(user));
|
||||||
user.put(new DimensionNameTracker(user));
|
user.put(new WorldNameTracker(user));
|
||||||
user.get(EntityTracker.class).initProtocol(this);
|
user.get(EntityTracker.class).initProtocol(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
|
||||||
|
|
||||||
import us.myles.ViaVersion.api.data.StoredObject;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
|
|
||||||
public class DimensionNameTracker extends StoredObject {
|
|
||||||
private String dimensionName;
|
|
||||||
|
|
||||||
public DimensionNameTracker(UserConnection user) {
|
|
||||||
super(user);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDimensionName() {
|
|
||||||
return dimensionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDimensionName(String dimensionName) {
|
|
||||||
this.dimensionName = dimensionName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,20 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
|
public class WorldNameTracker extends StoredObject {
|
||||||
|
private String worldName;
|
||||||
|
|
||||||
|
public WorldNameTracker(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWorldName() {
|
||||||
|
return worldName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorldName(String worldName) {
|
||||||
|
this.worldName = worldName;
|
||||||
|
}
|
||||||
|
}
|
@ -2,7 +2,7 @@ package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets;
|
|||||||
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.DimensionNameTracker;
|
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.WorldNameTracker;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||||
@ -53,8 +53,8 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
|||||||
map(dimensionTransformer); // Dimension Type
|
map(dimensionTransformer); // Dimension Type
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
// Grab the tracker for dimension names
|
// Grab the tracker for dimension names
|
||||||
DimensionNameTracker dimensionNameTracker = wrapper.user().get(DimensionNameTracker.class);
|
WorldNameTracker worldNameTracker = wrapper.user().get(WorldNameTracker.class);
|
||||||
String nextDimensionName = wrapper.read(Type.STRING); // Dimension
|
String nextWorldName = wrapper.read(Type.STRING); // World Name
|
||||||
|
|
||||||
wrapper.passthrough(Type.LONG); // Seed
|
wrapper.passthrough(Type.LONG); // Seed
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Gamemode
|
wrapper.passthrough(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
@ -65,7 +65,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
|||||||
int dimension = wrapper.get(Type.INT, 0);
|
int dimension = wrapper.get(Type.INT, 0);
|
||||||
|
|
||||||
// Send a dummy respawn with a different dimension if the previous one is equal to the new
|
// Send a dummy respawn with a different dimension if the previous one is equal to the new
|
||||||
if (clientWorld.getEnvironment() != null && dimension == clientWorld.getEnvironment().getId() && !nextDimensionName.equals(dimensionNameTracker.getDimensionName())) {
|
if (clientWorld.getEnvironment() != null && dimension == clientWorld.getEnvironment().getId() && !nextWorldName.equals(worldNameTracker.getWorldName())) {
|
||||||
PacketWrapper packet = wrapper.create(ClientboundPackets1_15.RESPAWN.ordinal());
|
PacketWrapper packet = wrapper.create(ClientboundPackets1_15.RESPAWN.ordinal());
|
||||||
packet.write(Type.INT, dimension == 0 ? -1 : 0);
|
packet.write(Type.INT, dimension == 0 ? -1 : 0);
|
||||||
packet.write(Type.LONG, 0L);
|
packet.write(Type.LONG, 0L);
|
||||||
@ -83,8 +83,8 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
|||||||
}
|
}
|
||||||
wrapper.read(Type.BOOLEAN); // Keep all playerdata
|
wrapper.read(Type.BOOLEAN); // Keep all playerdata
|
||||||
|
|
||||||
// Finally update the dimension
|
// Finally update the world name
|
||||||
dimensionNameTracker.setDimensionName(nextDimensionName);
|
worldNameTracker.setWorldName(nextWorldName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -99,8 +99,8 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
|||||||
map(Type.NBT, Type.NOTHING); // whatever this is
|
map(Type.NBT, Type.NOTHING); // whatever this is
|
||||||
map(dimensionTransformer); // Dimension Type
|
map(dimensionTransformer); // Dimension Type
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
DimensionNameTracker dimensionNameTracker = wrapper.user().get(DimensionNameTracker.class);
|
WorldNameTracker worldNameTracker = wrapper.user().get(WorldNameTracker.class);
|
||||||
dimensionNameTracker.setDimensionName(wrapper.read(Type.STRING)); // Save the dimension name
|
worldNameTracker.setWorldName(wrapper.read(Type.STRING)); // Save the world name
|
||||||
});
|
});
|
||||||
map(Type.LONG); // Seed
|
map(Type.LONG); // Seed
|
||||||
map(Type.UNSIGNED_BYTE); // Max players
|
map(Type.UNSIGNED_BYTE); // Max players
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren