diff --git a/AccessWidener/src/main/java/de/steamwar/ClassPatcher.java b/AccessWidener/src/main/java/de/steamwar/ClassPatcher.java index a5549762..2cce0c77 100644 --- a/AccessWidener/src/main/java/de/steamwar/ClassPatcher.java +++ b/AccessWidener/src/main/java/de/steamwar/ClassPatcher.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Set; import java.util.logging.Logger; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Uses ASM to patch class bytecode according to a list of access widener entries. @@ -46,6 +47,11 @@ public class ClassPatcher { this.entries = entries; this.targets = entries.stream() .map(AccessWidenerEntry::target) + .flatMap(s -> { + if (!s.contains("$")) return Stream.of(s); + int index = s.lastIndexOf('$'); + return Stream.of(s, s.substring(0, index)); + }) .collect(Collectors.toSet()); } diff --git a/AccessWidener/src/main/java/de/steamwar/ClassTransformer.java b/AccessWidener/src/main/java/de/steamwar/ClassTransformer.java index c329b966..ccc3df9d 100644 --- a/AccessWidener/src/main/java/de/steamwar/ClassTransformer.java +++ b/AccessWidener/src/main/java/de/steamwar/ClassTransformer.java @@ -47,6 +47,16 @@ public class ClassTransformer extends ClassVisitor { super.visit(version, newAccess, name, signature, superName, interfaces); } + @Override + public void visitInnerClass(String name, String outerName, String innerName, int access) { + int newAccess = access; + for (AccessWidenerEntry e : entries) { + if (!e.target().equals(name) || !"class".equals(e.memberType())) continue; + newAccess = applyDirective(e.directive(), newAccess, false); + } + super.visitInnerClass(name, outerName, innerName, newAccess); + } + @Override public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { int newAccess = access; diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index 0187d089..d11c98db 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -115,18 +115,18 @@ public class Recording implements Listener { }.register(); new StateDependent(ArenaMode.AntiReplay, FightState.Ingame) { private final BiFunction place = Recording.this::blockPlace; - private final BiFunction dig = Recording.this::blockDig; + private final BiFunction dig = Recording.this::blockDig; @Override public void enable() { TinyProtocol.instance.addFilter(ServerboundUseItemPacket.class, place); - TinyProtocol.instance.addFilter(blockDigPacket, dig); + TinyProtocol.instance.addFilter(ServerboundPlayerActionPacket.class, dig); } @Override public void disable() { TinyProtocol.instance.removeFilter(ServerboundUseItemPacket.class, place); - TinyProtocol.instance.removeFilter(blockDigPacket, dig); + TinyProtocol.instance.removeFilter(ServerboundPlayerActionPacket.class, dig); } }.register(); new StateDependentTask(ArenaMode.AntiReplay, FightState.All, () -> { @@ -143,13 +143,8 @@ public class Recording implements Listener { GlobalRecorder.getInstance().entitySpeed(entity); } - private static final Class> blockDigPacket = ServerboundPlayerActionPacket.class; - private static final Class playerDigType = blockDigPacket.getDeclaredClasses()[0]; - private static final Reflection.Field blockDigType = Reflection.getField(blockDigPacket, playerDigType, 0); - private static final Object releaseUseItem = playerDigType.getEnumConstants()[5]; - - private Object blockDig(Player p, Object packet) { - if (!isNotSent(p) && blockDigType.get(packet) == releaseUseItem) { + private Object blockDig(Player p, ServerboundPlayerActionPacket packet) { + if (!isNotSent(p) && packet.getAction() == ServerboundPlayerActionPacket.Action.RELEASE_USE_ITEM) { GlobalRecorder.getInstance().bowSpan(p, false, false); } return packet; diff --git a/SpigotCore/SpigotCore_Main/build.gradle.kts b/SpigotCore/SpigotCore_Main/build.gradle.kts index a5e3227d..34bc1d49 100644 --- a/SpigotCore/SpigotCore_Main/build.gradle.kts +++ b/SpigotCore/SpigotCore_Main/build.gradle.kts @@ -42,6 +42,45 @@ tasks.withType().configureEach { jvmArgs("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED") } +// ─── Collect all .accesswidener files from this plugin's resources ──────────── +val accessWidenerFiles: FileCollection = fileTree("src/") { + include("**/*.accesswidener") +} + +val paperJarProvider: Provider = provider { + val dep = libs.nms.get() + configurations["compileClasspath"].resolvedConfiguration.resolvedArtifacts.first { artifact -> + artifact.moduleVersion.id.module.group == dep.module.group && artifact.moduleVersion.id.module.name == dep.module.name + }.file +} + +// ─── Widen the Paper dev JAR so the IDE / javac see the patched access ──────── +val widenedJar by tasks.registering(JavaExec::class) { + description = "Produces a widened copy of the Paper dev JAR for compile-time use." + group = "widener" + + // Re-run whenever the .accesswidener files change + inputs.file(paperJarProvider) + inputs.files(accessWidenerFiles) + + val output = layout.buildDirectory.file("widened/paper-widened.jar") + outputs.file(output) + + classpath = project(":AccessWidener").tasks.named("shadowJar").get().outputs.files + + mainClass.set("de.steamwar.Main") + + doFirst { + args = buildList { + add(paperJarProvider.get().absolutePath) + add(output.get().asFile.absolutePath) + addAll(accessWidenerFiles.map { it.absolutePath }) + } + } + + dependsOn(":AccessWidener:shadowJar") +} + dependencies { compileOnly(libs.classindex) annotationProcessor(libs.classindex) @@ -53,6 +92,7 @@ dependencies { compileOnly(libs.paperapi) compileOnly(libs.nms) + compileOnly(files(widenedJar)) compileOnly(libs.authlib) compileOnly(libs.datafixer) compileOnly(libs.netty) @@ -61,3 +101,7 @@ dependencies { implementation(libs.anvilgui) } + +tasks.compileJava { + dependsOn(widenedJar) +} diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index f7df16c1..5391f59b 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -1,7 +1,6 @@ package com.comphenix.tinyprotocol; import com.google.common.collect.MapMaker; -import de.steamwar.Reflection; import de.steamwar.core.CRIUWakeupEvent; import de.steamwar.core.Core; import io.netty.channel.*; @@ -180,22 +179,12 @@ public class TinyProtocol { networkManagers = serverConnection.getConnections(); // We need to synchronize against this list createServerChannelHandler(); + for (ChannelFuture item : serverConnection.channels) { + // Channel future that contains the server connection + Channel serverChannel = item.channel(); - // Find the correct list, or implicitly throw an exception - boolean looking = true; - for (int i = 0; looking; i++) { - List list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection); - - for (Object item : list) { - if (!(item instanceof ChannelFuture)) break; - - // Channel future that contains the server connection - Channel serverChannel = ((ChannelFuture) item).channel(); - - serverChannels.add(serverChannel); - serverChannel.pipeline().addFirst(serverChannelHandler); - looking = false; - } + serverChannels.add(serverChannel); + serverChannel.pipeline().addFirst(serverChannelHandler); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java index e5a69d9f..64bef9b5 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java @@ -26,13 +26,9 @@ import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializer; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; -import net.minecraft.world.entity.PositionMoveRotation; -import net.minecraft.world.phys.Vec3; import org.bukkit.Sound; import org.bukkit.entity.Player; -import java.util.UUID; - public class BountifulWrapper { public static final BountifulWrapper impl = new BountifulWrapper(); @@ -55,49 +51,4 @@ public class BountifulWrapper { public Object getDataWatcherItem(Object dwo, Object value) { return new SynchedEntityData.DataItem<>((EntityDataAccessor) dwo, value); } - - public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { - try { - Reflection.Field field = Reflection.getField(packetClass, PositionMoveRotation.class, 0); - - return (packet, x, y, z, pitch, yaw) -> { - field.set(packet, new PositionMoveRotation(new Vec3(x, y, z), field.get(packet).deltaMovement(), yaw, pitch)); - }; - } catch (IllegalArgumentException e) { - Reflection.Field posX = Reflection.getField(packetClass, double.class, fieldOffset); - Reflection.Field posY = Reflection.getField(packetClass, double.class, fieldOffset + 1); - Reflection.Field posZ = Reflection.getField(packetClass, double.class, fieldOffset + 2); - boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn"); - Class pitchYawType = isByteClass ? byte.class : int.class; - Reflection.Field lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); - Reflection.Field lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); - - return (packet, x, y, z, pitch, yaw) -> { - posX.set(packet, x); - posY.set(packet, y); - posZ.set(packet, z); - if (isByteClass) { - lookYaw.set(packet, (byte) (yaw * 256 / 360)); - lookPitch.set(packet, (byte) (pitch * 256 / 360)); - } else { - lookYaw.set(packet, (int) (yaw * 256 / 360)); - lookPitch.set(packet, (int) (pitch * 256 / 360)); - } - }; - } - } - - public BountifulWrapper.UUIDSetter getUUIDSetter(Class packetClass) { - Reflection.Field uuidField = Reflection.getField(packetClass, UUID.class, 0); - - return uuidField::set; - } - - public interface PositionSetter { - void set(Object packet, double x, double y, double z, float pitch, float yaw); - } - - public interface UUIDSetter { - void set(Object packet, UUID uuid); - } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java index 4ccbaaa7..2849b5a4 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/CheckpointUtilsJ9.java @@ -20,7 +20,6 @@ package de.steamwar.core; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; import de.steamwar.sql.internal.Statement; import io.netty.channel.ChannelFuture; import net.minecraft.server.MinecraftServer; @@ -96,9 +95,6 @@ class CheckpointUtilsJ9 { } } - - private static final Reflection.Field channelFutures = Reflection.getField(ServerConnectionListener.class, List.class, 0, ChannelFuture.class); - private static void freezeInternal(Path path) throws Exception { Bukkit.getPluginManager().callEvent(new CRIUSleepEvent()); @@ -109,9 +105,9 @@ class CheckpointUtilsJ9 { // Close socket ServerConnectionListener serverConnection = MinecraftServer.getServer().getConnection(); - List channels = channelFutures.get(serverConnection); - for (Object future : channels) { - ((ChannelFuture) future).channel().close().syncUninterruptibly(); + List channels = serverConnection.channels; + for (ChannelFuture future : channels) { + future.channel().close().syncUninterruptibly(); } channels.clear(); @@ -145,8 +141,8 @@ class CheckpointUtilsJ9 { // Reopen socket serverConnection.startTcpServerListener(InetAddress.getLoopbackAddress(), port); - for (Object future : channels) { - ((ChannelFuture) future).channel().config().setAutoRead(true); + for (ChannelFuture future : channels) { + future.channel().config().setAutoRead(true); } Bukkit.getPluginManager().callEvent(new CRIUWakeupEvent()); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java index f60eb406..5995a3c1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java @@ -19,7 +19,6 @@ package de.steamwar.core; -import de.steamwar.Reflection; import de.steamwar.sql.SWException; import org.spigotmc.WatchdogThread; @@ -39,9 +38,7 @@ public class ErrorHandler extends Handler { public ErrorHandler() { Logger.getLogger("").addHandler(this); - - Reflection.Field getInstance = Reflection.getField(WatchdogThread.class, WatchdogThread.class, 0); - watchdogThreadId = getInstance.get(null).getId(); + watchdogThreadId = WatchdogThread.instance.threadId(); } void unregister() { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java index 2ca9d085..2fa27b1e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java @@ -20,7 +20,6 @@ package de.steamwar.core; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; import de.steamwar.linkage.Linked; import net.minecraft.network.protocol.game.ClientboundLoginPacket; import net.minecraft.network.protocol.game.CommonPlayerSpawnInfo; @@ -33,13 +32,8 @@ public class WorldIdentifier { private static ResourceKey resourceKey = null; - private static final Class resourceKeyClass = ResourceKey.class; - 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); - public static void set(String name) { - resourceKey = (ResourceKey) resourceKeyConstructor.invoke(minecraftKeyConstructor.invoke("minecraft", "dimension"), minecraftKeyConstructor.invoke("steamwar", name)); + resourceKey = new ResourceKey<>(new ResourceLocation("minecraft", "dimension"), new ResourceLocation("steamwar", name)); } public WorldIdentifier() { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java index 32e394e7..dd7540c6 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/authlib/SteamwarGameProfileRepository.java @@ -22,7 +22,6 @@ package de.steamwar.core.authlib; import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.ProfileLookupCallback; -import de.steamwar.Reflection; import de.steamwar.sql.SteamwarUser; import net.minecraft.server.MinecraftServer; import net.minecraft.server.Services; @@ -35,13 +34,10 @@ public class SteamwarGameProfileRepository implements GameProfileRepository { public static final SteamwarGameProfileRepository impl = new SteamwarGameProfileRepository(); private static final GameProfileRepository fallback; - private static final Reflection.Field field; private static final Services current; static { - Class clazz = MinecraftServer.getServer().getClass(); - field = Reflection.getField(clazz, Services.class, 0); - current = field.get(MinecraftServer.getServer()); + current = MinecraftServer.getServer().services; fallback = current.profileRepository(); } @@ -68,7 +64,6 @@ public class SteamwarGameProfileRepository implements GameProfileRepository { } public void inject() { - Services newServices = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations()); - field.set(MinecraftServer.getServer(), newServices); + MinecraftServer.getServer().services = new Services(current.sessionService(), current.servicesKeySet(), this, current.profileCache(), current.paperConfigurations()); } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 8ac0c01b..2d867cc1 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -44,7 +44,6 @@ import org.bukkit.inventory.ItemStack; import java.util.*; import java.util.function.Consumer; -import java.util.function.Function; public class REntity { @@ -174,14 +173,10 @@ public class REntity { server.postEntityMove(this, fromX, fromZ); } - private static final Class animationPacket = ClientboundAnimatePacket.class; - private static final Reflection.Field animationEntity = Reflection.getField(animationPacket, int.class, 5); - private static final Reflection.Field animationAnimation = Reflection.getField(animationPacket, int.class, 6); - public void showAnimation(byte animation) { - Object packet = Reflection.newInstance(animationPacket); - animationEntity.set(packet, entityId); - animationAnimation.set(packet, (int) animation); + ClientboundAnimatePacket packet = (ClientboundAnimatePacket) Reflection.newInstance(ClientboundAnimatePacket.class); + packet.id = entityId; + packet.action = animation; server.updateEntity(this, packet); } @@ -189,14 +184,10 @@ public class REntity { server.updateEntity(this, new ClientboundSetEntityMotionPacket(entityId, new Vec3(calcVelocity(dX), calcVelocity(dY), calcVelocity(dZ)))); } - private static final Class statusPacket = ClientboundEntityEventPacket.class; - private static final Reflection.Field statusEntity = Reflection.getField(statusPacket, int.class, 0); - private static final Reflection.Field statusStatus = Reflection.getField(statusPacket, byte.class, 0); - public void showDamage() { - Object packet = Reflection.newInstance(statusPacket); - statusEntity.set(packet, entityId); - statusStatus.set(packet, (byte) 2); + ClientboundEntityEventPacket packet = (ClientboundEntityEventPacket) Reflection.newInstance(ClientboundEntityEventPacket.class); + packet.entityId = entityId; + packet.eventId = (byte) 2; server.updateEntity(this, packet); } @@ -251,14 +242,10 @@ public class REntity { server.updateEntity(this, getDataWatcherPacket(entityStatusWatcher, getEntityStatus())); } - private static final Function spawnPacketGenerator = entitySpawnPacketGenerator(ClientboundAddEntityPacket.class, 2); - - private static final Reflection.Field additionalData = Reflection.getField(ClientboundAddEntityPacket.class, int.class, 4); - - private Object spawnPacketGenerator() { - Object packet = spawnPacketGenerator.apply(this); - additionalData.set(packet, objectData); - return packet; + private ClientboundAddEntityPacket spawnPacketGenerator() { + ResourceLocation key = CraftNamespacedKey.toMinecraft(entityType.getKey()); + net.minecraft.world.entity.EntityType entityType = BuiltInRegistries.ENTITY_TYPE.get(key).get().value(); + return new ClientboundAddEntityPacket(entityId, uuid, x, y, z, pitch, yaw, entityType, objectData, Vec3.ZERO, 0); } void list(Consumer packetSink) { @@ -359,14 +346,10 @@ public class REntity { } } - private static final Class headRotationPacket = ClientboundRotateHeadPacket.class; - private static final Reflection.Field headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0); - private static final Reflection.Field headRotationYaw = Reflection.getField(headRotationPacket, byte.class, 0); - private Object getHeadRotationPacket() { - Object packet = Reflection.newInstance(headRotationPacket); - headRotationEntity.set(packet, entityId); - headRotationYaw.set(packet, headYaw); + ClientboundRotateHeadPacket packet = (ClientboundRotateHeadPacket) Reflection.newInstance(ClientboundRotateHeadPacket.class); + packet.entityId = entityId; + packet.yHeadRot = headYaw; return packet; } @@ -374,33 +357,6 @@ public class REntity { return new ClientboundSetEquipmentPacket(entityId, Collections.singletonList(Pair.of((EquipmentSlot) slot, CraftItemStack.asNMSCopy(stack)))); } - private static final Reflection.Field spawnType = Reflection.getField(ClientboundAddEntityPacket.class, net.minecraft.world.entity.EntityType.class, 0); - - private static Function entitySpawnPacketGenerator(Class spawnPacket, int posOffset) { - BountifulWrapper.UUIDSetter uuid = BountifulWrapper.impl.getUUIDSetter(spawnPacket); - Function packetGenerator = spawnPacketGenerator(spawnPacket, posOffset); - - return entity -> { - Object packet = packetGenerator.apply(entity); - uuid.set(packet, entity.uuid); - ResourceLocation key = CraftNamespacedKey.toMinecraft(entity.entityType.getKey()); - spawnType.set(packet, BuiltInRegistries.ENTITY_TYPE.get(key).get().value()); - return packet; - }; - } - - protected static Function spawnPacketGenerator(Class spawnPacket, int posOffset) { - Reflection.Field entityId = Reflection.getField(spawnPacket, int.class, 0); - BountifulWrapper.PositionSetter position = BountifulWrapper.impl.getPositionSetter(spawnPacket, posOffset); - - return entity -> { - Object packet = Reflection.newInstance(spawnPacket); - entityId.set(packet, entity.entityId); - position.set(packet, entity.x, entity.y, entity.z, entity.pitch, entity.yaw); - return packet; - }; - } - private byte rotToByte(float rot) { return (byte) ((int) (rot * 256.0F / 360.0F)); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java index 3d7fa97c..471cdc4a 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ChunkHider.java @@ -19,10 +19,8 @@ package de.steamwar.techhider; -import de.steamwar.Reflection; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import net.minecraft.core.SectionPos; import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.util.SimpleBitStorage; @@ -35,13 +33,8 @@ import java.util.List; import java.util.function.UnaryOperator; public class ChunkHider { - private static final UnaryOperator chunkPacketShallowCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); - private static final UnaryOperator chunkDataShallowCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); - - private static final Reflection.Field levelChunkPacketDataField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkPacketData.class, 0); - - private static final Reflection.Field chunkBlockDataField = Reflection.getField(ClientboundLevelChunkPacketData.class, byte[].class, 0); - private static final Reflection.Field chunkBlockEntitiesDataField = Reflection.getField(ClientboundLevelChunkPacketData.class, List.class, 0); + private static final UnaryOperator chunkPacketShallowCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); + private static final UnaryOperator chunkDataShallowCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); private final int SECTION_SPAN_SIZE = 16; private final byte BIT_PER_BLOCK_INDIRECTION_LIMIT = 8; @@ -178,8 +171,8 @@ public class ChunkHider { byte[] data = new byte[out.readableBytes()]; out.readBytes(data); - List blockEntities = chunkBlockEntitiesDataField.get(chunkData); - List filteredBlockEntities = filterBlockEntities(player, blockEntities, chunkX, chunkZ); + List blockEntities = chunkData.blockEntitiesData; + List filteredBlockEntities = filterBlockEntities(player, blockEntities, chunkX, chunkZ); return buildNewChunkPacket(packet, data, filteredBlockEntities); @@ -237,33 +230,24 @@ public class ChunkHider { return reEncodedData.getRaw(); } - private ClientboundLevelChunkWithLightPacket buildNewChunkPacket(ClientboundLevelChunkWithLightPacket originalPacket, byte[] newBlockDataBuffer, List newBlockEntities) { - ClientboundLevelChunkWithLightPacket clonedPacket = (ClientboundLevelChunkWithLightPacket) chunkPacketShallowCloner.apply(originalPacket); - ClientboundLevelChunkPacketData clonedPacketChunkData = (ClientboundLevelChunkPacketData) chunkDataShallowCloner.apply(originalPacket.getChunkData()); + private ClientboundLevelChunkWithLightPacket buildNewChunkPacket(ClientboundLevelChunkWithLightPacket originalPacket, byte[] newBlockDataBuffer, List newBlockEntities) { + ClientboundLevelChunkWithLightPacket clonedPacket = chunkPacketShallowCloner.apply(originalPacket); + ClientboundLevelChunkPacketData clonedPacketChunkData = chunkDataShallowCloner.apply(originalPacket.getChunkData()); - chunkBlockDataField.set(clonedPacketChunkData, newBlockDataBuffer); - chunkBlockEntitiesDataField.set(clonedPacketChunkData, newBlockEntities); - - levelChunkPacketDataField.set(clonedPacket, clonedPacketChunkData); + clonedPacketChunkData.buffer = newBlockDataBuffer; + clonedPacketChunkData.blockEntitiesData = newBlockEntities; + clonedPacket.chunkData = clonedPacketChunkData; return clonedPacket; } - - private static final Class blockEntitiyInfoClass = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo"); - - private static final Reflection.Field blockEntityInfoTypeField = Reflection.getField(blockEntitiyInfoClass, BlockEntityType.class, 0); - private static final Reflection.Field packedXZField = Reflection.getField(blockEntitiyInfoClass, int.class, 0); - private static final Reflection.Field yField = Reflection.getField(blockEntitiyInfoClass, int.class, 1); - - private List filterBlockEntities(Player player, List blockEntities, int chunkX, int chunkZ) { + private List filterBlockEntities(Player player, List blockEntities, int chunkX, int chunkZ) { int fourBitBitmask = 0b0000_1111; return blockEntities.stream() .filter((blockEntityInfo) -> { - BlockEntityType type = blockEntityInfoTypeField.get(blockEntityInfo); - - int packedXZ = packedXZField.get(blockEntityInfo); + BlockEntityType type = blockEntityInfo.type; + int packedXZ = blockEntityInfo.packedXZ; int localX = (packedXZ >> 4) & fourBitBitmask; int localZ = packedXZ & fourBitBitmask; @@ -271,7 +255,7 @@ public class ChunkHider { int worldX = (chunkX * SECTION_SPAN_SIZE) + localX; int worldZ = (chunkZ * SECTION_SPAN_SIZE) + localZ; - int worldY = yField.get(blockEntityInfo); + int worldY = blockEntityInfo.y; return accessPrivilegeProvider.isPlayerPrivilegedToAccessPosition(player, worldX, worldY, worldZ) && accessPrivilegeProvider.isPlayerPrivilegedToAccessBlockEntity(player, worldX, worldY, worldZ, type); }).toList(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java index e71b522a..b97fe828 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/ProtocolUtils.java @@ -50,33 +50,23 @@ public class ProtocolUtils { }; } - public static UnaryOperator shallowCloneGenerator(Class clazz) { - BiConsumer filler = shallowFill(clazz); + public static UnaryOperator shallowCloneGenerator(Class clazz) { + BiConsumer filler = shallowFill(clazz); return source -> { - Object clone = Reflection.newInstance(clazz); + T clone = (T) Reflection.newInstance(clazz); filler.accept(source, clone); return clone; }; } - public static UnaryOperator shallowTypedCloneGenerator(Class clazz) { - BiConsumer filler = shallowFill(clazz); - - return source -> { - Object clone = Reflection.newInstance(clazz); - filler.accept(source, clone); - return (T) clone; - }; - } - - private static BiConsumer shallowFill(Class clazz) { + private static BiConsumer shallowFill(Class clazz) { if (clazz == null) { return (source, clone) -> { }; } - BiConsumer superFiller = shallowFill(clazz.getSuperclass()); + BiConsumer superFiller = shallowFill(clazz.getSuperclass()); Field[] fds = clazz.getDeclaredFields(); List fields = new ArrayList<>(); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java index 1539f16d..0fef6f1e 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/TechHider.java @@ -20,7 +20,6 @@ package de.steamwar.techhider; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.Reflection; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.shorts.ShortArraySet; @@ -364,24 +363,16 @@ public class TechHider { }; } - private final Reflection.Field moveEntityPacketEntityIdField = Reflection.getField(ClientboundMoveEntityPacket.class, int.class, 0); - private Packet processMoveEntityPacket(Player player, ClientboundMoveEntityPacket packet) { - int entityId = moveEntityPacketEntityIdField.get(packet); - - if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, entityId)) { + if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, packet.entityId)) { return packet; } else { return null; } } - private final Reflection.Field rotateHeadPacketEntityIdField = Reflection.getField(ClientboundRotateHeadPacket.class, int.class, 0); - private Packet processRotateHeadPacket(Player player, ClientboundRotateHeadPacket packet) { - int entityId = rotateHeadPacketEntityIdField.get(packet); - - if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, entityId)) { + if (privilegeProvider.isPlayerPrivilegedToAccessEntity(player, packet.entityId)) { return packet; } else { return null; @@ -463,14 +454,10 @@ public class TechHider { } } - private final Reflection.Field sectionPosField = Reflection.getField(ClientboundSectionBlocksUpdatePacket.class, SectionPos.class, 0); - private final Reflection.Field oldPosField = Reflection.getField(ClientboundSectionBlocksUpdatePacket.class, short[].class, 0); - private final Reflection.Field oldStatesField = Reflection.getField(ClientboundSectionBlocksUpdatePacket.class, BlockState[].class, 0); - private ClientboundSectionBlocksUpdatePacket processSectionUpdate(Player p, ClientboundSectionBlocksUpdatePacket packet) { - SectionPos sectionPos = sectionPosField.get(packet); - short[] oldPos = oldPosField.get(packet); - BlockState[] oldStates = oldStatesField.get(packet); + SectionPos sectionPos = packet.sectionPos; + short[] oldPos = packet.positions; + BlockState[] oldStates = packet.states; List filteredPos = new ArrayList<>(oldPos.length); List filteredStates = new ArrayList<>(oldStates.length); diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ChunkHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ChunkHider.java index c3df8e6f..57bce2e2 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ChunkHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ChunkHider.java @@ -34,7 +34,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import org.bukkit.entity.Player; import java.util.Collections; -import java.util.List; import java.util.Set; import java.util.function.BiFunction; import java.util.function.UnaryOperator; @@ -44,35 +43,26 @@ import java.util.stream.Collectors; public class ChunkHider { public static final ChunkHider impl = new ChunkHider(); - public Class mapChunkPacket() { - return ClientboundLevelChunkWithLightPacket.class; - } + private static final UnaryOperator chunkPacketCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); + private static final UnaryOperator chunkDataCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); - private static final UnaryOperator chunkPacketCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkWithLightPacket.class); - private static final UnaryOperator chunkDataCloner = ProtocolUtils.shallowCloneGenerator(ClientboundLevelChunkPacketData.class); - - private static final Reflection.Field chunkXField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 0); - private static final Reflection.Field chunkZField = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, int.class, 1); - private static final Reflection.Field chunkData = Reflection.getField(ClientboundLevelChunkWithLightPacket.class, ClientboundLevelChunkPacketData.class, 0); - - private static final Reflection.Field dataField = Reflection.getField(ClientboundLevelChunkPacketData.class, byte[].class, 0); - private static final Reflection.Field tileEntities = Reflection.getField(ClientboundLevelChunkPacketData.class, List.class, 0); - - public BiFunction chunkHiderGenerator(TechHider techHider) { + public BiFunction chunkHiderGenerator(TechHider techHider) { return (p, packet) -> { - int chunkX = chunkXField.get(packet); - int chunkZ = chunkZField.get(packet); + int chunkX = packet.getX(); + int chunkZ = packet.getZ(); if (techHider.getLocationEvaluator().skipChunk(p, chunkX, chunkZ)) { return packet; } packet = chunkPacketCloner.apply(packet); - Object dataWrapper = chunkDataCloner.apply(chunkData.get(packet)); + ClientboundLevelChunkPacketData dataWrapper = chunkDataCloner.apply(packet.getChunkData()); Set hiddenBlockEntities = techHider.getHiddenBlockEntities(); - tileEntities.set(dataWrapper, ((List) tileEntities.get(dataWrapper)).stream().filter(te -> tileEntityVisible(hiddenBlockEntities, te)).collect(Collectors.toList())); + dataWrapper.blockEntitiesData = dataWrapper.blockEntitiesData.stream() + .filter(te -> tileEntityVisible(hiddenBlockEntities, te)) + .collect(Collectors.toList()); - ByteBuf in = Unpooled.wrappedBuffer(dataField.get(dataWrapper)); + ByteBuf in = Unpooled.wrappedBuffer(dataWrapper.buffer); ByteBuf out = Unpooled.buffer(in.readableBytes() + 64); for (int yOffset = p.getWorld().getMinHeight(); yOffset < p.getWorld().getMaxHeight(); yOffset += 16) { SectionHider section = new SectionHider(p, techHider, in, out, chunkX, yOffset / 16, chunkZ); @@ -88,20 +78,18 @@ public class ChunkHider { byte[] data = new byte[out.readableBytes()]; out.readBytes(data); - dataField.set(dataWrapper, data); + dataWrapper.buffer = data; - chunkData.set(packet, dataWrapper); + packet.chunkData = dataWrapper; return packet; }; } private static final Registry> registry = Reflection.getField(BuiltInRegistries.class, "BLOCK_ENTITY_TYPE", Registry.class).get(null); private static final Reflection.Method getKey = Reflection.getTypedMethod(Reflection.getClass("net.minecraft.core.Registry"), "getKey", ResourceLocation.class, Object.class); - public static final Class tileEntity = Reflection.getClass("net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo"); - protected static final Reflection.Field entityType = Reflection.getField(tileEntity, BlockEntityType.class, 0); - protected boolean tileEntityVisible(Set hiddenBlockEntities, Object tile) { - BlockEntityType type = entityType.get(tile); + protected boolean tileEntityVisible(Set hiddenBlockEntities, ClientboundLevelChunkPacketData.BlockEntityInfo tile) { + BlockEntityType type = tile.type; String path = ((ResourceLocation) getKey.invoke(registry, type)).getPath(); return !hiddenBlockEntities.contains(path); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ProtocolWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ProtocolWrapper.java index 00e0dc31..cb7b8d05 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ProtocolWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/ProtocolWrapper.java @@ -19,10 +19,8 @@ package de.steamwar.techhider.legacy; -import de.steamwar.Reflection; import net.minecraft.core.SectionPos; -import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraft.world.level.block.entity.SignBlockEntity; +import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.entity.Player; @@ -33,24 +31,20 @@ import java.util.function.BiFunction; public class ProtocolWrapper { public static final ProtocolWrapper impl = new ProtocolWrapper(); - private static final Reflection.Field multiBlockChangeChunk = Reflection.getField(TechHider.multiBlockChangePacket, SectionPos.class, 0); - private static final Reflection.Field multiBlockChangePos = Reflection.getField(TechHider.multiBlockChangePacket, short[].class, 0); - private static final Reflection.Field multiBlockChangeBlocks = Reflection.getField(TechHider.multiBlockChangePacket, BlockState[].class, 0); - - public BiFunction multiBlockChangeGenerator(TechHider techHider) { + public BiFunction multiBlockChangeGenerator(TechHider techHider) { return (p, packet) -> { TechHider.LocationEvaluator locationEvaluator = techHider.getLocationEvaluator(); - Object chunkCoords = multiBlockChangeChunk.get(packet); - int chunkX = TechHider.blockPositionX.get(chunkCoords); - int chunkY = TechHider.blockPositionY.get(chunkCoords); - int chunkZ = TechHider.blockPositionZ.get(chunkCoords); + SectionPos chunkCoords = packet.sectionPos; + int chunkX = chunkCoords.getX(); + int chunkY = chunkCoords.getY(); + int chunkZ = chunkCoords.getZ(); if (locationEvaluator.skipChunkSection(p, chunkX, chunkY, chunkZ)) { return packet; } packet = TechHider.multiBlockChangeCloner.apply(packet); - final short[] oldPos = multiBlockChangePos.get(packet); - final BlockState[] oldBlocks = multiBlockChangeBlocks.get(packet); + final short[] oldPos = packet.positions; + final BlockState[] oldBlocks = packet.states; ArrayList poss = new ArrayList<>(oldPos.length); ArrayList blocks = new ArrayList<>(oldPos.length); for (int i = 0; i < oldPos.length; i++) { @@ -77,16 +71,9 @@ public class ProtocolWrapper { newPos[i] = poss.get(i); } - multiBlockChangePos.set(packet, newPos); - multiBlockChangeBlocks.set(packet, blocks.toArray(new BlockState[0])); + packet.positions = newPos; + packet.states = blocks.toArray(BlockState[]::new); return packet; }; } - - private static final Reflection.Field tileEntityType = Reflection.getField(TechHider.tileEntityDataPacket, BlockEntityType.class, 0); - private static final BlockEntityType signType = Reflection.getField(BlockEntityType.class, BlockEntityType.class, 0, SignBlockEntity.class).get(null); - - public boolean unfilteredTileEntityDataAction(Object packet) { - return tileEntityType.get(packet) != signType; - } } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/TechHider.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/TechHider.java index 25b3f215..9a96771f 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/TechHider.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/techhider/legacy/TechHider.java @@ -28,6 +28,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; import net.minecraft.network.protocol.game.*; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Material; import org.bukkit.craftbukkit.util.CraftMagicNumbers; @@ -37,7 +38,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.function.BiFunction; -import java.util.function.Function; import java.util.function.UnaryOperator; import java.util.stream.Collectors; @@ -45,10 +45,6 @@ import java.util.stream.Collectors; public class TechHider { public static final Class blockPosition = BlockPos.class; - private static final Class baseBlockPosition = Vec3i.class; - public static final Reflection.Field blockPositionX = Reflection.getField(baseBlockPosition, int.class, 0); - public static final Reflection.Field blockPositionY = Reflection.getField(baseBlockPosition, int.class, 1); - public static final Reflection.Field blockPositionZ = Reflection.getField(baseBlockPosition, int.class, 2); public static final Class iBlockData = BlockState.class; public static final Class block = Block.class; @@ -79,11 +75,11 @@ public class TechHider { this.obfuscationTarget = CraftMagicNumbers.getBlock(obfuscationTarget).defaultBlockState(); this.obfuscationTargetId = BlockIds.impl.materialToId(obfuscationTarget); - techhiders.put(blockActionPacket, this::blockActionHider); - techhiders.put(blockChangePacket, this::blockChangeHider); - techhiders.put(tileEntityDataPacket, this::tileEntityDataHider); - techhiders.put(multiBlockChangePacket, ProtocolWrapper.impl.multiBlockChangeGenerator(this)); - techhiders.put(ChunkHider.impl.mapChunkPacket(), ChunkHider.impl.chunkHiderGenerator(this)); + techhiders.put(ClientboundBlockEventPacket.class, (player, o) -> this.blockActionHider(player, (ClientboundBlockEventPacket) o)); + techhiders.put(ClientboundBlockUpdatePacket.class, (player, o) -> this.blockChangeHider(player, (ClientboundBlockUpdatePacket) o)); + techhiders.put(ClientboundBlockEntityDataPacket.class, (player, o) -> this.tileEntityDataHider(player, (ClientboundBlockEntityDataPacket) o)); + techhiders.put(ClientboundSectionBlocksUpdatePacket.class, (BiFunction) ProtocolWrapper.impl.multiBlockChangeGenerator(this)); + techhiders.put(ClientboundLevelChunkWithLightPacket.class, (BiFunction) ChunkHider.impl.chunkHiderGenerator(this)); techhiders.put(ServerboundUseItemOnPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); techhiders.put(ServerboundInteractPacket.class, (p, packet) -> locationEvaluator.suppressInteractions(p) ? null : packet); @@ -97,53 +93,43 @@ public class TechHider { techhiders.forEach(TinyProtocol.instance::removeFilter); } - public static final Class multiBlockChangePacket = ClientboundSectionBlocksUpdatePacket.class; - public static final UnaryOperator multiBlockChangeCloner = ProtocolUtils.shallowCloneGenerator(TechHider.multiBlockChangePacket); + public static final UnaryOperator multiBlockChangeCloner = ProtocolUtils.shallowCloneGenerator(ClientboundSectionBlocksUpdatePacket.class); - private static final Class blockChangePacket = ClientboundBlockUpdatePacket.class; - private static final Function blockChangeCloner = ProtocolUtils.shallowCloneGenerator(blockChangePacket); - private static final Reflection.Field blockChangePosition = Reflection.getField(blockChangePacket, blockPosition, 0); - private static final Reflection.Field blockChangeBlockData = Reflection.getField(blockChangePacket, iBlockData, 0); + private static final UnaryOperator blockChangeCloner = ProtocolUtils.shallowCloneGenerator(ClientboundBlockUpdatePacket.class); - private Object blockChangeHider(Player p, Object packet) { - switch (locationEvaluator.checkBlockPos(p, blockChangePosition.get(packet))) { + private ClientboundBlockUpdatePacket blockChangeHider(Player p, ClientboundBlockUpdatePacket packet) { + switch (locationEvaluator.checkBlockPos(p, packet.getPos())) { case SKIP: return packet; case CHECK: - if (!iBlockDataHidden((BlockState) blockChangeBlockData.get(packet))) { + if (!iBlockDataHidden(packet.blockState)) { return packet; } case HIDE: packet = blockChangeCloner.apply(packet); - blockChangeBlockData.set(packet, obfuscationTarget); + packet.blockState = (BlockState) obfuscationTarget; return packet; case HIDE_AIR: default: packet = blockChangeCloner.apply(packet); - blockChangeBlockData.set(packet, AIR); + packet.blockState = (BlockState) AIR; return packet; } } - private static final Class blockActionPacket = ClientboundBlockEventPacket.class; - private static final Reflection.Field blockActionPosition = Reflection.getField(blockActionPacket, blockPosition, 0); - - private Object blockActionHider(Player p, Object packet) { - if (locationEvaluator.checkBlockPos(p, blockActionPosition.get(packet)) == State.SKIP) { + private Object blockActionHider(Player p, ClientboundBlockEventPacket packet) { + if (locationEvaluator.checkBlockPos(p, packet.getPos()) == State.SKIP) { return packet; } return null; } - public static final Class tileEntityDataPacket = ClientboundBlockEntityDataPacket.class; - private static final Reflection.Field tileEntityDataPosition = Reflection.getField(tileEntityDataPacket, blockPosition, 0); - - private Object tileEntityDataHider(Player p, Object packet) { - switch (locationEvaluator.checkBlockPos(p, tileEntityDataPosition.get(packet))) { + private ClientboundBlockEntityDataPacket tileEntityDataHider(Player p, ClientboundBlockEntityDataPacket packet) { + switch (locationEvaluator.checkBlockPos(p, packet.getPos())) { case SKIP: return packet; case CHECK: - if (ProtocolWrapper.impl.unfilteredTileEntityDataAction(packet)) { + if (packet.getType() != BlockEntityType.SIGN) { return packet; } default: @@ -173,8 +159,8 @@ public class TechHider { return skipChunkSection(player, ProtocolUtils.posToChunk(x), ProtocolUtils.posToChunk(y), ProtocolUtils.posToChunk(z)) ? State.SKIP : State.CHECK; } - default State checkBlockPos(Player player, Object pos) { - return check(player, blockPositionX.get(pos), blockPositionY.get(pos), blockPositionZ.get(pos)); + default State checkBlockPos(Player player, Vec3i pos) { + return check(player, pos.getX(), pos.getY(), pos.getZ()); } default boolean blockPrecise(Player player, int x, int y, int z) { diff --git a/SpigotCore/SpigotCore_Main/src/spigotcore.accesswidener b/SpigotCore/SpigotCore_Main/src/spigotcore.accesswidener new file mode 100644 index 00000000..1fcaac48 --- /dev/null +++ b/SpigotCore/SpigotCore_Main/src/spigotcore.accesswidener @@ -0,0 +1,57 @@ +accessWidener v2 named + +# For TinyProtocol and CheckpointUtilsJ9 +accessible field net/minecraft/server/network/ServerConnectionListener channels Ljava/util/List; + +# For ErrorHandler +accessible field org/spigotmc/WatchdogThread instance Lorg/spigotmc/WatchdogThread; + +# For ResourceKey +accessible method net/minecraft/resources/ResourceKey (Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/resources/ResourceLocation;)V +accessible method net/minecraft/resources/ResourceLocation (Ljava/lang/String;Ljava/lang/String;)V + +# For SteamwarGameProfileRepository +accessible field net/minecraft/server/MinecraftServer services Lnet/minecraft/server/Services; +mutable field net/minecraft/server/MinecraftServer services Lnet/minecraft/server/Services; + +# REntity +accessible field net/minecraft/network/protocol/game/ClientboundAnimatePacket id I +mutable field net/minecraft/network/protocol/game/ClientboundAnimatePacket id I +accessible field net/minecraft/network/protocol/game/ClientboundAnimatePacket action I +mutable field net/minecraft/network/protocol/game/ClientboundAnimatePacket action I + +accessible field net/minecraft/network/protocol/game/ClientboundEntityEventPacket entityId I +mutable field net/minecraft/network/protocol/game/ClientboundEntityEventPacket entityId I +accessible field net/minecraft/network/protocol/game/ClientboundEntityEventPacket eventId B +mutable field net/minecraft/network/protocol/game/ClientboundEntityEventPacket eventId B + +accessible field net/minecraft/network/protocol/game/ClientboundRotateHeadPacket yHeadRot B +mutable field net/minecraft/network/protocol/game/ClientboundRotateHeadPacket yHeadRot B +## + TechHider +accessible field net/minecraft/network/protocol/game/ClientboundRotateHeadPacket entityId I +mutable field net/minecraft/network/protocol/game/ClientboundRotateHeadPacket entityId I + +# For ChunkHider +accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket chunkData Lnet/minecraft/network/protocol/game/ClientboundLevelChunkPacketData; +mutable field net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket chunkData Lnet/minecraft/network/protocol/game/ClientboundLevelChunkPacketData; + +accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData buffer [B +mutable field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData buffer [B +accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData blockEntitiesData Ljava/util/List; +mutable field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData blockEntitiesData Ljava/util/List; + +accessible class net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo +accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo type Lnet/minecraft/world/level/block/entity/BlockEntityType; +accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo packedXZ I +accessible field net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData$BlockEntityInfo y I + +# For TechHider +accessible field net/minecraft/network/protocol/game/ClientboundMoveEntityPacket entityId I +accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket sectionPos Lnet/minecraft/core/SectionPos; +accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket positions [S +mutable field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket positions [S +accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket states [Lnet/minecraft/world/level/block/state/BlockState; +mutable field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket states [Lnet/minecraft/world/level/block/state/BlockState; + +# For legacy/TechHider +mutable field net/minecraft/network/protocol/game/ClientboundBlockUpdatePacket blockState Lnet/minecraft/world/level/block/state/BlockState;