forked from SteamWar/SteamWar
Remove more Reflection stuff
This commit is contained in:
@@ -21,7 +21,6 @@ package de.steamwar.core;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import de.steamwar.Reflection;
|
||||
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoRemovePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket;
|
||||
@@ -42,7 +41,7 @@ public class ProtocolWrapper {
|
||||
public static final Class<?> equipmentPacket = ClientboundSetEquipmentPacket.class;
|
||||
|
||||
// 0: hand, 1: offhand, 2: feet, 3: legs, 4: chest, 5: head
|
||||
public static final Object[] itemSlots = Core.getVersion() > 8 ? Reflection.getClass("net.minecraft.world.entity.EnumItemSlot").getEnumConstants() : new Integer[]{0, 0, 1, 2, 3, 4};
|
||||
public static final EquipmentSlot[] itemSlots = EquipmentSlot.values();
|
||||
|
||||
public static final ProtocolWrapper impl = new ProtocolWrapper();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import de.steamwar.linkage.Linked;
|
||||
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
|
||||
import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Linked
|
||||
@@ -33,7 +34,7 @@ public class WorldIdentifier {
|
||||
private static ResourceKey<Level> resourceKey = null;
|
||||
|
||||
private static final Class<?> resourceKeyClass = ResourceKey.class;
|
||||
private static final Class<?> minecraftKeyClass = Reflection.getClass("net.minecraft.resources.MinecraftKey");
|
||||
private static final Class<?> minecraftKeyClass = ResourceLocation.class;
|
||||
private static final Reflection.Constructor resourceKeyConstructor = Reflection.getConstructor(resourceKeyClass, minecraftKeyClass, minecraftKeyClass);
|
||||
private static final Reflection.Constructor minecraftKeyConstructor = Reflection.getConstructor(minecraftKeyClass, String.class, String.class);
|
||||
|
||||
|
||||
@@ -21,8 +21,10 @@ package de.steamwar.entity;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import de.steamwar.Reflection;
|
||||
import de.steamwar.core.*;
|
||||
import de.steamwar.core.BountifulWrapper;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.ProtocolWrapper;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.network.CoreNetworkHandler;
|
||||
import de.steamwar.network.NetworkSender;
|
||||
import de.steamwar.network.packets.common.PlayerSkinRequestPacket;
|
||||
@@ -36,7 +38,6 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class RPlayer extends REntity {
|
||||
|
||||
@@ -114,24 +115,7 @@ public class RPlayer extends REntity {
|
||||
packetSink.accept(ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.REMOVE, saved, GameMode.CREATIVE));
|
||||
}
|
||||
|
||||
private static Class<?> namedSpawnPacket = null;
|
||||
private static Function<REntity, Object> namedSpawnPacketGenerator = null;
|
||||
private static Reflection.Field<UUID> namedSpawnUUID = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
namedSpawnPacket = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundAddPlayerPacket");
|
||||
namedSpawnPacketGenerator = spawnPacketGenerator(namedSpawnPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||
namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
|
||||
} catch (IllegalArgumentException e) { }
|
||||
}
|
||||
|
||||
private Object getNamedSpawnPacket() {
|
||||
if (Core.getVersion() >= 21) return PacketConstructor.impl.createRPlayerSpawn(this);
|
||||
|
||||
Object packet = namedSpawnPacketGenerator.apply(this);
|
||||
namedSpawnUUID.set(packet, uuid);
|
||||
FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet);
|
||||
return packet;
|
||||
return PacketConstructor.impl.createRPlayerSpawn(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user