mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-10-20 14:16:26 -04:00
testing
This commit is contained in:
+51
-3
@@ -17,6 +17,7 @@ import com.cobblemon.mod.common.client.render.models.blockbench.PoseableEntitySt
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.additives.EarBounceAdditive
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.animation.StatefulAnimation
|
||||
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPoseableModel
|
||||
import com.cobblemon.mod.common.client.render.pokemon.PokemonRenderer.Companion.ease
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import net.minecraft.client.MinecraftClient
|
||||
@@ -24,10 +25,12 @@ import java.lang.Float.min
|
||||
import kotlin.math.abs
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.data.TrackedData
|
||||
import net.minecraft.particle.ParticleTypes
|
||||
import net.minecraft.sound.SoundCategory
|
||||
import net.minecraft.sound.SoundEvent
|
||||
import net.minecraft.util.Hand
|
||||
import net.minecraft.util.Identifier
|
||||
import net.minecraft.util.math.RotationAxis
|
||||
import net.minecraft.util.math.Vec3d
|
||||
import org.joml.Vector3f
|
||||
|
||||
@@ -55,6 +58,7 @@ class PokemonClientDelegate : PoseableEntityState<PokemonEntity>(), PokemonSideD
|
||||
var ballOffset = 0f
|
||||
var ballRotOffset = 0f
|
||||
var sendOutPosition: Vec3d? = null
|
||||
var sendOutOffset: Vec3d? = null
|
||||
|
||||
val secondsSinceBeamEffectStarted: Float
|
||||
get() = (System.currentTimeMillis() - beamStartTime) / 1000F
|
||||
@@ -94,16 +98,60 @@ class PokemonClientDelegate : PoseableEntityState<PokemonEntity>(), PokemonSideD
|
||||
// Scaling up out of pokeball
|
||||
entityScaleModifier = 0F
|
||||
beamStartTime = System.currentTimeMillis()
|
||||
ballStartTime = System.currentTimeMillis()
|
||||
currentEntity.isInvisible = true
|
||||
after(seconds = BEAM_EXTEND_TIME) {
|
||||
lerp(BEAM_SHRINK_TIME) { entityScaleModifier = it }
|
||||
currentEntity.isInvisible = false
|
||||
ballDone = false
|
||||
var soundPos = currentEntity.pos
|
||||
currentEntity.pokemon.getOwnerUUID()?.let{
|
||||
currentEntity.world.getPlayerByUuid(it)?.let {
|
||||
val offset = it.pos.subtract(currentEntity.pos.add(0.0, 2.0 - (ballOffset.toDouble()/10f), 0.0)).normalize().multiply(-ease(ballOffset.toDouble()))
|
||||
with(it.pos.subtract(currentEntity.pos)) {
|
||||
var newOffset = offset.multiply(2.0)
|
||||
// the further away the source position is, the smaller the newOffset should be. Max distance is 20 blocks
|
||||
val distance = it.pos.distanceTo(currentEntity.pos)
|
||||
newOffset = newOffset.multiply((distance / 10.0) * 3)
|
||||
soundPos = currentEntity.pos.add(newOffset)
|
||||
}
|
||||
it.swingHand(it.activeHand ?: Hand.MAIN_HAND)
|
||||
}
|
||||
}
|
||||
lerp(POKEBALL_AIR_TIME) { ballOffset = it }
|
||||
ballRotOffset = ((Math.random()) * currentEntity.world.random.nextBetween(-15, 15)).toFloat()
|
||||
after(seconds = POKEBALL_AIR_TIME){
|
||||
beamStartTime = System.currentTimeMillis()
|
||||
ballDone = true
|
||||
val client = MinecraftClient.getInstance()
|
||||
if (client.soundManager.get(CobblemonSounds.POKE_BALL_OPEN.id) != null) {
|
||||
currentEntity.owner?.let {
|
||||
client.world?.playSound(client.player, soundPos.x, soundPos.y, soundPos.z, SoundEvent.of(CobblemonSounds.POKE_BALL_OPEN.id), SoundCategory.PLAYERS, 1f, 1f)
|
||||
/// create end rod particles in a 0.1 radius around the soundPos with a count of 50 and a random velocity of 0.1
|
||||
sendOutPosition?.let{
|
||||
val newPos = it.add(sendOutOffset)
|
||||
for(i in 0..50) {
|
||||
client.particleManager.addParticle(ParticleTypes.END_ROD, newPos!!.x + (Math.random() * 0.1) - 0.05, newPos!!.y + (Math.random() * 0.1) - 0.05, newPos!!.z + (Math.random() * 0.1) - 0.05,
|
||||
Math.random() * 0.1 - 0.05, Math.random() * 0.1 - 0.05, Math.random() * 0.1 - 0.05)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
after(seconds = BEAM_EXTEND_TIME) {
|
||||
lerp(BEAM_SHRINK_TIME) { entityScaleModifier = it }
|
||||
currentEntity.isInvisible = false
|
||||
after(seconds = POKEBALL_AIR_TIME*2){
|
||||
ballOffset = 0f
|
||||
ballRotOffset = 0f
|
||||
sendOutPosition = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
// Scaling down into pokeball
|
||||
entityScaleModifier = 1F
|
||||
beamStartTime = System.currentTimeMillis()
|
||||
ballOffset = 0f
|
||||
ballRotOffset = 0f
|
||||
sendOutPosition = null
|
||||
after(seconds = BEAM_EXTEND_TIME) {
|
||||
lerp(BEAM_SHRINK_TIME) {
|
||||
entityScaleModifier = (1 - it)
|
||||
|
||||
+15
-13
@@ -58,6 +58,7 @@ import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.tan
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class PokemonRenderer(
|
||||
context: EntityRendererFactory.Context
|
||||
@@ -71,6 +72,9 @@ class PokemonRenderer(
|
||||
|
||||
val recallBeamColour = Vector4f(1F, 0.1F, 0.1F, 1F)
|
||||
val sendOutBeamColour = Vector4f(0.85F, 0.85F, 1F, 0.5F)
|
||||
fun ease(x: Double): Double {
|
||||
return if (x < 0.5) 4 * x * x * x else 1 - (-2 * x + 2).pow(3) / 2
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTexture(entity: PokemonEntity): Identifier {
|
||||
@@ -128,22 +132,22 @@ class PokemonRenderer(
|
||||
} else if(beamMode == 1) {
|
||||
beamSourcePosition = clientDelegate.sendOutPosition!!
|
||||
}
|
||||
// get the direction from the source position to the entity, then multiply it by the offset
|
||||
val offset = beamSourcePosition.subtract(entity.pos.add(0.0, 2.0 - (clientDelegate.ballOffset.toDouble()/10f), 0.0)).normalize().multiply(-ease(clientDelegate.ballOffset.toDouble()))
|
||||
val offset = beamSourcePosition.subtract(entity.pos.add(0.0, 2.0 - ((clientDelegate.ballOffset.toDouble())/10f), 0.0)).normalize().multiply(-ease(clientDelegate.ballOffset.toDouble()))
|
||||
var anglePitch by Delegates.notNull<Double>()
|
||||
with(beamSourcePosition.subtract(entity.pos)) {
|
||||
var newOffset = offset.multiply(2.0)
|
||||
// the further away the source position is, the smaller the newOffset should be. Max distance is 20 blocks
|
||||
val distance = beamSourcePosition.distanceTo(entity.pos)
|
||||
newOffset = newOffset.multiply((distance / 10.0) * 3)
|
||||
val dir = this.add(newOffset).normalize()
|
||||
anglePitch = MathHelper.atan2(dir.y, Math.sqrt(dir.x * dir.x + dir.z * dir.z))
|
||||
clientDelegate.sendOutOffset = newOffset
|
||||
poseMatrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees((clientDelegate.ballRotOffset * clientDelegate.ballOffset.toDouble()).toFloat()))
|
||||
poseMatrix.translate(x+newOffset.x, y+newOffset.y, z+newOffset.z)
|
||||
}
|
||||
poseMatrix.push()
|
||||
// rotate ball to face dir
|
||||
val dir = beamSourcePosition.subtract(entity.pos.add(0.0, 2.0 - (clientDelegate.ballOffset.toDouble()/10f), 0.0)).normalize()
|
||||
val angle = MathHelper.atan2(dir.z, dir.x) - PI / 2
|
||||
poseMatrix.multiply(RotationAxis.POSITIVE_Y.rotation(-angle.toFloat()))
|
||||
poseMatrix.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180f))
|
||||
poseMatrix.multiply(RotationAxis.POSITIVE_Y.rotation(-angle.toFloat() + (180 * Math.PI / 180).toFloat()))
|
||||
poseMatrix.multiply(RotationAxis.POSITIVE_X.rotationDegrees(max(-65f, min(65f, (anglePitch.toFloat() * 1.5f) * 180f / PI))))
|
||||
drawPokeBall(
|
||||
ClientBallDisplay(entity.pokemon.caughtBall, setOf()),
|
||||
poseMatrix,
|
||||
@@ -151,11 +155,10 @@ class PokemonRenderer(
|
||||
partialTicks = partialTicks,
|
||||
buff = buffer,
|
||||
packedLight = packedLight,
|
||||
ball = CobblemonClient.storage.myParty.firstOrNull { it?.uuid == entity.pokemon.uuid }?.caughtBall ?: entity.pokemon.caughtBall
|
||||
ball = CobblemonClient.storage.myParty.firstOrNull { it?.uuid == entity.pokemon.uuid }?.caughtBall ?: clientDelegate.currentEntity.pokemon.caughtBall
|
||||
)
|
||||
poseMatrix.pop()
|
||||
poseMatrix.pop()
|
||||
if(clientDelegate.ballDone){
|
||||
if(clientDelegate.ballDone || beamMode == 2) {
|
||||
renderBeam(poseMatrix, partialTicks, entity, phaseTarget, lightColour, buffer, offset)
|
||||
}
|
||||
}
|
||||
@@ -404,9 +407,7 @@ class PokemonRenderer(
|
||||
}
|
||||
}
|
||||
|
||||
fun ease(x: Double): Double {
|
||||
return if (x < 0.5) 4 * x * x * x else 1 - (-2 * x + 2).pow(3) / 2
|
||||
}
|
||||
|
||||
private fun drawPokeBall(
|
||||
state: ClientBallDisplay,
|
||||
matrixStack: MatrixStack,
|
||||
@@ -429,6 +430,7 @@ class PokemonRenderer(
|
||||
matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(Math.lerp(0F, 1080F, scale)))
|
||||
}
|
||||
model.setupAnimStateful(null, state, 0F, 0F, 0F, 0F, 0F)
|
||||
model.animateModel(null, 0f, 0F, 0F)
|
||||
val buffer = ItemRenderer.getDirectItemGlintConsumer(buff, model.getLayer(texture), false, false)
|
||||
matrixStack.scale(scale, scale, scale)
|
||||
model.render(matrixStack, buffer, packedLight, OverlayTexture.DEFAULT_UV, 1F, 1F, 1F, 1F)
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"format_version": "1.10.0",
|
||||
"particle_effect": {
|
||||
"description": {
|
||||
"identifier": "cobblemon:capturesparks",
|
||||
"basic_render_parameters": {
|
||||
"material": "particles_alpha",
|
||||
"texture": "textures/particles/capturesparks"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"minecraft:emitter_rate_instant": {
|
||||
"num_particles": 10
|
||||
},
|
||||
"minecraft:emitter_lifetime_once": {
|
||||
"active_time": 1
|
||||
},
|
||||
"minecraft:emitter_shape_sphere": {
|
||||
"direction": ["math.random(-10,10)", "math.random(0,8)*2+1", "math.random(-10,10)"]
|
||||
},
|
||||
"minecraft:particle_lifetime_expression": {
|
||||
"max_lifetime": 1
|
||||
},
|
||||
"minecraft:particle_initial_speed": "math.random(2,6)*0.025",
|
||||
"minecraft:particle_motion_dynamic": {
|
||||
"linear_acceleration": [0, -3, 0],
|
||||
"linear_drag_coefficient": 3.5
|
||||
},
|
||||
"minecraft:particle_appearance_billboard": {
|
||||
"size": [0.1, 0.1],
|
||||
"facing_camera_mode": "rotate_xyz",
|
||||
"uv": {
|
||||
"texture_width": 112,
|
||||
"texture_height": 8,
|
||||
"flipbook": {
|
||||
"base_UV": [0, 0],
|
||||
"size_UV": [8, 8],
|
||||
"step_UV": [8, 0],
|
||||
"frames_per_second": 15,
|
||||
"max_frame": 14
|
||||
}
|
||||
}
|
||||
},
|
||||
"minecraft:particle_appearance_tinting": {
|
||||
"color": {
|
||||
"interpolant": "v.particle_age / v.particle_lifetime",
|
||||
"gradient": {
|
||||
"0.11": "#FFFFFCB2",
|
||||
"0.22": "#FFFFFFFF",
|
||||
"0.53": "#FF6196FF"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"format_version": "1.10.0",
|
||||
"particle_effect": {
|
||||
"description": {
|
||||
"identifier": "cobblemon:capturestar",
|
||||
"basic_render_parameters": {
|
||||
"material": "particles_alpha",
|
||||
"texture": "textures/particles/capturestar"
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"minecraft:emitter_rate_instant": {
|
||||
"num_particles": 5
|
||||
},
|
||||
"minecraft:emitter_lifetime_once": {
|
||||
"active_time": 1
|
||||
},
|
||||
"minecraft:emitter_shape_sphere": {
|
||||
"direction": ["math.random(-1,1)*5", "math.random(0.5,2)*3+1", "math.random(-10,10)"]
|
||||
},
|
||||
"minecraft:particle_lifetime_expression": {
|
||||
"max_lifetime": 1
|
||||
},
|
||||
"minecraft:particle_initial_spin": {
|
||||
"rotation": "math.random(0,359)",
|
||||
"rotation_rate": 6
|
||||
},
|
||||
"minecraft:particle_initial_speed": "math.random(3,5)*0.045",
|
||||
"minecraft:particle_motion_dynamic": {
|
||||
"linear_acceleration": [0, -0.5, 0],
|
||||
"linear_drag_coefficient": 4
|
||||
},
|
||||
"minecraft:particle_appearance_billboard": {
|
||||
"size": [0.175, 0.175],
|
||||
"facing_camera_mode": "rotate_xyz",
|
||||
"uv": {
|
||||
"texture_width": 112,
|
||||
"texture_height": 8,
|
||||
"flipbook": {
|
||||
"base_UV": [0, 0],
|
||||
"size_UV": [8, 8],
|
||||
"step_UV": [8, 0],
|
||||
"frames_per_second": 15,
|
||||
"max_frame": 14
|
||||
}
|
||||
}
|
||||
},
|
||||
"minecraft:particle_appearance_tinting": {
|
||||
"color": [1, 1, 1, 1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
"cobblemon:sleep_zzz",
|
||||
"cobblemon:bubble",
|
||||
"cobblemon:confetti",
|
||||
"cobblemon:cherry_petal"
|
||||
"cobblemon:cherry_petal",
|
||||
"cobblemon:capturesparks",
|
||||
"cobblemon:capturestar"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
|
||||
# This is required to provide enough memory for the Minecraft decompilation process.
|
||||
org.gradle.jvmargs=-Xmx6G
|
||||
org.gradle.jvmargs=-Xmx8G
|
||||
org.gradle.daemon=false
|
||||
org.gradle.parallel=true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user