diff --git a/build.gradle.kts b/build.gradle.kts index 130a641..84023d5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,8 @@ import java.io.BufferedReader plugins { eclipse - kotlin("jvm") version "2.1.21" + kotlin("jvm") version "2.2.20" + id("io.papermc.paperweight.userdev") version "2.0.0-beta.18" id("com.diffplug.spotless") version "8.1.0" id("com.gradleup.shadow") version "8.3.9" } @@ -32,12 +33,17 @@ repositories { } dependencies { + paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT") - implementation("com.github.retrooper:packetevents-spigot:2.9.5") + implementation("com.github.retrooper:packetevents-spigot:2.11.1") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") } +paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.REOBF_PRODUCTION + tasks { + assemble { dependsOn(reobfJar) } build { dependsOn(spotlessApply) dependsOn(shadowJar) diff --git a/src/main/kotlin/net/trueog/antipierayog/AntiPieRay.kt b/src/main/kotlin/net/trueog/antipierayog/AntiPieRay.kt index b3d088a..1a19377 100644 --- a/src/main/kotlin/net/trueog/antipierayog/AntiPieRay.kt +++ b/src/main/kotlin/net/trueog/antipierayog/AntiPieRay.kt @@ -113,13 +113,5 @@ class AntiPieRay : JavaPlugin() { override fun onDisable() { Bukkit.getScheduler().cancelTasks(this) PacketEvents.getAPI().terminate() - - while (getActiveTasks() > 0) { - Thread.sleep(25) - } - } - - fun getActiveTasks(): Int { - return Bukkit.getScheduler().activeWorkers.count { it.owner == this } } } diff --git a/src/main/kotlin/net/trueog/antipierayog/BlockEntityHider.kt b/src/main/kotlin/net/trueog/antipierayog/BlockEntityHider.kt index b70abf1..89193fc 100644 --- a/src/main/kotlin/net/trueog/antipierayog/BlockEntityHider.kt +++ b/src/main/kotlin/net/trueog/antipierayog/BlockEntityHider.kt @@ -5,10 +5,14 @@ import java.util.concurrent.ConcurrentHashMap import kotlin.math.abs import kotlin.math.ceil import kotlin.math.min +import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel import org.bukkit.Bukkit import org.bukkit.Location import org.bukkit.Material import org.bukkit.World +import org.bukkit.block.Block +import org.bukkit.craftbukkit.v1_19_R3.CraftWorld import org.bukkit.entity.Player import org.bukkit.util.BlockIterator import org.bukkit.util.Vector @@ -85,6 +89,15 @@ class BlockEntityHider { Vector(-0.49, -0.49, -0.49), ) + val Block.typeFast: Material + get() { + val craftWorld = (world as CraftWorld).handle + val serverChunkCache = (craftWorld as ServerLevel).getChunkSource() + val chunk = serverChunkCache.getChunkAtIfLoadedMainThread(this.x shr 4, this.z shr 4) + val blockState = chunk.getBlockState(BlockPos(this.x, this.y, this.z)) + return blockState.bukkitMaterial + } + fun canSee(eye: Location, loc: Location): Set? { // Get the center val blockCenterLoc = loc.clone().add(0.5, 0.5, 0.5) @@ -125,7 +138,7 @@ class BlockEntityHider { if (hitBlock == loc.block) { break } - val hitBlockType = hitBlock.type + val hitBlockType = hitBlock.typeFast if (!isAir(hitBlockType) && !isLiquid(hitBlockType) && !isTransparent(hitBlockType)) { if (eyeOffset == Vector(0, 0, 0)) { blockingBlocks += hitBlock.location.toBlockPosition()