Skip to content

1.19.2 Support #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 1.17-quilt
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 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 @@ -32,13 +32,17 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modCompileOnly files("lib/iris-and-sodium-mc1.17-1.1.2+build.9.jar")
modCompileOnly files("lib/iris-mc1.19.2-1.5.2.jar")

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
Original file line number Diff line number Diff line change
@@ -1,41 +1,36 @@
package dev.thecodewarrior.hooked.mixin;

import com.teamwizardry.librarianlib.core.util.Client;
import dev.thecodewarrior.hooked.client.HookRenderManager;
import net.coderbot.iris.mixin.WorldRendererAccessor;
import net.minecraft.client.MinecraftClient;
import net.coderbot.iris.pipeline.ShadowRenderer;
import net.minecraft.client.render.BufferBuilderStorage;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(targets = "net.coderbot.iris.pipeline.ShadowRenderer")
@Mixin(ShadowRenderer.class)
public class IrisShadowRendererMixin {
@Shadow @Final private BufferBuilderStorage buffers;

@Inject(
method = "renderShadows",
method = "renderBlockEntities",
at = @At(
value = "INVOKE_STRING",
target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",
target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V",
args = {"ldc=build blockentities"}
),
locals = LocalCapture.CAPTURE_FAILSOFT
)
private void hooked$renderEntities(
WorldRendererAccessor worldRenderer, Camera playerCamera,
CallbackInfo ci,
MinecraftClient client, MatrixStack modelView
VertexConsumerProvider.Immediate par1, MatrixStack modelView, double cameraX, double cameraY, double cameraZ, float tickDelta, boolean hasEntityFrustum, CallbackInfoReturnable<Integer> cir
) {
var cameraPos = client.gameRenderer.getCamera().getPos();
modelView.translate(-cameraPos.getX(), -cameraPos.getY(), -cameraPos.getZ());
HookRenderManager.INSTANCE.renderHooks(modelView, Client.getMinecraft().getTickDelta(), buffers.getEntityVertexConsumers());
modelView.translate(cameraPos.getX(), cameraPos.getY(), cameraPos.getZ());
modelView.translate(-cameraX, -cameraY, -cameraZ);
HookRenderManager.INSTANCE.renderHooks(modelView, tickDelta, buffers.getEntityVertexConsumers());
modelView.translate(cameraX, cameraY, cameraZ);
}
}
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
Loading