mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-19 06:38:53 -05:00
Updated Vivecraft 1 final time with the new Listener System
This commit is contained in:
1 parent
56c3ff55ca
commit
74541c1bcb
5 files changed
+5
-31
No files matched your search
+3
-4
@@ -1,6 +1,7 @@
|
||||
package com.cobblemon.mod.common.integration.vivecraft
|
||||
|
||||
import net.minecraft.client.Minecraft
|
||||
import org.vivecraft.api.VRAPI
|
||||
import org.vivecraft.api.client.VRClientAPI
|
||||
import org.vivecraft.client_vr.ClientDataHolderVR
|
||||
|
||||
@@ -9,13 +10,11 @@ class CobblemonVRClient {
|
||||
PokeballSwingTracker(Minecraft.getInstance(), VRClient)
|
||||
|
||||
fun init() {
|
||||
VRClient.addClientRegistrationHandler { client ->
|
||||
client.registerTrackers(pokeballSwingTracker)
|
||||
|
||||
}
|
||||
VRAPI.instance().register(pokeballSwingTracker)
|
||||
}
|
||||
|
||||
companion object {
|
||||
val VRClient: VRClientAPI = VRClientAPI.instance()
|
||||
val VR: VRAPI = VRAPI.instance()
|
||||
}
|
||||
}
|
||||
+2
-27
@@ -5,42 +5,17 @@ import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
|
||||
import com.cobblemon.mod.common.net.messages.server.SendOutPokeballPacket
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.player.LocalPlayer
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import org.vivecraft.api.client.Tracker
|
||||
import org.vivecraft.api.client.VRClientAPI
|
||||
import org.vivecraft.api.client.tracker.swing.SwingContext
|
||||
import org.vivecraft.api.client.tracker.swing.SwingTracker
|
||||
import org.vivecraft.api.data.VRBodyPart
|
||||
import org.vivecraft.client_vr.gameplay.trackers.DebugRenderTracker
|
||||
import net.minecraft.world.phys.Vec3
|
||||
import org.vivecraft.api.client.tracker.swing.SwingSource
|
||||
import org.vivecraft.api.client.tracker.swing.SwingListener
|
||||
|
||||
class PokeballSwingTracker(
|
||||
private val minecraft: Minecraft,
|
||||
private val clientData: VRClientAPI
|
||||
) : SwingTracker, DebugRenderTracker {
|
||||
|
||||
private var swingSource: SwingSource? = null
|
||||
|
||||
override fun processType(): Tracker.ProcessType = Tracker.ProcessType.PER_TICK
|
||||
|
||||
override fun isActive(localPlayer: LocalPlayer?): Boolean = true
|
||||
|
||||
override fun activeProcess(localPlayer: LocalPlayer?) {
|
||||
val source = clientData.getTrackerSource(SwingSource::class.java)
|
||||
if (this.swingSource === source) return
|
||||
this.swingSource?.removeListener(this)
|
||||
this.swingSource = source
|
||||
this.swingSource?.addListener(this)
|
||||
}
|
||||
|
||||
override fun inactiveProcess(player: LocalPlayer?) {
|
||||
this.swingSource?.removeListener(this)
|
||||
this.swingSource = null
|
||||
}
|
||||
|
||||
override fun renderDebug() {}
|
||||
) : SwingListener {
|
||||
|
||||
private fun changeForVelocity(bodyPart: VRBodyPart, ticks: Int = 10): Vec3? {
|
||||
val history = clientData.historicalVRPoses ?: return null
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user