mirror of
https://gitlab.bixilon.de/bixilon/pixlyzer-physics.git
synced 2025-09-18 11:38:18 -04:00
elytra extractor
This commit is contained in:
parent
cf59097c28
commit
36ce9a4b84
@ -70,9 +70,10 @@ object PhysicsExtractor {
|
|||||||
// MixedFluidExtractor::class.java,
|
// MixedFluidExtractor::class.java,
|
||||||
|
|
||||||
// DamageExtractor::class.java,
|
// DamageExtractor::class.java,
|
||||||
VelocityFlatteningExtractor::class.java,
|
// VelocityFlatteningExtractor::class.java,
|
||||||
IceWalk::class.java,
|
// IceWalk::class.java,
|
||||||
AbilitiesExtractor::class.java,
|
// AbilitiesExtractor::class.java,
|
||||||
|
ElytraExtractor::class.java,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
package de.bixilon.pixlyzer.physics
|
package de.bixilon.pixlyzer.physics
|
||||||
|
|
||||||
|
import de.bixilon.kutil.cast.CastUtil.unsafeCast
|
||||||
|
import de.bixilon.pixlyzer.physics.tests.fluid.FluidUtil.addTags
|
||||||
import net.minecraft.block.Blocks
|
import net.minecraft.block.Blocks
|
||||||
|
import net.minecraft.block.FluidBlock
|
||||||
|
import net.minecraft.fluid.Fluids
|
||||||
import net.minecraft.tag.BlockTags
|
import net.minecraft.tag.BlockTags
|
||||||
|
import net.minecraft.tag.FluidTags
|
||||||
|
|
||||||
object PhysicsTags {
|
object PhysicsTags {
|
||||||
|
|
||||||
fun initialize() {
|
fun initialize() {
|
||||||
Blocks.SOUL_SAND.registryEntry.tags = setOf(BlockTags.SOUL_SPEED_BLOCKS)
|
Blocks.SOUL_SAND.registryEntry.tags = setOf(BlockTags.SOUL_SPEED_BLOCKS)
|
||||||
|
|
||||||
|
Blocks.WATER.unsafeCast<FluidBlock>().addTags(FluidTags.WATER)
|
||||||
|
Blocks.LAVA.unsafeCast<FluidBlock>().addTags(FluidTags.LAVA)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ class MinecraftPlayer(
|
|||||||
jump: Boolean = false,
|
jump: Boolean = false,
|
||||||
sneak: Boolean = false,
|
sneak: Boolean = false,
|
||||||
sprint: Boolean = false,
|
sprint: Boolean = false,
|
||||||
|
jumpNextTick: Boolean = false,
|
||||||
) {
|
) {
|
||||||
val input = CustomInput()
|
val input = CustomInput()
|
||||||
input.pressingForward = forwards
|
input.pressingForward = forwards
|
||||||
@ -67,6 +68,8 @@ class MinecraftPlayer(
|
|||||||
|
|
||||||
this.sprint.value = sprint
|
this.sprint.value = sprint
|
||||||
native.input = input
|
native.input = input
|
||||||
|
|
||||||
|
input.jumpNextTick = jumpNextTick
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAbilities(
|
fun setAbilities(
|
||||||
|
@ -10,7 +10,7 @@ import net.minecraft.world.dimension.DimensionType
|
|||||||
class MinecraftWorld(
|
class MinecraftWorld(
|
||||||
val level: ClientWorld,
|
val level: ClientWorld,
|
||||||
) {
|
) {
|
||||||
fun set(x: Int, y: Int, z: Int, value: BlockState?) {
|
operator fun set(x: Int, y: Int, z: Int, value: BlockState?) {
|
||||||
try {
|
try {
|
||||||
level.setBlockState(BlockPos(x, y, z), value)
|
level.setBlockState(BlockPos(x, y, z), value)
|
||||||
} catch (error: Throwable) {
|
} catch (error: Throwable) {
|
||||||
|
@ -3,11 +3,12 @@ package de.bixilon.pixlyzer.physics.input
|
|||||||
import net.minecraft.client.input.Input
|
import net.minecraft.client.input.Input
|
||||||
import net.minecraft.client.input.KeyboardInput
|
import net.minecraft.client.input.KeyboardInput
|
||||||
|
|
||||||
class CustomInput : Input() {
|
class CustomInput() : Input() {
|
||||||
|
var jumpNextTick: Boolean = false
|
||||||
|
|
||||||
fun tick(slowDown: Boolean) {
|
fun tick(slowDown: Boolean) {
|
||||||
tick(slowDown, 0.3f)
|
tick(slowDown, 0.3f)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getMovementMultiplier(positive: Boolean, negative: Boolean): Float {
|
fun getMovementMultiplier(positive: Boolean, negative: Boolean): Float {
|
||||||
return if (positive == negative) {
|
return if (positive == negative) {
|
||||||
@ -24,5 +25,9 @@ class CustomInput : Input() {
|
|||||||
movementSideways *= multiplier
|
movementSideways *= multiplier
|
||||||
movementForward *= multiplier
|
movementForward *= multiplier
|
||||||
}
|
}
|
||||||
|
if (jumpNextTick) {
|
||||||
|
jumping = true
|
||||||
|
jumpNextTick = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,113 @@
|
|||||||
|
package de.bixilon.pixlyzer.physics.tests
|
||||||
|
|
||||||
|
import net.minecraft.block.Blocks
|
||||||
|
import net.minecraft.entity.EquipmentSlot
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraft.item.Items
|
||||||
|
|
||||||
|
class ElytraExtractor : AbstractExtractor() {
|
||||||
|
|
||||||
|
private fun equip() {
|
||||||
|
val item = ItemStack(Items.ELYTRA)
|
||||||
|
player.native.equipStack(EquipmentSlot.CHEST, item)
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraStartFly() {
|
||||||
|
player.teleport(17.0, 9.5, 8.0)
|
||||||
|
equip()
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(1)
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraFlyStraight() {
|
||||||
|
player.teleport(0.0, 30.5, 0.0)
|
||||||
|
player.rotate(0.0, 10.0)
|
||||||
|
equip()
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(15)
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraFlyUp() {
|
||||||
|
player.teleport(0.0, 30.5, 0.0)
|
||||||
|
equip()
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(1)
|
||||||
|
player.setVelocity(0.0, 0.0, 3.0)
|
||||||
|
player.rotate(0.0, -10.0)
|
||||||
|
player.tick(5)
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraFlyRotated() {
|
||||||
|
player.teleport(0.0, 30.5, 0.0)
|
||||||
|
equip()
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(1)
|
||||||
|
|
||||||
|
for (x in 0..100) {
|
||||||
|
player.tick()
|
||||||
|
player.rotate(kotlin.math.sin(x / Math.PI / 100.0) * 400.0, 0.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraWater() {
|
||||||
|
player.teleport(0.0, 31.8, 0.0)
|
||||||
|
equip()
|
||||||
|
world.fill(-3, 30, -3, 3, 33, 3, Blocks.WATER.defaultState)
|
||||||
|
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(5)
|
||||||
|
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraLava() {
|
||||||
|
player.teleport(0.0, 31.8, 0.0)
|
||||||
|
equip()
|
||||||
|
world.fill(-3, 30, -3, 3, 33, 3, Blocks.LAVA.defaultState)
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(5)
|
||||||
|
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraLevitation() {
|
||||||
|
player.teleport(0.0, 30.8, 0.0)
|
||||||
|
player.applyLevitation(1)
|
||||||
|
equip()
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(10)
|
||||||
|
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExtractorMethod
|
||||||
|
fun elytraSlowFalling() {
|
||||||
|
player.teleport(0.0, 30.8, 0.0)
|
||||||
|
player.applySlowFalling()
|
||||||
|
equip()
|
||||||
|
player.tick(3)
|
||||||
|
player.setKeys(jumpNextTick = true)
|
||||||
|
player.tick(10)
|
||||||
|
|
||||||
|
storeMovement()
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,7 @@ import de.bixilon.pixlyzer.physics.tests.ExtractorMethod
|
|||||||
import net.minecraft.block.Blocks
|
import net.minecraft.block.Blocks
|
||||||
import net.minecraft.tag.FluidTags
|
import net.minecraft.tag.FluidTags
|
||||||
|
|
||||||
class LavaStillExtractor : StillFluidExtractor(Blocks.LAVA.unsafeCast(), FluidTags.LAVA) {
|
class LavaStillExtractor : StillFluidExtractor(Blocks.LAVA.unsafeCast()) {
|
||||||
|
|
||||||
@ExtractorMethod
|
@ExtractorMethod
|
||||||
fun lavaStillLanding1() {
|
fun lavaStillLanding1() {
|
||||||
|
@ -10,12 +10,8 @@ import net.minecraft.tag.TagKey
|
|||||||
|
|
||||||
abstract class StillFluidExtractor(
|
abstract class StillFluidExtractor(
|
||||||
protected val fluid: FluidBlock,
|
protected val fluid: FluidBlock,
|
||||||
protected val tag: TagKey<Fluid>,
|
|
||||||
) : AbstractExtractor() {
|
|
||||||
|
|
||||||
init {
|
) : AbstractExtractor() {
|
||||||
fluid.addTags(tag)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun walking() {
|
protected fun walking() {
|
||||||
world.fill(-10, 16, -10, 20, 16, 20, fluid.withLevel(0))
|
world.fill(-10, 16, -10, 20, 16, 20, fluid.withLevel(0))
|
||||||
|
@ -5,7 +5,7 @@ import de.bixilon.pixlyzer.physics.tests.ExtractorMethod
|
|||||||
import net.minecraft.block.Blocks
|
import net.minecraft.block.Blocks
|
||||||
import net.minecraft.tag.FluidTags
|
import net.minecraft.tag.FluidTags
|
||||||
|
|
||||||
class WaterStillExtractor : StillFluidExtractor(Blocks.WATER.unsafeCast(), FluidTags.WATER) {
|
class WaterStillExtractor : StillFluidExtractor(Blocks.WATER.unsafeCast()) {
|
||||||
|
|
||||||
@ExtractorMethod
|
@ExtractorMethod
|
||||||
fun waterStillLanding1() {
|
fun waterStillLanding1() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user