Compare commits

..

No commits in common. "df988dbf87c5f9e5d47fa8f849385a6c94249c35" and "a98d5a75bdc30686d9def1551c3322d6ccbb0ca8" have entirely different histories.

3 changed files with 21 additions and 48 deletions
build.gradle.kts
src/main/java/xyz/ineanto/nicko

View file

@ -39,7 +39,7 @@ repositories {
dependencies {
// Nicko
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
compileOnly("com.github.dmulloy2:ProtocolLib:master-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.5")
compileOnly("net.kyori:adventure-api:4.17.0")
@ -128,14 +128,9 @@ tasks {
downloadPlugins {
url("https://download.luckperms.net/1554/bukkit/loader/LuckPerms-Bukkit-5.4.139.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")
url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
}
minecraftVersion("1.20.4")
minecraftVersion("1.21.1")
}
}

View file

@ -151,7 +151,7 @@ public class AppearanceManager {
respawn.setGameMode(player.getGameMode());
respawn.setPreviousGameMode(player.getGameMode());
respawn.setCopyMetadata(true);
respawn.sendPacket(player);
//respawn.sendPacket(player);
player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
player.setAllowFlight(wasAllowedToFly);
player.setFlying(wasFlying);

View file

@ -3,10 +3,9 @@ package xyz.ineanto.nicko.wrapper;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.InternalStructure;
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.MinecraftVersion;
import com.comphenix.protocol.wrappers.BukkitConverters;
import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.MinecraftKey;
import com.google.common.hash.Hashing;
@ -24,53 +23,32 @@ import org.bukkit.World;
public class WrapperPlayServerRespawn extends AbstractPacket {
public static final PacketType TYPE = PacketType.Play.Server.RESPAWN;
private InternalStructure spawnInfoStructure = null;
private final InternalStructure spawnInfoStructure;
public WrapperPlayServerRespawn() {
super(new PacketContainer(TYPE), TYPE);
handle.getModifier().writeDefaults();
if (MinecraftVersion.CONFIG_PHASE_PROTOCOL_UPDATE.atOrAbove()) {
spawnInfoStructure = handle.getStructures().read(0);
}
spawnInfoStructure = handle.getStructures().readSafely(0);
}
public void setDimension(World value) {
final MinecraftVersion v1_20_5 = new MinecraftVersion(1, 20, 5);
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);
if (!MinecraftVersion.CONFIG_PHASE_PROTOCOL_UPDATE.atOrAbove()) {
// 1.20 to 1.20.1 (by lukalt)
final InternalStructure dimensionType = handle.getStructures().read(0);
dimensionType.getMinecraftKeys().writeSafely(0, new MinecraftKey("minecraft", "dimension_type"));
dimensionType.getMinecraftKeys().writeSafely(1, new MinecraftKey("minecraft", "overworld"));
structureModifier.writeSafely(0, dimensionType);
worldStructureModifier.writeSafely(0, value);
} 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);
handle.getStructures().writeSafely(0, dimensionType);
handle.getWorldKeys().writeSafely(0, value);
return;
}
// 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);
}
}