9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-30 12:29:15 +00:00

Move to CoreReflections

This commit is contained in:
iqtester
2025-06-02 15:11:34 -04:00
parent 65f0e968cc
commit 32d9a942e4
7 changed files with 436 additions and 99 deletions

View File

@@ -1,13 +1,13 @@
package net.momirealms.craftengine.bukkit.entity.data;
import net.momirealms.craftengine.bukkit.util.Reflections;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
public class PlayerData<T> extends LivingEntityData<T> {
public static final PlayerData<Object> Pose = new PlayerData<>(6, EntityDataValue.Serializers$POSE, Reflections.instance$Pose$STANDING);
public static final PlayerData<Object> Pose = new PlayerData<>(6, EntityDataValue.Serializers$POSE, CoreReflections.instance$Pose$STANDING);
public static final PlayerData<Byte> Skin = new PlayerData<>(17, EntityDataValue.Serializers$BYTE, (byte) 0);
public static final PlayerData<Byte> Hand = new PlayerData<>(18, EntityDataValue.Serializers$BYTE, (byte) 0);
public static final PlayerData<Object> LShoulder = new PlayerData<>(19, EntityDataValue.Serializers$COMPOUND_TAG, Reflections.instance$CompoundTag$Empty);
public static final PlayerData<Object> RShoulder = new PlayerData<>(20, EntityDataValue.Serializers$COMPOUND_TAG, Reflections.instance$CompoundTag$Empty);
public static final PlayerData<Object> LShoulder = new PlayerData<>(19, EntityDataValue.Serializers$COMPOUND_TAG, CoreReflections.instance$CompoundTag$Empty);
public static final PlayerData<Object> RShoulder = new PlayerData<>(20, EntityDataValue.Serializers$COMPOUND_TAG, CoreReflections.instance$CompoundTag$Empty);
public PlayerData(int id, Object serializer, T defaultValue) {
super(id, serializer, defaultValue);

View File

@@ -7,10 +7,13 @@ import net.momirealms.craftengine.bukkit.entity.furniture.BukkitFurniture;
import net.momirealms.craftengine.bukkit.nms.FastNMS;
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
import net.momirealms.craftengine.bukkit.plugin.network.BukkitNetworkManager;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MAttributeHolders;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.NetworkReflections;
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
import net.momirealms.craftengine.bukkit.util.EntityUtils;
import net.momirealms.craftengine.bukkit.util.PlayerUtils;
import net.momirealms.craftengine.bukkit.util.Reflections;
import net.momirealms.craftengine.core.entity.furniture.AbstractSeat;
import net.momirealms.craftengine.core.entity.furniture.Furniture;
import net.momirealms.craftengine.core.entity.furniture.Seat;
@@ -62,18 +65,18 @@ public class CrawlSeat extends AbstractSeat {
seatEntity.addPassenger(player);
// Fix Rider Pose
int visualId = Reflections.instance$Entity$ENTITY_COUNTER.incrementAndGet();
int visualId = CoreReflections.instance$Entity$ENTITY_COUNTER.incrementAndGet();
List<Object> packets = new ArrayList<>();
packets.add(FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(visualId, UUID.randomUUID(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(),
Reflections.instance$EntityType$SHULKER, 0, Reflections.instance$Vec3$Zero, 0));
MEntityTypes.instance$EntityType$SHULKER, 0, CoreReflections.instance$Vec3$Zero, 0));
packets.add(FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(visualId, List.copyOf(visualData)));
try {
if (VersionHelper.isOrAbove1_20_5()) {
Object attributeInstance = Reflections.constructor$AttributeInstance.newInstance(Reflections.instance$Holder$Attribute$scale, (Consumer<?>) (o) -> {});
Reflections.method$AttributeInstance$setBaseValue.invoke(attributeInstance, 0.6);
Object attributeInstance = CoreReflections.constructor$AttributeInstance.newInstance(MAttributeHolders.SCALE, (Consumer<?>) (o) -> {});
CoreReflections.method$AttributeInstance$setBaseValue.invoke(attributeInstance, 0.6);
packets.add(
Reflections.constructor$ClientboundUpdateAttributesPacket0
NetworkReflections.constructor$ClientboundUpdateAttributesPacket0
.newInstance(visualId, Collections.singletonList(attributeInstance))
);
packets.add(FastNMS.INSTANCE.constructor$ClientboundSetPassengersPacket(seatEntity.getEntityId(), visualId));
@@ -90,9 +93,9 @@ public class CrawlSeat extends AbstractSeat {
player.setPose(Pose.SWIMMING, true);
Object syncPosePacket = null;
try {
Object playerData = Reflections.method$Entity$getEntityData.invoke(serverPlayer.serverPlayer());
Object dataItem = Reflections.method$SynchedEntityData$getItem.invoke(playerData, PlayerData.Pose.entityDataAccessor());
Object dataValue = Reflections.method$SynchedEntityData$DataItem$value.invoke(dataItem);
Object playerData = CoreReflections.method$Entity$getEntityData.invoke(serverPlayer.serverPlayer());
Object dataItem = CoreReflections.method$SynchedEntityData$getItem.invoke(playerData, PlayerData.Pose.entityDataAccessor());
Object dataValue = CoreReflections.method$SynchedEntityData$DataItem$value.invoke(dataItem);
syncPosePacket = FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(serverPlayer.entityID(), List.of(dataValue));
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to construct sync pose packet", e);
@@ -130,7 +133,7 @@ public class CrawlSeat extends AbstractSeat {
super.dismount(player);
((org.bukkit.entity.Player) player.platformPlayer()).setPose(Pose.STANDING, false);
try {
Object packet = Reflections.constructor$ClientboundRemoveEntitiesPacket.newInstance((Object) new int[]{visualId});
Object packet = CoreReflections.constructor$ClientboundRemoveEntitiesPacket.newInstance((Object) new int[]{visualId});
player.sendPacket(packet, false);
} catch (Exception e) {
BukkitCraftEngine.instance().logger().warn("Failed to remove crawl entity", e);

View File

@@ -10,6 +10,10 @@ import net.momirealms.craftengine.bukkit.entity.furniture.BukkitFurniture;
import net.momirealms.craftengine.bukkit.nms.FastNMS;
import net.momirealms.craftengine.bukkit.plugin.BukkitCraftEngine;
import net.momirealms.craftengine.bukkit.plugin.network.BukkitNetworkManager;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.CoreReflections;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MEntityTypes;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.MItems;
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.NetworkReflections;
import net.momirealms.craftengine.bukkit.plugin.scheduler.impl.FoliaTask;
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
import net.momirealms.craftengine.bukkit.util.*;
@@ -74,41 +78,41 @@ public class LaySeat extends AbstractSeat {
try {
List<Object> packets = new ArrayList<>();
// NPC
Object server = Reflections.method$MinecraftServer$getServer.invoke(null);
Object server = CoreReflections.method$MinecraftServer$getServer.invoke(null);
Object level = FastNMS.INSTANCE.field$CraftWorld$ServerLevel(player.getWorld());
UUID uuid = UUID.randomUUID();
Object npcProfile = Reflections.constructor$GameProfile.newInstance(uuid, player.getName());
Object playerProfile = Reflections.method$ServerPlayer$getGameProfile.invoke(serverPlayer);
Object npcProfile = CoreReflections.constructor$GameProfile.newInstance(uuid, player.getName());
Object playerProfile = CoreReflections.method$ServerPlayer$getGameProfile.invoke(serverPlayer);
Multimap<String, Object> properties = (Multimap<String, Object>) Reflections.method$GameProfile$getProperties.invoke(npcProfile);
properties.putAll((Multimap<String, Object>) Reflections.method$GameProfile$getProperties.invoke(playerProfile));
Multimap<String, Object> properties = (Multimap<String, Object>) CoreReflections.method$GameProfile$getProperties.invoke(npcProfile);
properties.putAll((Multimap<String, Object>) CoreReflections.method$GameProfile$getProperties.invoke(playerProfile));
Object npc;
if (VersionHelper.isOrAbove1_20_2()) {
Object clientInfo = Reflections.method$ServerPlayer$clientInformation.invoke(serverPlayer);
npc = Reflections.constructor$ServerPlayer.newInstance(server, level, npcProfile, clientInfo);
Object clientInfo = CoreReflections.method$ServerPlayer$clientInformation.invoke(serverPlayer);
npc = CoreReflections.constructor$ServerPlayer.newInstance(server, level, npcProfile, clientInfo);
} else {
npc = Reflections.constructor$ServerPlayer.newInstance(server, level, npcProfile);
npc = CoreReflections.constructor$ServerPlayer.newInstance(server, level, npcProfile);
}
int npcId = FastNMS.INSTANCE.method$Entity$getId(npc);
Reflections.method$Entity$absSnapTo.invoke(npc, loc.getX(), loc.getY(), loc.getZ(), 0, 0);
CoreReflections.method$Entity$absSnapTo.invoke(npc, loc.getX(), loc.getY(), loc.getZ(), 0, 0);
Object npcSpawnPacket = FastNMS.INSTANCE.constructor$ClientboundAddEntityPacket(npcId, uuid,
loc.getX(), loc.getY(), loc.getZ(), 0, 0,
Reflections.instance$EntityType$PLAYER, 0, Reflections.instance$Vec3$Zero, 0);
MEntityTypes.instance$EntityType$PLAYER, 0, CoreReflections.instance$Vec3$Zero, 0);
// Info
EnumSet enumSet = EnumSet.noneOf((Class<? extends Enum>) Reflections.clazz$ClientboundPlayerInfoUpdatePacket$Action);
enumSet.add(Reflections.instance$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER);
EnumSet enumSet = EnumSet.noneOf((Class<? extends Enum>) CoreReflections.clazz$ClientboundPlayerInfoUpdatePacket$Action);
enumSet.add(CoreReflections.instance$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER);
Object entry;
if (VersionHelper.isOrAbove1_21_4()) {
entry = Reflections.constructor$ClientBoundPlayerInfoUpdatePacket$Entry.newInstance(
uuid, npcProfile, false, 0, Reflections.instance$GameType$SURVIVAL, null, true, 0, null);
entry = CoreReflections.constructor$ClientBoundPlayerInfoUpdatePacket$Entry.newInstance(
uuid, npcProfile, false, 0, CoreReflections.instance$GameType$SURVIVAL, null, true, 0, null);
} else if (VersionHelper.isOrAbove1_21_3()) {
entry = Reflections.constructor$ClientBoundPlayerInfoUpdatePacket$Entry.newInstance(
uuid, npcProfile, false, 0, Reflections.instance$GameType$SURVIVAL, null, 0, null);
entry = CoreReflections.constructor$ClientBoundPlayerInfoUpdatePacket$Entry.newInstance(
uuid, npcProfile, false, 0, CoreReflections.instance$GameType$SURVIVAL, null, 0, null);
} else {
entry = Reflections.constructor$ClientBoundPlayerInfoUpdatePacket$Entry.newInstance(
uuid, npcProfile, false, 0, Reflections.instance$GameType$SURVIVAL, null, null);
entry = CoreReflections.constructor$ClientBoundPlayerInfoUpdatePacket$Entry.newInstance(
uuid, npcProfile, false, 0, CoreReflections.instance$GameType$SURVIVAL, null, null);
}
Object npcInfoPacket = FastNMS.INSTANCE.constructor$ClientboundPlayerInfoUpdatePacket(enumSet, Collections.singletonList(entry));
@@ -120,50 +124,50 @@ public class LaySeat extends AbstractSeat {
bedLoc.setY(bedLoc.getWorld().getMinHeight());
Object bedPos = LocationUtils.toBlockPos(new BlockPos(bedLoc.getBlockX(), bedLoc.getBlockY(), bedLoc.getBlockZ()));
Object blockState = BlockStateUtils.blockDataToBlockState(bedData);
Object bedPacket = Reflections.constructor$ClientboundBlockUpdatePacket.newInstance(bedPos, blockState);
Object bedPacket = CoreReflections.constructor$ClientboundBlockUpdatePacket.newInstance(bedPos, blockState);
// Data
Object npcData = Reflections.method$Entity$getEntityData.invoke(npc);
Object playerData = Reflections.method$Entity$getEntityData.invoke(serverPlayer);
Reflections.method$Entity$setInvisible.invoke(serverPlayer, true);
Reflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.Pose.entityDataAccessor(), Reflections.instance$Pose$SLEEPING);
Reflections.method$SynchedEntityData$set.invoke(npcData, LivingEntityData.SleepingPos.entityDataAccessor(), Optional.of(bedPos));
Reflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.Skin.entityDataAccessor(), Reflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.Skin.entityDataAccessor()));
Reflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.Hand.entityDataAccessor(), Reflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.Hand.entityDataAccessor()));
Reflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.LShoulder.entityDataAccessor(), Reflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.LShoulder.entityDataAccessor()));
Reflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.RShoulder.entityDataAccessor(), Reflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.RShoulder.entityDataAccessor()));
Reflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.LShoulder.entityDataAccessor(), Reflections.instance$CompoundTag$Empty);
Reflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.RShoulder.entityDataAccessor(), Reflections.instance$CompoundTag$Empty);
Object npcData = CoreReflections.method$Entity$getEntityData.invoke(npc);
Object playerData = CoreReflections.method$Entity$getEntityData.invoke(serverPlayer);
CoreReflections.method$Entity$setInvisible.invoke(serverPlayer, true);
CoreReflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.Pose.entityDataAccessor(), CoreReflections.instance$Pose$SLEEPING);
CoreReflections.method$SynchedEntityData$set.invoke(npcData, LivingEntityData.SleepingPos.entityDataAccessor(), Optional.of(bedPos));
CoreReflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.Skin.entityDataAccessor(), CoreReflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.Skin.entityDataAccessor()));
CoreReflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.Hand.entityDataAccessor(), CoreReflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.Hand.entityDataAccessor()));
CoreReflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.LShoulder.entityDataAccessor(), CoreReflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.LShoulder.entityDataAccessor()));
CoreReflections.method$SynchedEntityData$set.invoke(npcData, PlayerData.RShoulder.entityDataAccessor(), CoreReflections.method$SynchedEntityData$get.invoke(playerData, PlayerData.RShoulder.entityDataAccessor()));
CoreReflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.LShoulder.entityDataAccessor(), CoreReflections.instance$CompoundTag$Empty);
CoreReflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.RShoulder.entityDataAccessor(), CoreReflections.instance$CompoundTag$Empty);
// SetData
Reflections.method$Entity$setInvisible.invoke(serverPlayer, true);
CoreReflections.method$Entity$setInvisible.invoke(serverPlayer, true);
Object npcDataPacket = FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(
npcId, (List) Reflections.method$SynchedEntityData$packDirty.invoke(npcData)
npcId, (List) CoreReflections.method$SynchedEntityData$packDirty.invoke(npcData)
);
// Remove
Object npcRemovePacket = Reflections.constructor$ClientboundRemoveEntitiesPacket.newInstance((Object) new int[]{npcId});
Object npcRemovePacket = CoreReflections.constructor$ClientboundRemoveEntitiesPacket.newInstance((Object) new int[]{npcId});
// TP
Object npcTeleportPacket;
if (VersionHelper.isOrAbove1_21_3()) {
Object positionMoveRotation = Reflections.method$PositionMoveRotation$of.invoke(null, npc);
npcTeleportPacket = Reflections.constructor$ClientboundTeleportEntityPacket.newInstance(npcId, positionMoveRotation, Set.of(), false);
Object positionMoveRotation = CoreReflections.method$PositionMoveRotation$of.invoke(null, npc);
npcTeleportPacket = CoreReflections.constructor$ClientboundTeleportEntityPacket.newInstance(npcId, positionMoveRotation, Set.of(), false);
} else {
npcTeleportPacket = Reflections.constructor$ClientboundTeleportEntityPacket.newInstance(npc);
npcTeleportPacket = CoreReflections.constructor$ClientboundTeleportEntityPacket.newInstance(npc);
}
// Equipment
List<Pair<Object, Object>> emptySlots = new ArrayList<>();
emptySlots.add(Pair.of(Reflections.instance$EquipmentSlot$MAINHAND, Reflections.instance$ItemStack$Air));
emptySlots.add(Pair.of(Reflections.instance$EquipmentSlot$OFFHAND, Reflections.instance$ItemStack$Air));
emptySlots.add(Pair.of(Reflections.instance$EquipmentSlot$HEAD, Reflections.instance$ItemStack$Air));
emptySlots.add(Pair.of(Reflections.instance$EquipmentSlot$CHEST, Reflections.instance$ItemStack$Air));
emptySlots.add(Pair.of(Reflections.instance$EquipmentSlot$LEGS, Reflections.instance$ItemStack$Air));
emptySlots.add(Pair.of(Reflections.instance$EquipmentSlot$FEET, Reflections.instance$ItemStack$Air));
Object emptyEquipPacket = Reflections.constructor$ClientboundSetEquipmentPacket.newInstance(player.getEntityId(), emptySlots);
emptySlots.add(Pair.of(CoreReflections.instance$EquipmentSlot$MAINHAND, MItems.Air$ItemStack));
emptySlots.add(Pair.of(CoreReflections.instance$EquipmentSlot$OFFHAND, MItems.Air$ItemStack));
emptySlots.add(Pair.of(CoreReflections.instance$EquipmentSlot$HEAD, MItems.Air$ItemStack));
emptySlots.add(Pair.of(CoreReflections.instance$EquipmentSlot$CHEST, MItems.Air$ItemStack));
emptySlots.add(Pair.of(CoreReflections.instance$EquipmentSlot$LEGS, MItems.Air$ItemStack));
emptySlots.add(Pair.of(CoreReflections.instance$EquipmentSlot$FEET, MItems.Air$ItemStack));
Object emptyEquipPacket = NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance(player.getEntityId(), emptySlots);
Map<EquipmentSlot, ItemStack> equipments = new HashMap<>();
EntityEquipment equipment = player.getEquipment();
@@ -178,7 +182,7 @@ public class LaySeat extends AbstractSeat {
}
List<Pair<Object, Object>> npcSlots = new ArrayList<>();
equipments.forEach((slot, item) -> npcSlots.add(Pair.of(EntityUtils.fromEquipmentSlot(slot), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(item))));
Object fullEquipPacket = Reflections.constructor$ClientboundSetEquipmentPacket.newInstance(npcId, npcSlots);
Object fullEquipPacket = NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance(npcId, npcSlots);
packets.add(npcInfoPacket);
@@ -341,16 +345,16 @@ public class LaySeat extends AbstractSeat {
Object blockPos = LocationUtils.toBlockPos(bedLoc.getBlockX(), bedLoc.getBlockY(), bedLoc.getBlockZ());
Object blockState = BlockStateUtils.blockDataToBlockState(bedLoc.getBlock().getBlockData());
try {
Object blockUpdatePacket = Reflections.constructor$ClientboundBlockUpdatePacket.newInstance(blockPos, blockState);
if (player.getPotionEffect(PotionEffectType.INVISIBILITY) == null) Reflections.method$Entity$setInvisible.invoke(serverPlayer.serverPlayer(), false);
Object blockUpdatePacket = CoreReflections.constructor$ClientboundBlockUpdatePacket.newInstance(blockPos, blockState);
if (player.getPotionEffect(PotionEffectType.INVISIBILITY) == null) CoreReflections.method$Entity$setInvisible.invoke(serverPlayer.serverPlayer(), false);
from.sendPacket(this.npcRemovePacket, true);
from.sendPacket(blockUpdatePacket, true);
Object npcData = Reflections.method$Entity$getEntityData.invoke(npc);
Object playerData = Reflections.method$Entity$getEntityData.invoke(serverPlayer.serverPlayer());
Reflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.LShoulder.entityDataAccessor(), Reflections.method$SynchedEntityData$get.invoke(npcData, PlayerData.LShoulder.entityDataAccessor()));
Reflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.RShoulder.entityDataAccessor(), Reflections.method$SynchedEntityData$get.invoke(npcData, PlayerData.RShoulder.entityDataAccessor()));
if (player.getPotionEffect(PotionEffectType.INVISIBILITY) == null) Reflections.method$Entity$setInvisible.invoke(serverPlayer.serverPlayer(), false);
Object npcData = CoreReflections.method$Entity$getEntityData.invoke(npc);
Object playerData = CoreReflections.method$Entity$getEntityData.invoke(serverPlayer.serverPlayer());
CoreReflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.LShoulder.entityDataAccessor(), CoreReflections.method$SynchedEntityData$get.invoke(npcData, PlayerData.LShoulder.entityDataAccessor()));
CoreReflections.method$SynchedEntityData$set.invoke(playerData, PlayerData.RShoulder.entityDataAccessor(), CoreReflections.method$SynchedEntityData$get.invoke(npcData, PlayerData.RShoulder.entityDataAccessor()));
if (player.getPotionEffect(PotionEffectType.INVISIBILITY) == null) CoreReflections.method$Entity$setInvisible.invoke(serverPlayer.serverPlayer(), false);
player.updateInventory();
@@ -358,8 +362,8 @@ public class LaySeat extends AbstractSeat {
player.setSleepingIgnored(false);
}
Object fullSlots = Reflections.method$ClientboundSetEquipmentPacket$getSlots.invoke(this.fullEquipPacket);
Object recoverEquip = Reflections.constructor$ClientboundSetEquipmentPacket.newInstance(player.getEntityId(), fullSlots);
Object fullSlots = CoreReflections.method$ClientboundSetEquipmentPacket$getSlots.invoke(this.fullEquipPacket);
Object recoverEquip = NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance(player.getEntityId(), fullSlots);
for (org.bukkit.entity.Player p : PlayerUtils.getTrackedBy(player)) {
BukkitServerPlayer sp = BukkitAdaptors.adapt(p);
@@ -388,8 +392,8 @@ public class LaySeat extends AbstractSeat {
equipments.forEach((slot, item) ->
allSlots.add(Pair.of(EntityUtils.fromEquipmentSlot(slot), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(item))));
try {
this.updateEquipPacket = Reflections.constructor$ClientboundSetEquipmentPacket.newInstance(npcID, changedSlots);
this.fullEquipPacket = Reflections.constructor$ClientboundSetEquipmentPacket.newInstance(npcID, allSlots);
this.updateEquipPacket = NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance(npcID, changedSlots);
this.fullEquipPacket = NetworkReflections.constructor$ClientboundSetEquipmentPacket.newInstance(npcID, allSlots);
if (previousSlot != -1) {
player.updateInventory();
}
@@ -414,7 +418,7 @@ public class LaySeat extends AbstractSeat {
@Override
public void handleContainerSetSlot(NetWorkUser user, NMSPacketEvent event, Object packet) {
try {
int slot = (int) Reflections.method$ClientboundContainerSetSlotPacket$getSlot.invoke(packet);
int slot = (int) CoreReflections.method$ClientboundContainerSetSlotPacket$getSlot.invoke(packet);
org.bukkit.entity.Player player = (org.bukkit.entity.Player) user.platformPlayer();
int convertSlot;
@@ -437,9 +441,9 @@ public class LaySeat extends AbstractSeat {
}
if (!(convertSlot == player.getInventory().getHeldItemSlot() || (isPlayerInv && (slot == 45 || (slot >= 5 && slot <= 8))))) return;
int containerId = (int) Reflections.method$ClientboundContainerSetSlotPacket$getContainerId.invoke(packet);
int stateId = (int) Reflections.method$ClientboundContainerSetSlotPacket$getStateId.invoke(packet);
Object replacePacket = Reflections.constructor$ClientboundContainerSetSlotPacket.newInstance(containerId, stateId, slot, Reflections.instance$ItemStack$Air);
int containerId = (int) CoreReflections.method$ClientboundContainerSetSlotPacket$getContainerId.invoke(packet);
int stateId = (int) CoreReflections.method$ClientboundContainerSetSlotPacket$getStateId.invoke(packet);
Object replacePacket = CoreReflections.constructor$ClientboundContainerSetSlotPacket.newInstance(containerId, stateId, slot, MItems.Air$ItemStack);
event.replacePacket(replacePacket);
} catch (Exception e) {
CraftEngine.instance().logger().warn("Failed to handleContainerSetSlotPacket", e);
@@ -452,9 +456,9 @@ public class LaySeat extends AbstractSeat {
try {
Object animatePacket;
if (e.getAnimationType() == PlayerAnimationType.ARM_SWING) {
animatePacket = Reflections.constructor$ClientboundAnimatePacket.newInstance(npc, 0);
animatePacket = CoreReflections.constructor$ClientboundAnimatePacket.newInstance(npc, 0);
} else {
animatePacket = Reflections.constructor$ClientboundAnimatePacket.newInstance(npc, 3);
animatePacket = CoreReflections.constructor$ClientboundAnimatePacket.newInstance(npc, 3);
}
serverPlayer.sendPacket(animatePacket, true);
for (org.bukkit.entity.Player other : PlayerUtils.getTrackedBy(serverPlayer.platformPlayer())) {
@@ -502,7 +506,7 @@ public class LaySeat extends AbstractSeat {
// Invisible
updateNpcInvisible();
try {
if (!player.isInvisible()) Reflections.method$Entity$setInvisible.invoke(serverPlayer.serverPlayer(), true);
if (!player.isInvisible()) CoreReflections.method$Entity$setInvisible.invoke(serverPlayer.serverPlayer(), true);
} catch (Exception exception) {
CraftEngine.instance().logger().warn("Failed to set shared flag", exception);
}
@@ -545,7 +549,7 @@ public class LaySeat extends AbstractSeat {
private void updateNpcYaw(float playerYaw) {
byte packYaw = getRot(playerYaw);
try {
this.npcRotHeadPacket = Reflections.constructor$ClientboundRotateHeadPacket.newInstance(npc, packYaw);
this.npcRotHeadPacket = CoreReflections.constructor$ClientboundRotateHeadPacket.newInstance(npc, packYaw);
} catch (Exception exception) {
CraftEngine.instance().logger().warn("Failed to sync NPC yaw", exception);
}
@@ -584,20 +588,20 @@ public class LaySeat extends AbstractSeat {
org.bukkit.entity.Player player = serverPlayer.platformPlayer();
if (player.getPotionEffect(PotionEffectType.INVISIBILITY) == null && npcDataPacket != null) {
npcDataPacket = null;
Reflections.method$Entity$setInvisible.invoke(npc, false);
Object npcData = Reflections.method$Entity$getEntityData.invoke(npc);
Object dataItem = Reflections.method$SynchedEntityData$getItem.invoke(npcData, PlayerData.SharedFlags.entityDataAccessor());
Object dataValue = Reflections.method$SynchedEntityData$DataItem$value.invoke(dataItem);
CoreReflections.method$Entity$setInvisible.invoke(npc, false);
Object npcData = CoreReflections.method$Entity$getEntityData.invoke(npc);
Object dataItem = CoreReflections.method$SynchedEntityData$getItem.invoke(npcData, PlayerData.SharedFlags.entityDataAccessor());
Object dataValue = CoreReflections.method$SynchedEntityData$DataItem$value.invoke(dataItem);
Object packet = FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(npcID, List.of(dataValue));
serverPlayer.sendPacket(packet, false);
for (org.bukkit.entity.Player p : PlayerUtils.getTrackedBy(player)) {
BukkitNetworkManager.instance().getOnlineUser(p).sendPacket(packet, false);
}
} else if (player.getPotionEffect(PotionEffectType.INVISIBILITY) != null && npcDataPacket == null) {
Reflections.method$Entity$setInvisible.invoke(npc, true);
Object npcData = Reflections.method$Entity$getEntityData.invoke(npc);
Object dataItem = Reflections.method$SynchedEntityData$getItem.invoke(npcData, PlayerData.SharedFlags.entityDataAccessor());
Object dataValue = Reflections.method$SynchedEntityData$DataItem$value.invoke(dataItem);
CoreReflections.method$Entity$setInvisible.invoke(npc, true);
Object npcData = CoreReflections.method$Entity$getEntityData.invoke(npc);
Object dataItem = CoreReflections.method$SynchedEntityData$getItem.invoke(npcData, PlayerData.SharedFlags.entityDataAccessor());
Object dataValue = CoreReflections.method$SynchedEntityData$DataItem$value.invoke(dataItem);
npcDataPacket = FastNMS.INSTANCE.constructor$ClientboundSetEntityDataPacket(npcID, List.of(dataValue));
serverPlayer.sendPacket(npcDataPacket, false);
for (org.bukkit.entity.Player p : PlayerUtils.getTrackedBy(player)) {

View File

@@ -17,7 +17,6 @@ import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.LibraryRefl
import net.momirealms.craftengine.bukkit.plugin.reflection.minecraft.NetworkReflections;
import net.momirealms.craftengine.bukkit.plugin.user.BukkitServerPlayer;
import net.momirealms.craftengine.bukkit.util.KeyUtils;
import net.momirealms.craftengine.bukkit.util.Reflections;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.context.CooldownData;
import net.momirealms.craftengine.core.plugin.network.*;
@@ -165,6 +164,8 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
registerNMSPacketConsumer(PacketConsumers.SET_ENTITY_MOTION, NetworkReflections.clazz$ClientboundSetEntityMotionPacket);
registerNMSPacketConsumer(PacketConsumers.SET_EQUIPMENT_NMS, Reflections.clazz$ClientboundSetEquipmentPacket);
registerNMSPacketConsumer(PacketConsumers.SET_CONTAINER_SLOT, Reflections.clazz$ClientboundContainerSetSlotPacket);
registerNMSPacketConsumer(PacketConsumers.SET_EQUIPMENT_NMS, NetworkReflections.clazz$ClientboundSetEquipmentPacket);
registerNMSPacketConsumer(PacketConsumers.SET_CONTAINER_SLOT, NetworkReflections.clazz$ClientboundContainerSetSlotPacket);
registerS2CByteBufPacketConsumer(PacketConsumers.LEVEL_CHUNK_WITH_LIGHT, this.packetIds.clientboundLevelChunkWithLightPacket());
registerS2CByteBufPacketConsumer(PacketConsumers.SECTION_BLOCK_UPDATE, this.packetIds.clientboundSectionBlocksUpdatePacket());
registerS2CByteBufPacketConsumer(PacketConsumers.BLOCK_UPDATE, this.packetIds.clientboundBlockUpdatePacket());

View File

@@ -2431,7 +2431,7 @@ public class PacketConsumers {
};
public static final TriConsumer<NetWorkUser, NMSPacketEvent, Object> SET_EQUIPMENT_NMS = (user, event, packet) -> {
try {
int entityId = (int) Reflections.method$ClientboundSetEquipmentPacket$getEntity.invoke(packet);
int entityId = (int) CoreReflections.method$ClientboundSetEquipmentPacket$getEntity.invoke(packet);
EntityPacketHandler handler = user.entityPacketHandlers().get(entityId);
if (handler != null) {
handler.handleSetEquipment(user, event, packet);

View File

@@ -1,5 +1,6 @@
package net.momirealms.craftengine.bukkit.plugin.reflection.minecraft;
import com.google.common.collect.ForwardingMultimap;
import com.google.common.collect.ImmutableList;
import com.google.gson.JsonElement;
import com.mojang.serialization.Codec;
@@ -3347,4 +3348,332 @@ public final class CoreReflections {
throw new ReflectionInitException("Failed to init ItemStack$CODEC", e);
}
}
public static final Method method$Entity$setInvisible = requireNonNull(
ReflectionUtils.getMethod(
clazz$Entity, new String[]{"j", "setInvisible"}, boolean.class
)
);
public static final Class<?> clazz$GameProfile = requireNonNull(
ReflectionUtils.getClazz("com.mojang.authlib.GameProfile")
);
public static final Constructor<?> constructor$GameProfile = requireNonNull(
ReflectionUtils.getConstructor(
clazz$GameProfile, 0
)
);
public static final Method method$GameProfile$getProperties = requireNonNull(
ReflectionUtils.getMethod(
clazz$GameProfile, ForwardingMultimap.class
)
);
public static final Constructor<?> constructor$ServerPlayer = requireNonNull(
ReflectionUtils.getConstructor(
clazz$ServerPlayer, 0
)
);
public static final Method method$ServerPlayer$getGameProfile = requireNonNull(
ReflectionUtils.getMethod(
clazz$ServerPlayer, clazz$GameProfile, 0
)
);
// 1.20.2 +
public static final Method method$ServerPlayer$clientInformation = VersionHelper.isOrAbove1_20_2() ? requireNonNull(ReflectionUtils.getMethod(
clazz$ServerPlayer, clazz$ClientInformation, 0
)) : null;
public static final Class<?> clazz$CompoundTag = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"nbt.NBTTagCompound",
"nbt.CompoundTag"
)
);
public static final Object instance$CompoundTag$Empty;
static {
try {
instance$CompoundTag$Empty = CoreReflections.clazz$CompoundTag.getConstructor().newInstance();
} catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to instantiate empty CompoundTag", e);
}
}
public static final Method method$Entity$getEntityData = requireNonNull(
ReflectionUtils.getMethod(
clazz$Entity, clazz$SynchedEntityData, 0
)
);
public static final Method method$SynchedEntityData$set = requireNonNull(
ReflectionUtils.getMethod(
clazz$SynchedEntityData, void.class, clazz$EntityDataAccessor, Object.class
)
);
public static final Method method$SynchedEntityData$isDirty = requireNonNull(
ReflectionUtils.getMethod(
clazz$SynchedEntityData, boolean.class
)
);
public static final Method method$SynchedEntityData$packDirty = requireNonNull(
ReflectionUtils.getMethod(
clazz$SynchedEntityData, List.class, new String[]{"b", "packDirty"}
)
);
public static final Class<?> clazz$SynchedEntityData$DataItem = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.syncher.DataWatcher$Item",
"network.syncher.SynchedEntityData$DataItem"
)
);
public static final Method method$SynchedEntityData$getItem = requireNonNull(
ReflectionUtils.getDeclaredMethod(
clazz$SynchedEntityData, clazz$SynchedEntityData$DataItem, clazz$EntityDataAccessor)
);
public static final Method method$SynchedEntityData$DataItem$value = requireNonNull(
ReflectionUtils.getMethod(
clazz$SynchedEntityData$DataItem, clazz$SynchedEntityData$DataValue, 0
)
);
public static final Class<?> clazz$ClientBoundPlayerInfoRemovePacket = requireNonNull(
ReflectionUtils.getClazz(
BukkitReflectionUtils.assembleMCClass("network.protocol.game.ClientboundPlayerInfoRemovePacket")
)
);
public static final Constructor<?> constructor$ClientBoundPlayerInfoRemovePacket = requireNonNull(
ReflectionUtils.getConstructor(clazz$ClientBoundPlayerInfoRemovePacket, List.class)
);
public static final Class<?> clazz$ClientBoundPlayerInfoUpdatePacket$Entry = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.ClientboundPlayerInfoUpdatePacket$b",
"network.protocol.game.ClientboundPlayerInfoUpdatePacket$Entry"
)
);
public static final Class<?> clazz$RemoteChatSession$Data = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.chat.RemoteChatSession$a",
"network.chat.RemoteChatSession$Data"
)
);
public static final Constructor<?> constructor$ClientBoundPlayerInfoUpdatePacket$Entry = requireNonNull(
VersionHelper.isOrAbove1_21_3()
? VersionHelper.isOrAbove1_21_4()
? ReflectionUtils.getConstructor(clazz$ClientBoundPlayerInfoUpdatePacket$Entry, UUID.class, clazz$GameProfile, boolean.class, int.class, clazz$GameType, clazz$Component, boolean.class, int.class, clazz$RemoteChatSession$Data)
: ReflectionUtils.getConstructor(clazz$ClientBoundPlayerInfoUpdatePacket$Entry, UUID.class, clazz$GameProfile, boolean.class, int.class, clazz$GameType, clazz$Component, int.class, clazz$RemoteChatSession$Data)
: ReflectionUtils.getConstructor(clazz$ClientBoundPlayerInfoUpdatePacket$Entry, UUID.class, clazz$GameProfile, boolean.class, int.class, clazz$GameType, clazz$Component, clazz$RemoteChatSession$Data)
);
public static final Method method$GameType$values = requireNonNull(
ReflectionUtils.getStaticMethod(
clazz$GameType, clazz$GameType.arrayType()
)
);
public static final Object instance$GameType$SURVIVAL;
public static final Object instance$GameType$CREATIVE;
public static final Object instance$GameType$ADVENTURE;
public static final Object instance$GameType$SPECTATOR;
static {
try {
Object[] values = (Object[]) method$GameType$values.invoke(null);
instance$GameType$SURVIVAL = values[0];
instance$GameType$CREATIVE = values[1];
instance$GameType$ADVENTURE = values[2];
instance$GameType$SPECTATOR = values[3];
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
// 1.21.3 +
public static final Class<?> clazz$PositionMoveRotation = VersionHelper.isOrAbove1_21_3() ? ReflectionUtils.getClazz(
requireNonNull(BukkitReflectionUtils.assembleMCClass("world.entity.PositionMoveRotation"))) : null;
public static final Method method$PositionMoveRotation$of = VersionHelper.isOrAbove1_21_3() ? requireNonNull(
ReflectionUtils.getStaticMethod(clazz$PositionMoveRotation, clazz$PositionMoveRotation, clazz$Entity)) : null;
public static final Method method$Entity$absSnapTo = requireNonNull(
ReflectionUtils.getMethod(
clazz$Entity, void.class, double.class, double.class, double.class, float.class, float.class
)
);
public static final Class<?> clazz$ClientboundTeleportEntityPacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.PacketPlayOutEntityTeleport",
"network.protocol.game.ClientboundTeleportEntityPacket"
)
);
public static final Constructor<?> constructor$ClientboundTeleportEntityPacket = requireNonNull(
VersionHelper.isOrAbove1_21_3()
? ReflectionUtils.getConstructor(clazz$ClientboundTeleportEntityPacket, int.class, clazz$PositionMoveRotation, Set.class, boolean.class)
: ReflectionUtils.getConstructor(clazz$ClientboundTeleportEntityPacket, clazz$Entity)
);
public static final Method method$Entity$setSharedFlag = requireNonNull(
ReflectionUtils.getDeclaredMethod(
clazz$Entity, void.class, int.class, boolean.class
)
);
public static final Method method$ClientboundSetEquipmentPacket$getEntity = requireNonNull(
ReflectionUtils.getMethod(
NetworkReflections.clazz$ClientboundSetEquipmentPacket, int.class
)
);
public static final Method method$ClientboundSetEquipmentPacket$getSlots = requireNonNull(
ReflectionUtils.getMethod(
NetworkReflections.clazz$ClientboundSetEquipmentPacket, List.class
)
);
public static final Class<?> clazz$ClientboundContainerSetSlotPacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.PacketPlayOutSetSlot",
"network.protocol.game.ClientboundContainerSetSlotPacket"
)
);
public static final Constructor<?> constructor$ClientboundContainerSetSlotPacket = requireNonNull(
ReflectionUtils.getConstructor(
clazz$ClientboundContainerSetSlotPacket, int.class, int.class, int.class, clazz$ItemStack
)
);
public static final Method method$ClientboundContainerSetSlotPacket$getContainerId = requireNonNull(
ReflectionUtils.getMethod(
clazz$ClientboundContainerSetSlotPacket, int.class, new String[]{"a", "getContainerId"}
)
);
public static final Method method$ClientboundContainerSetSlotPacket$getSlot = requireNonNull(
ReflectionUtils.getMethod(
clazz$ClientboundContainerSetSlotPacket, int.class, new String[]{"c", "d", "getSlot"}
)
);
public static final Method method$ClientboundContainerSetSlotPacket$getStateId = requireNonNull(
ReflectionUtils.getMethod(
clazz$ClientboundContainerSetSlotPacket, int.class, new String[]{"e", "f", "getStateId"}
)
);
public static final Class<?> clazz$ClientboundAnimatePacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.PacketPlayOutAnimation",
"network.protocol.game.ClientboundAnimatePacket")
);
public static final Constructor<?> constructor$ClientboundAnimatePacket = requireNonNull(
ReflectionUtils.getConstructor(clazz$ClientboundAnimatePacket, clazz$Entity, int.class)
);
public static final Class<?> clazz$ClientboundRotateHeadPacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.PacketPlayOutEntityHeadRotation",
"network.protocol.game.ClientboundRotateHeadPacket"
)
);
public static final Constructor<?> constructor$ClientboundRotateHeadPacket = requireNonNull(
ReflectionUtils.getDeclaredConstructor(
clazz$ClientboundRotateHeadPacket, clazz$Entity, byte.class
)
);
public static final Class<?> clazz$ClientboundBlockUpdatePacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.PacketPlayOutBlockChange",
"network.protocol.game.ClientboundBlockUpdatePacket"
)
);
public static final Constructor<?> constructor$ClientboundBlockUpdatePacket = requireNonNull(
ReflectionUtils.getConstructor(
clazz$ClientboundBlockUpdatePacket, clazz$BlockPos, clazz$BlockState
)
);
public static final Class<?> clazz$ClientboundRemoveEntitiesPacket = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.PacketPlayOutEntityDestroy",
"network.protocol.game.ClientboundRemoveEntitiesPacket"
)
);
public static final Constructor<?> constructor$ClientboundRemoveEntitiesPacket = requireNonNull(
ReflectionUtils.getConstructor(clazz$ClientboundRemoveEntitiesPacket, int[].class)
);
public static final Class<?> clazz$ClientboundPlayerInfoUpdatePacket = requireNonNull(
ReflectionUtils.getClazz(
BukkitReflectionUtils.assembleMCClass("network.protocol.game.ClientboundPlayerInfoUpdatePacket")
)
);
public static final Field field$ClientboundPlayerInfoUpdatePacket$entries = requireNonNull(
ReflectionUtils.getDeclaredField(
clazz$ClientboundPlayerInfoUpdatePacket, List.class, 0
)
);
public static final Class<?> clazz$ClientboundPlayerInfoUpdatePacket$Action = requireNonNull(
BukkitReflectionUtils.findReobfOrMojmapClass(
"network.protocol.game.ClientboundPlayerInfoUpdatePacket$a",
"network.protocol.game.ClientboundPlayerInfoUpdatePacket$Action"
)
);
public static final Method method$ClientboundPlayerInfoUpdatePacket$Action$values = requireNonNull(
ReflectionUtils.getStaticMethod(
clazz$ClientboundPlayerInfoUpdatePacket$Action, clazz$ClientboundPlayerInfoUpdatePacket$Action.arrayType()
)
);
public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER;
public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$INITIALIZE_CHAT;
public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE;
public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_LISTED;
public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_LATENCY;
public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_DISPLAY_NAME;
//public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_LIST_ORDER;
//public static final Object instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_HAT;
static {
try {
Object[] values = (Object[]) method$ClientboundPlayerInfoUpdatePacket$Action$values.invoke(null);
instance$ClientboundPlayerInfoUpdatePacket$Action$ADD_PLAYER = values[0];
instance$ClientboundPlayerInfoUpdatePacket$Action$INITIALIZE_CHAT = values[1];
instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_GAME_MODE = values[2];
instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_LISTED = values[3];
instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_LATENCY = values[4];
instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_DISPLAY_NAME = values[5];
//1.21.3
//instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_LIST_ORDER = values[6];
//1.21.4
//instance$ClientboundPlayerInfoUpdatePacket$Action$UPDATE_HAT = values[7];
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -111,24 +111,24 @@ public class EntityUtils {
public static Object fromEquipmentSlot(org.bukkit.inventory.EquipmentSlot slot) {
return switch (slot) {
case HAND -> Reflections.instance$EquipmentSlot$MAINHAND;
case OFF_HAND -> Reflections.instance$EquipmentSlot$OFFHAND;
case HEAD -> Reflections.instance$EquipmentSlot$HEAD;
case CHEST -> Reflections.instance$EquipmentSlot$CHEST;
case LEGS -> Reflections.instance$EquipmentSlot$LEGS;
case FEET -> Reflections.instance$EquipmentSlot$FEET;
case HAND -> CoreReflections.instance$EquipmentSlot$MAINHAND;
case OFF_HAND -> CoreReflections.instance$EquipmentSlot$OFFHAND;
case HEAD -> CoreReflections.instance$EquipmentSlot$HEAD;
case CHEST -> CoreReflections.instance$EquipmentSlot$CHEST;
case LEGS -> CoreReflections.instance$EquipmentSlot$LEGS;
case FEET -> CoreReflections.instance$EquipmentSlot$FEET;
default -> new Object();
};
};
public static Object fromEquipmentSlot(EquipmentSlot slot) {
return switch (slot) {
case MAIN_HAND -> Reflections.instance$EquipmentSlot$MAINHAND;
case OFF_HAND -> Reflections.instance$EquipmentSlot$OFFHAND;
case HEAD -> Reflections.instance$EquipmentSlot$HEAD;
case CHEST -> Reflections.instance$EquipmentSlot$CHEST;
case LEGS -> Reflections.instance$EquipmentSlot$LEGS;
case FEET -> Reflections.instance$EquipmentSlot$FEET;
case MAIN_HAND -> CoreReflections.instance$EquipmentSlot$MAINHAND;
case OFF_HAND -> CoreReflections.instance$EquipmentSlot$OFFHAND;
case HEAD -> CoreReflections.instance$EquipmentSlot$HEAD;
case CHEST -> CoreReflections.instance$EquipmentSlot$CHEST;
case LEGS -> CoreReflections.instance$EquipmentSlot$LEGS;
case FEET -> CoreReflections.instance$EquipmentSlot$FEET;
default -> new Object();
};
}