refactor: DoubleJumpComponent to track usage and reset on landing, and adjust max tiers for DoubleJump, Glider, and Grappling items.
This commit is contained in:
parent
790e2f446c
commit
03080fbd48
35
.kotlin/errors/errors-1765457724573.log
Normal file
35
.kotlin/errors/errors-1765457724573.log
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
kotlin version: 2.2.21
|
||||||
|
error message: Incremental compilation failed: /home/nixos/projects/minecraft/crafters-toolbox/components/plugins/hcu-items/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin (No such file or directory)
|
||||||
|
java.io.FileNotFoundException: /home/nixos/projects/minecraft/crafters-toolbox/components/plugins/hcu-items/build/kotlin/compileKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin (No such file or directory)
|
||||||
|
at java.base/java.io.FileInputStream.open0(Native Method)
|
||||||
|
at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
|
||||||
|
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:152)
|
||||||
|
at org.jetbrains.kotlin.incremental.storage.ExternalizersKt.loadFromFile(externalizers.kt:184)
|
||||||
|
at org.jetbrains.kotlin.incremental.snapshots.LazyClasspathSnapshot.getSavedShrunkClasspathAgainstPreviousLookups(LazyClasspathSnapshot.kt:86)
|
||||||
|
at org.jetbrains.kotlin.incremental.classpathDiff.ClasspathSnapshotShrinkerKt.shrinkAndSaveClasspathSnapshot(ClasspathSnapshotShrinker.kt:267)
|
||||||
|
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.performWorkAfterCompilation(IncrementalJvmCompilerRunner.kt:76)
|
||||||
|
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.performWorkAfterCompilation(IncrementalJvmCompilerRunner.kt:23)
|
||||||
|
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:418)
|
||||||
|
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally$lambda$0$compile(IncrementalCompilerRunner.kt:249)
|
||||||
|
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.tryCompileIncrementally(IncrementalCompilerRunner.kt:267)
|
||||||
|
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:119)
|
||||||
|
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:684)
|
||||||
|
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:94)
|
||||||
|
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1810)
|
||||||
|
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
|
||||||
|
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
|
||||||
|
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
|
||||||
|
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
|
||||||
|
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
|
||||||
|
at java.base/java.security.AccessController.doPrivileged(AccessController.java:714)
|
||||||
|
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
|
||||||
|
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:598)
|
||||||
|
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:844)
|
||||||
|
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:721)
|
||||||
|
at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
|
||||||
|
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:720)
|
||||||
|
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
|
||||||
|
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:1583)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,15 +16,22 @@ import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.entity.EntityToggleGlideEvent
|
import org.bukkit.event.entity.EntityToggleGlideEvent
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.util.Vector
|
import org.bukkit.util.Vector
|
||||||
|
import java.util.UUID
|
||||||
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
|
||||||
class DoubleJumpComponent(private val plugin: App) : AbstractComponent(plugin, "double_jump_component"), EquippableComponent {
|
class DoubleJumpComponent(private val plugin: App) : AbstractComponent(plugin, "double_jump_component"), EquippableComponent {
|
||||||
|
|
||||||
override val displayName: String = "Double Jump"
|
override val displayName: String = "Double Jump"
|
||||||
override val maxTier: Int = 3
|
override val maxTier: Int = 1
|
||||||
|
|
||||||
override val dataComponentDependencies: List<DataComponentType.NonValued>
|
override val dataComponentDependencies: List<DataComponentType.NonValued>
|
||||||
get() = listOf(DataComponentTypes.GLIDER)
|
get() = listOf(DataComponentTypes.GLIDER)
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
// Track players who have used their double jump (GLIDER is removed)
|
||||||
|
private val usedDoubleJump = ConcurrentHashMap.newKeySet<UUID>()
|
||||||
|
}
|
||||||
|
|
||||||
override fun apply(item: ItemStack, tier: Tier?) {
|
override fun apply(item: ItemStack, tier: Tier?) {
|
||||||
if (isBoots(item.type)) {
|
if (isBoots(item.type)) {
|
||||||
super.apply(item, tier)
|
super.apply(item, tier)
|
||||||
|
|
@ -32,33 +39,57 @@ class DoubleJumpComponent(private val plugin: App) : AbstractComponent(plugin, "
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isBoots(material: Material): Boolean {
|
private fun isBoots(material: Material): Boolean {
|
||||||
// Only apply to boots
|
|
||||||
return material.name.endsWith("_BOOTS")
|
return material.name.endsWith("_BOOTS")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
override fun onTick(player: Player, item: ItemStack) {
|
override fun onTick(player: Player, item: ItemStack) {
|
||||||
// No custom tick login currently
|
// Ensure GLIDER is present if this component is on the item
|
||||||
|
// This handles the case where equipment is removed/re-equipped while GLIDER was off
|
||||||
|
if (!item.hasData(DataComponentTypes.GLIDER) && !usedDoubleJump.contains(player.uniqueId)) {
|
||||||
|
item.setData(DataComponentTypes.GLIDER)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset double jump when player lands on ground
|
||||||
|
if (player.isOnGround && usedDoubleJump.contains(player.uniqueId)) {
|
||||||
|
usedDoubleJump.remove(player.uniqueId)
|
||||||
|
|
||||||
|
// Re-add GLIDER component
|
||||||
|
if (!item.hasData(DataComponentTypes.GLIDER)) {
|
||||||
|
item.setData(DataComponentTypes.GLIDER)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onToggleGlide(player: Player, item: ItemStack, event: EntityToggleGlideEvent) {
|
override fun onToggleGlide(player: Player, item: ItemStack, event: EntityToggleGlideEvent) {
|
||||||
if (player.gameMode == GameMode.CREATIVE || player.gameMode == GameMode.SPECTATOR) return
|
if (player.gameMode == GameMode.CREATIVE || player.gameMode == GameMode.SPECTATOR) return
|
||||||
|
|
||||||
// When user initiates gliding (pressing Jump in air with Elytra/Glider capability)
|
// Only handle glide start events
|
||||||
// event.isGliding will be true.
|
if (!event.isGliding) return
|
||||||
if (event.isGliding) {
|
|
||||||
// Cancel the glide start
|
|
||||||
event.isCancelled = true
|
|
||||||
|
|
||||||
// Execute Double Jump
|
// If player has already used double jump, don't cancel - let them glide normally
|
||||||
handleDoubleJump(player, item)
|
// (though GLIDER should be removed, so this shouldn't fire anyway)
|
||||||
|
if (usedDoubleJump.contains(player.uniqueId)) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cancel the glide start
|
||||||
|
event.isCancelled = true
|
||||||
|
|
||||||
|
// Mark as used
|
||||||
|
usedDoubleJump.add(player.uniqueId)
|
||||||
|
|
||||||
|
// Execute Double Jump
|
||||||
|
handleDoubleJump(player, item)
|
||||||
|
|
||||||
|
// Remove GLIDER component to prevent further glide triggers
|
||||||
|
item.unsetData(DataComponentTypes.GLIDER)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDoubleJump(player: Player, item: ItemStack) {
|
private fun handleDoubleJump(player: Player, item: ItemStack) {
|
||||||
val tier = getTier(item) ?: Tier.ONE
|
val tier = getTier(item) ?: Tier.ONE
|
||||||
|
|
||||||
// Physics Calculation
|
// Physics Calculation
|
||||||
// Vector: Up + Forward direction
|
|
||||||
val direction = player.location.direction.clone().setY(0).normalize()
|
val direction = player.location.direction.clone().setY(0).normalize()
|
||||||
val currentVelocity = player.velocity
|
val currentVelocity = player.velocity
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import kotlin.math.pow
|
||||||
class GliderComponent(private val plugin: App) : AbstractComponent(plugin, "glider_component"), EquippableComponent {
|
class GliderComponent(private val plugin: App) : AbstractComponent(plugin, "glider_component"), EquippableComponent {
|
||||||
|
|
||||||
override val displayName: String = "Glider"
|
override val displayName: String = "Glider"
|
||||||
override val maxTier: Int = 10
|
override val maxTier: Int = 3
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val activeGliders = ConcurrentHashMap<UUID, GliderState>()
|
val activeGliders = ConcurrentHashMap<UUID, GliderState>()
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
class GrapplingItem : AbstractItem("grappling_hook") {
|
class GrapplingItem : AbstractItem("grappling_hook") {
|
||||||
|
|
||||||
|
override val maxTier: Int = 5
|
||||||
|
|
||||||
override fun buildItem(tier: Tier): ItemStack {
|
override fun buildItem(tier: Tier): ItemStack {
|
||||||
val item = ItemStack(Material.FISHING_ROD)
|
val item = ItemStack(Material.FISHING_ROD)
|
||||||
val meta = item.itemMeta ?: return item
|
val meta = item.itemMeta ?: return item
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user