Skip to content

Commit

Permalink
🤷
Browse files Browse the repository at this point in the history
  • Loading branch information
roastpiece committed Mar 14, 2023
1 parent 72a85ab commit c78ed0f
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 63 deletions.
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.10.64'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'maven-publish'
id 'eclipse'
id 'idea'
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
}

sourceCompatibility = JavaVersion.VERSION_16
Expand Down Expand Up @@ -37,8 +37,12 @@ dependencies {
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
modImplementation "dev.emi:trinkets:${project.trinkets_version}"
modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_components_version}"
include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_components_version}"

// modImplementation "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_components_version}"
// include "io.github.onyxstudios.Cardinal-Components-API:cardinal-components-entity:${project.cardinal_components_version}"

modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components_version}"
include "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components_version}"

[
"com.teamwizardry.librarianlib:mosaic:${liblib_version}",
Expand Down
27 changes: 15 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

minecraft_version=1.17.1
yarn_mappings=1.17.1+build.65
loader_version=0.12.11
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.28
loader_version=0.14.17

mod_version=2.0.0-alpha.3

mod_version=2.0.0-alpha.3-1.19.2
archivesBaseName=hooked
release.curseforge.type=alpha
release.modrinth.type=ALPHA

fabric_version=0.45.0+1.17
fabric_kotlin_version=1.7.1+kotlin.1.6.10
liblib_version=5.0.0-alpha.11
trinkets_version=3.0.4
cardinal_components_version=3.0.1

#Fabric api
fabric_version=0.75.1+1.19.2
fabric_kotlin_version=1.9.1+kotlin.1.8.10
liblib_version=1.17-quilt-SNAPSHOT
trinkets_version=3.4.0
cardinal_components_version=5.0.2

mod.dependencies.fabricloader=>=0.11.6
mod.dependencies.minecraft=1.17.x
mod.dependencies.flk=>=1.7.1+kotlin.1.6.10
mod.dependencies.trinkets=>=3.0.4
mod.dependencies.minecraft=1.19.2
mod.dependencies.flk=>=1.9.1+kotlin.1.8.10
mod.dependencies.trinkets=>=3.4.0

mod.modmenu.hooked_name=Hooked
11 changes: 7 additions & 4 deletions src/main/kotlin/dev/thecodewarrior/hooked/Hooked.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents
import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder
import net.fabricmc.fabric.api.event.registry.RegistryAttribute
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
import net.fabricmc.fabric.api.resource.ResourceManagerHelper
import net.fabricmc.fabric.api.tag.TagFactory
import net.minecraft.client.gui.screen.Screen
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.network.PacketByteBuf
Expand All @@ -37,6 +37,7 @@ import net.minecraft.server.network.ServerPlayerEntity
import net.minecraft.sound.SoundEvent
import net.minecraft.stat.StatFormatter
import net.minecraft.stat.Stats
import net.minecraft.tag.TagKey
import net.minecraft.util.Identifier
import net.minecraft.util.registry.DefaultedRegistry
import net.minecraft.util.registry.Registry
Expand All @@ -59,7 +60,9 @@ object Hooked {
registerStats()
registerSounds()
registerNetworking()
ServerHookProcessor.registerEvents()
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register { player, _, _ ->
player.hookData().syncStatus.forceFullSyncToClient = true
}
Rules // static initializer registers the gamerule
Tags // static initializer registers tags
}
Expand Down Expand Up @@ -189,8 +192,8 @@ object Hooked {
}

object Tags {
val SOLID_BLOCKS = TagFactory.BLOCK.create(Identifier("hooked:solid_blocks"))
val IGNORE_BLOCKS = TagFactory.BLOCK.create(Identifier("hooked:ignore_blocks"))
val SOLID_BLOCKS = TagKey.of(Registry.BLOCK_KEY, Identifier("hooked:solid_blocks"))
val IGNORE_BLOCKS = TagKey.of(Registry.BLOCK_KEY, Identifier("hooked:ignore_blocks"))
}

object Components : EntityComponentInitializer {
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/dev/thecodewarrior/hooked/client/Keybinds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ object Keybinds {
var doubleJumpTimer = 0

fun tick(client: MinecraftClient) {
val jumpDown = Client.minecraft.options.keyJump.isPressed
val jumpDown = Client.minecraft.options.jumpKey.isPressed
val jumpPressed = jumpDown && !jumpWasDown
jumpWasDown = jumpDown

val player = Client.player ?: return
val data = player.hookData()

if(data.type != HookType.NONE) {
val sneakPressed = Client.minecraft.options.keySneak.isPressed
val sneakPressed = Client.minecraft.options.sneakKey.isPressed
if (FIRE.wasPressed()) {
ClientHookProcessor.fireHook(player, data, player.eyePos, player.pitch, player.yaw, sneakPressed)
while(FIRE.wasPressed()) { /* consume excess keypresses */ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ abstract class SimpleHookRenderer<C: HookPlayerController>(val type: HookType):

private fun loadModel(manager: ResourceManager): ReloadData {
var model = try {
manager.getResource(modelLocation).use {
ObjReader.read(it.inputStream)
manager.getResource(modelLocation).get().inputStream.use {
ObjReader.read(it)
}
} catch (e: IOException) {
Objs.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ abstract class HookPlayerController {
request.withBlockMode(Raycaster.BlockMode.COLLISION)
.withBlockOverride { state, _, _ ->
when {
Hooked.Tags.SOLID_BLOCKS.contains(state.block) -> VoxelShapes.fullCube()
Hooked.Tags.IGNORE_BLOCKS.contains(state.block) -> VoxelShapes.empty()
state.isIn(Hooked.Tags.SOLID_BLOCKS) -> VoxelShapes.fullCube()
state.isIn(Hooked.Tags.IGNORE_BLOCKS) -> VoxelShapes.empty()
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ object ServerHookProcessor: CommonHookProcessor() {
}
}

fun registerEvents() {
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register { player, _, _ ->
player.hookData().syncStatus.forceFullSyncToClient = true
}
}
// fun registerEvents() {
// ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register { player, _, _ ->
// player.hookData().syncStatus.forceFullSyncToClient = true
// }
// }

fun fireHook(
player: ServerPlayerEntity,
Expand Down
11 changes: 5 additions & 6 deletions src/main/kotlin/dev/thecodewarrior/hooked/item/HookItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import dev.thecodewarrior.hooked.capability.IHookItem
import dev.thecodewarrior.hooked.hook.HookType
import net.minecraft.client.item.TooltipContext
import net.minecraft.item.ItemStack
import net.minecraft.text.KeybindText
import net.minecraft.text.Text
import net.minecraft.text.TranslatableText
import net.minecraft.text.TranslatableTextContent
import net.minecraft.util.Formatting
import net.minecraft.world.World

Expand All @@ -18,15 +17,15 @@ class HookItem(settings: Settings, override val hookType: HookType): TrinketItem
tooltip: MutableList<Text>,
context: TooltipContext
) {
tooltip.add(TranslatableText("$translationKey.tip"))
tooltip.add(Text.translatable("$translationKey.tip"))
if (hasShiftDown()) {
val fireKeyName = KeybindText("key.hooked.fire").formatted(Formatting.BOLD)
val fireKeyName = Text.keybind("key.hooked.fire").formatted(Formatting.BOLD)
tooltip.addAll(hookType.controlLangKeys.map { key ->
TranslatableText(key, fireKeyName).formatted(Formatting.GRAY)
Text.translatable(key, fireKeyName).formatted(Formatting.GRAY)
})
} else {
tooltip.add(
TranslatableText("hooked.controller.universal.controls.collapsed").formatted(Formatting.GRAY)
Text.translatable("hooked.controller.universal.controls.collapsed").formatted(Formatting.GRAY)
)
}
super.appendTooltip(stack, world, tooltip, context)
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/dev/thecodewarrior/hooked/util/ClientUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ inline fun VertexConsumer.vertex(stack: MatrixStack, x: Number, y: Number, z: Nu
val xf = x.toFloat()
val yf = y.toFloat()
val zf = z.toFloat()
val matrix = mixinCast<IMatrix4f>(stack.peek().model)
val matrix = mixinCast<IMatrix4f>(stack.peek().positionMatrix)
return this.vertex(
matrix.transformX(xf, yf, zf).toDouble(),
matrix.transformY(xf, yf, zf).toDouble(),
Expand All @@ -37,7 +37,7 @@ fun VertexConsumer.vertex(stack: MatrixStack, v: Vec3d): VertexConsumer {
val xf = v.x.toFloat()
val yf = v.y.toFloat()
val zf = v.z.toFloat()
val matrix = mixinCast<IMatrix4f>(stack.peek().model)
val matrix = mixinCast<IMatrix4f>(stack.peek().positionMatrix)
return this.vertex(
matrix.transformX(xf, yf, zf).toDouble(),
matrix.transformY(xf, yf, zf).toDouble(),
Expand All @@ -50,7 +50,7 @@ inline fun VertexConsumer.normal(stack: MatrixStack, x: Number, y: Number, z: Nu
val xf = x.toFloat()
val yf = y.toFloat()
val zf = z.toFloat()
val matrix = mixinCast<IMatrix3f>(stack.peek().normal)
val matrix = mixinCast<IMatrix3f>(stack.peek().normalMatrix)
return this.normal(
matrix.transformX(xf, yf, zf),
matrix.transformY(xf, yf, zf),
Expand All @@ -63,7 +63,7 @@ fun VertexConsumer.normal(stack: MatrixStack, v: Vec3d): VertexConsumer {
val xf = v.x.toFloat()
val yf = v.y.toFloat()
val zf = v.z.toFloat()
val matrix = mixinCast<IMatrix3f>(stack.peek().normal)
val matrix = mixinCast<IMatrix3f>(stack.peek().normalMatrix)
return this.normal(
matrix.transformX(xf, yf, zf),
matrix.transformY(xf, yf, zf),
Expand Down
25 changes: 9 additions & 16 deletions src/main/kotlin/dev/thecodewarrior/hooked/util/JumpHeightUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.teamwizardry.librarianlib.core.util.vec
import net.minecraft.block.ShapeContext
import net.minecraft.entity.Entity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.util.collection.ReusableStream
import net.minecraft.util.function.BooleanBiFunction
import net.minecraft.util.math.Box
import net.minecraft.util.math.Vec3d
Expand All @@ -28,23 +27,21 @@ object JumpHeightUtil {
movement: Vec3d,
maxHeight: Double
): Vec3d {
val shapeContext = ShapeContext.of(player)
val voxelShape: VoxelShape = player.world.worldBorder.asVoxelShape()
val stream = if (VoxelShapes.matchesAnywhere(
val list: List<VoxelShape> = if (VoxelShapes.matchesAnywhere(
voxelShape,
VoxelShapes.cuboid(box.contract(1.0E-7)),
BooleanBiFunction.AND
)
) Stream.empty() else Stream.of(voxelShape)
val stream2: Stream<VoxelShape> = player.world.getEntityCollisions(player, box.stretch(movement), { true })
val reusableStream: ReusableStream<VoxelShape> = ReusableStream(Stream.concat(stream2, stream))
) emptyList() else listOf(voxelShape)
val list2: List<VoxelShape> = player.world.getEntityCollisions(player, box.stretch(movement))
val finalList: List<VoxelShape> = list + list2
val horizontal = if (movement.lengthSquared() == 0.0) movement else Entity.adjustMovementForCollisions(
player,
movement,
box,
player.world,
shapeContext,
reusableStream
finalList
)
val collidedX = movement.x != horizontal.x
val collidedZ = movement.z != horizontal.z
Expand All @@ -54,25 +51,22 @@ object JumpHeightUtil {
Vec3d(movement.x, maxHeight, movement.z),
box,
player.world,
shapeContext,
reusableStream
finalList
)
val ceiling = Entity.adjustMovementForCollisions(
player,
Vec3d(0.0, maxHeight, 0.0),
box.stretch(movement.x, 0.0, movement.z),
player.world,
shapeContext,
reusableStream
finalList
)
if (ceiling.y < maxHeight) {
val ceilingHorizontal = Entity.adjustMovementForCollisions(
player,
Vec3d(movement.x, 0.0, movement.z),
box.offset(ceiling),
player.world,
shapeContext,
reusableStream
finalList
).add(ceiling)
if (ceilingHorizontal.horizontalLengthSquared() > rising.horizontalLengthSquared()) {
rising = ceilingHorizontal
Expand All @@ -85,8 +79,7 @@ object JumpHeightUtil {
Vec3d(0.0, -rising.y + movement.y, 0.0),
box.offset(rising),
player.world,
shapeContext,
reusableStream
finalList
)
)
}
Expand Down
15 changes: 9 additions & 6 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
"main": [
{
"adapter": "kotlin",
"value": "dev.thecodewarrior.hooked.Hooked\$CommonInitializer"
"value": "dev.thecodewarrior.hooked.Hooked\u0024CommonInitializer"
}
],
"client": [
{
"adapter": "kotlin",
"value": "dev.thecodewarrior.hooked.Hooked\$ClientInitializer"
"value": "dev.thecodewarrior.hooked.Hooked\u0024ClientInitializer"
}
],
"cardinal-components": [
{
"adapter": "kotlin",
"value": "dev.thecodewarrior.hooked.Hooked\$Components"
"value": "dev.thecodewarrior.hooked.Hooked\u0024Components"
}
]
},
Expand All @@ -45,11 +45,14 @@

"depends": {
"fabric": "*",
"fabric-language-kotlin": ">=1.6.4+kotlin.1.5.30",
"minecraft": "1.17.x",
"fabric-language-kotlin": ">=1.9.1+kotlin.1.8.10",
"minecraft": "1.19.2",
"java": ">=16",
"liblib-core": ">=5.0.0-alpha.10",
"trinkets": "3.0.4",
"liblib-glitter": ">=5.0.0-alpha.10",
"liblib-etcetera": ">=5.0.0-alpha.10",
"liblib-mosaic": ">=5.0.0-alpha.10",
"trinkets": ">=3.4.0",
"fabric-key-binding-api-v1": "*"
},
"custom": {
Expand Down

0 comments on commit c78ed0f

Please sign in to comment.