Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Instantly respawn sub 1.15 clients if gamerule is set
Dieser Commit ist enthalten in:
Ursprung
f95b05866c
Commit
35f531d051
@ -5,6 +5,7 @@ import nl.matsv.viabackwards.api.BackwardsProtocol;
|
|||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.BackwardsMappings;
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.BackwardsMappings;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15;
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.BlockItemPackets1_15;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15;
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.packets.EntityPackets1_15;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
@ -201,7 +202,6 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
|||||||
registerOutgoing(State.PLAY, 0x45, 0x44);
|
registerOutgoing(State.PLAY, 0x45, 0x44);
|
||||||
registerOutgoing(State.PLAY, 0x46, 0x45);
|
registerOutgoing(State.PLAY, 0x46, 0x45);
|
||||||
registerOutgoing(State.PLAY, 0x48, 0x47);
|
registerOutgoing(State.PLAY, 0x48, 0x47);
|
||||||
registerOutgoing(State.PLAY, 0x49, 0x48);
|
|
||||||
registerOutgoing(State.PLAY, 0x4A, 0x49);
|
registerOutgoing(State.PLAY, 0x4A, 0x49);
|
||||||
registerOutgoing(State.PLAY, 0x4B, 0x4A);
|
registerOutgoing(State.PLAY, 0x4B, 0x4A);
|
||||||
registerOutgoing(State.PLAY, 0x4C, 0x4B);
|
registerOutgoing(State.PLAY, 0x4C, 0x4B);
|
||||||
@ -240,6 +240,8 @@ public class Protocol1_14_4To1_15 extends BackwardsProtocol {
|
|||||||
public void init(UserConnection user) {
|
public void init(UserConnection user) {
|
||||||
if (!user.has(ClientWorld.class))
|
if (!user.has(ClientWorld.class))
|
||||||
user.put(new ClientWorld(user));
|
user.put(new ClientWorld(user));
|
||||||
|
if (!user.has(ImmediateRespawn.class))
|
||||||
|
user.put(new ImmediateRespawn(user));
|
||||||
if (!user.has(EntityTracker.class))
|
if (!user.has(EntityTracker.class))
|
||||||
user.put(new EntityTracker(user));
|
user.put(new EntityTracker(user));
|
||||||
user.get(EntityTracker.class).initProtocol(this);
|
user.get(EntityTracker.class).initProtocol(this);
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
|
public class ImmediateRespawn extends StoredObject {
|
||||||
|
private boolean immediateRespawn;
|
||||||
|
|
||||||
|
public ImmediateRespawn(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isImmediateRespawn() {
|
||||||
|
return immediateRespawn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImmediateRespawn(boolean immediateRespawn) {
|
||||||
|
this.immediateRespawn = immediateRespawn;
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
|||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.Protocol1_14_4To1_15;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.EntityTypeMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ImmediateRespawn;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||||
@ -25,6 +26,26 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets(Protocol1_14_4To1_15 protocol) {
|
protected void registerPackets(Protocol1_14_4To1_15 protocol) {
|
||||||
|
// Update health
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x49, 0x48, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
float health = wrapper.passthrough(Type.FLOAT);
|
||||||
|
if (health > 0) return;
|
||||||
|
if (!wrapper.user().get(ImmediateRespawn.class).isImmediateRespawn()) return;
|
||||||
|
|
||||||
|
// Instantly request respawn when 1.15 gamerule is set
|
||||||
|
PacketWrapper statusPacket = wrapper.create(0x04);
|
||||||
|
statusPacket.write(Type.VAR_INT, 0);
|
||||||
|
statusPacket.sendToServer(Protocol1_14_4To1_15.class);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Spawn Object
|
// Spawn Object
|
||||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
@ -118,10 +139,16 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
|||||||
map(Type.VAR_INT); // 5 - View Distance
|
map(Type.VAR_INT); // 5 - View Distance
|
||||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||||
|
|
||||||
map(Type.BOOLEAN, Type.NOTHING); // Show death screen
|
|
||||||
|
|
||||||
handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.INT));
|
handler(getTrackerHandler(Entity1_15Types.EntityType.PLAYER, Type.INT));
|
||||||
handler(getDimensionHandler(1));
|
handler(getDimensionHandler(1));
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
boolean immediateRespawn = wrapper.read(Type.BOOLEAN);
|
||||||
|
wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(immediateRespawn);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren