Compare commits
2 commits
a98d5a75bd
...
df988dbf87
Author | SHA1 | Date | |
---|---|---|---|
df988dbf87 | |||
23f9424fa9 |
3 changed files with 48 additions and 21 deletions
|
@ -39,7 +39,7 @@ repositories {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Nicko
|
// Nicko
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("com.github.dmulloy2:ProtocolLib:master-SNAPSHOT")
|
compileOnly("com.github.dmulloy2:ProtocolLib:master-SNAPSHOT")
|
||||||
compileOnly("me.clip:placeholderapi:2.11.5")
|
compileOnly("me.clip:placeholderapi:2.11.5")
|
||||||
compileOnly("net.kyori:adventure-api:4.17.0")
|
compileOnly("net.kyori:adventure-api:4.17.0")
|
||||||
|
@ -128,9 +128,14 @@ tasks {
|
||||||
|
|
||||||
downloadPlugins {
|
downloadPlugins {
|
||||||
url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.jar")
|
url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.jar")
|
||||||
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
|
||||||
|
// 1.20 - 1.20.4 testing
|
||||||
|
url("https://github.com/dmulloy2/ProtocolLib/releases/download/5.2.0/ProtocolLib.jar")
|
||||||
|
|
||||||
|
// 1.20.5 - latest testing
|
||||||
|
//url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraftVersion("1.21.1")
|
minecraftVersion("1.20.4")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -151,7 +151,7 @@ public class AppearanceManager {
|
||||||
respawn.setGameMode(player.getGameMode());
|
respawn.setGameMode(player.getGameMode());
|
||||||
respawn.setPreviousGameMode(player.getGameMode());
|
respawn.setPreviousGameMode(player.getGameMode());
|
||||||
respawn.setCopyMetadata(true);
|
respawn.setCopyMetadata(true);
|
||||||
//respawn.sendPacket(player);
|
respawn.sendPacket(player);
|
||||||
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
player.setAllowFlight(wasAllowedToFly);
|
player.setAllowFlight(wasAllowedToFly);
|
||||||
player.setFlying(wasFlying);
|
player.setFlying(wasFlying);
|
||||||
|
|
|
@ -3,9 +3,10 @@ package xyz.ineanto.nicko.wrapper;
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.InternalStructure;
|
import com.comphenix.protocol.events.InternalStructure;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import com.comphenix.protocol.reflect.accessors.Accessors;
|
||||||
import com.comphenix.protocol.utility.MinecraftReflection;
|
import com.comphenix.protocol.utility.MinecraftReflection;
|
||||||
import com.comphenix.protocol.utility.MinecraftVersion;
|
import com.comphenix.protocol.utility.MinecraftVersion;
|
||||||
import com.comphenix.protocol.wrappers.BukkitConverters;
|
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||||
import com.comphenix.protocol.wrappers.MinecraftKey;
|
import com.comphenix.protocol.wrappers.MinecraftKey;
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
|
@ -23,32 +24,53 @@ import org.bukkit.World;
|
||||||
public class WrapperPlayServerRespawn extends AbstractPacket {
|
public class WrapperPlayServerRespawn extends AbstractPacket {
|
||||||
public static final PacketType TYPE = PacketType.Play.Server.RESPAWN;
|
public static final PacketType TYPE = PacketType.Play.Server.RESPAWN;
|
||||||
|
|
||||||
private final InternalStructure spawnInfoStructure;
|
private InternalStructure spawnInfoStructure = null;
|
||||||
|
|
||||||
public WrapperPlayServerRespawn() {
|
public WrapperPlayServerRespawn() {
|
||||||
super(new PacketContainer(TYPE), TYPE);
|
super(new PacketContainer(TYPE), TYPE);
|
||||||
handle.getModifier().writeDefaults();
|
handle.getModifier().writeDefaults();
|
||||||
spawnInfoStructure = handle.getStructures().readSafely(0);
|
if (MinecraftVersion.CONFIG_PHASE_PROTOCOL_UPDATE.atOrAbove()) {
|
||||||
|
spawnInfoStructure = handle.getStructures().read(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimension(World value) {
|
public void setDimension(World value) {
|
||||||
if (!MinecraftVersion.CONFIG_PHASE_PROTOCOL_UPDATE.atOrAbove()) {
|
final MinecraftVersion v1_20_5 = new MinecraftVersion(1, 20, 5);
|
||||||
// 1.20 to 1.20.1 (by lukalt)
|
|
||||||
final InternalStructure dimensionType = handle.getStructures().read(0);
|
if (!MinecraftVersion.getCurrentVersion().isAtLeast(v1_20_5)) {
|
||||||
|
// 1.20 - 1.20.4
|
||||||
|
final StructureModifier<InternalStructure> structureModifier = spawnInfoStructure == null ?
|
||||||
|
handle.getStructures() : spawnInfoStructure.getStructures();
|
||||||
|
|
||||||
|
final StructureModifier<World> worldStructureModifier = spawnInfoStructure == null ?
|
||||||
|
handle.getWorldKeys() : spawnInfoStructure.getWorldKeys();
|
||||||
|
|
||||||
|
final InternalStructure dimensionType = structureModifier.read(0);
|
||||||
dimensionType.getMinecraftKeys().writeSafely(0, new MinecraftKey("minecraft", "dimension_type"));
|
dimensionType.getMinecraftKeys().writeSafely(0, new MinecraftKey("minecraft", "dimension_type"));
|
||||||
dimensionType.getMinecraftKeys().writeSafely(1, new MinecraftKey("minecraft", "overworld"));
|
dimensionType.getMinecraftKeys().writeSafely(1, new MinecraftKey("minecraft", "overworld"));
|
||||||
handle.getStructures().writeSafely(0, dimensionType);
|
structureModifier.writeSafely(0, dimensionType);
|
||||||
handle.getWorldKeys().writeSafely(0, value);
|
worldStructureModifier.writeSafely(0, value);
|
||||||
return;
|
} else {
|
||||||
}
|
// 1.20.5 to 1.21.1
|
||||||
|
|
||||||
|
// why is life so hard?
|
||||||
|
// Get the key from that class
|
||||||
|
final MinecraftKey key = MinecraftKey.fromHandle(
|
||||||
|
Accessors.getFieldAccessor(
|
||||||
|
TYPE.getPacketClass(),
|
||||||
|
MinecraftReflection.getResourceKey(),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.get(spawnInfoStructure));
|
||||||
|
|
||||||
|
// Set the key
|
||||||
|
Accessors.getFieldAccessor(
|
||||||
|
spawnInfoStructure.getClass(),
|
||||||
|
MinecraftReflection.getResourceKey(),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.set(spawnInfoStructure, key);
|
||||||
|
|
||||||
// 1.20.2 to 1.21
|
|
||||||
if (MinecraftVersion.TRAILS_AND_TAILS.atOrAbove() && !MinecraftVersion.v1_21_0.atOrAbove()) {
|
|
||||||
spawnInfoStructure.getHolders(
|
|
||||||
MinecraftReflection.getDimensionManager(),
|
|
||||||
BukkitConverters.getDimensionConverter()
|
|
||||||
).write(0, value);
|
|
||||||
spawnInfoStructure.getWorldKeys().writeSafely(0, value);
|
|
||||||
handle.getStructures().writeSafely(0, spawnInfoStructure);
|
handle.getStructures().writeSafely(0, spawnInfoStructure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue