diff --git a/build.gradle.kts b/build.gradle.kts index bafe85b3b..6d91e5297 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,14 +1,7 @@ -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import net.fabricmc.loom.api.LoomGradleExtensionAPI -import net.fabricmc.loom.task.RemapJarTask import org.jetbrains.kotlin.gradle.dsl.JvmTarget import java.util.* -val targets = listOf("META-INF/*.toml", "fabric.mod.json") -val replacements = file("gradle.properties").inputStream().use { stream -> - Properties().apply { load(stream) } -}.map { (k, v) -> k.toString() to v.toString() }.toMap() - val modId: String by project val modVersion: String by project val mavenGroup: String by project @@ -16,6 +9,11 @@ val minecraftVersion: String by project val yarnMappings: String by project val libs = file("libs") +val targets = listOf("META-INF/*.toml", "fabric.mod.json") +val replacements = file("gradle.properties").inputStream().use { stream -> + Properties().apply { load(stream) } +}.map { (k, v) -> k.toString() to v.toString() }.toMap() + val Project.loom: LoomGradleExtensionAPI get() = (this as ExtensionAware).extensions.getByName("loom") as LoomGradleExtensionAPI @@ -23,7 +21,7 @@ plugins { kotlin("jvm") version "2.0.0" id("org.jetbrains.dokka") version "1.9.20" id("architectury-plugin") version "3.4-SNAPSHOT" - id("dev.architectury.loom") version "1.6-SNAPSHOT" apply false + id("dev.architectury.loom") version "1.7-SNAPSHOT" apply false id("com.github.johnrengelman.shadow") version "8.1.1" apply false } @@ -37,38 +35,15 @@ subprojects { dependencies { "minecraft"("com.mojang:minecraft:$minecraftVersion") - "mappings"("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2") + "mappings"(loom.layered { + mappings("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2") + mappings("dev.architectury:yarn-mappings-patch-neoforge:$minecraftVersion+build.4") // Fix the mappings interaction between Yarn and NeoForge + }) } if (path == ":common") return@subprojects - apply(plugin = "com.github.johnrengelman.shadow") - - val versionWithMCVersion = "$modVersion+$minecraftVersion" - tasks { - val shadowCommon by configurations.creating { - isCanBeConsumed = false - isCanBeResolved = true - } - - val shadow = named("shadowJar") { - archiveVersion = versionWithMCVersion - archiveClassifier.set("shadow") - configurations = listOf(shadowCommon) - } - - named("remapJar") { - dependsOn(shadow) - inputFile = shadow.flatMap { it.archiveFile } - archiveVersion = versionWithMCVersion - archiveClassifier = "" - } - - jar { - enabled = false - } - processResources { // Replaces placeholders in the mod info files filesMatching(targets) { diff --git a/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java b/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java index 29cc5bb7a..388a4c778 100644 --- a/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java +++ b/common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java @@ -6,7 +6,7 @@ import io.netty.channel.ChannelHandlerContext; import net.minecraft.network.ClientConnection; import net.minecraft.network.NetworkSide; -import net.minecraft.network.listener.PacketListener; +import net.minecraft.network.listener.ClientLoginPacketListener; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.c2s.handshake.ConnectionIntent; import net.minecraft.text.Text; @@ -58,15 +58,11 @@ private void receivingPacketPost( EventFlow.post(new PacketEvent.Receive.Post(packet)); } - @Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/PacketListener;Lnet/minecraft/network/packet/c2s/handshake/ConnectionIntent;)V", at = @At("HEAD")) + @Inject(method = "connect(Ljava/lang/String;ILnet/minecraft/network/listener/ClientLoginPacketListener;)V", at = @At("HEAD")) private void onConnect( - String address, - int port, - PacketListener listener, - ConnectionIntent intent, - CallbackInfo ci + String address, int port, ClientLoginPacketListener listener, CallbackInfo ci ) { - EventFlow.post(new ConnectionEvent.Connect(address, port, listener, intent)); + EventFlow.post(new ConnectionEvent.Connect(address, port, listener, ConnectionIntent.LOGIN)); } @Inject(method = "disconnect(Lnet/minecraft/text/Text;)V", at = @At("HEAD")) diff --git a/common/src/main/java/com/lambda/mixin/render/CameraMixin.java b/common/src/main/java/com/lambda/mixin/render/CameraMixin.java index 393adc7d6..37192d062 100644 --- a/common/src/main/java/com/lambda/mixin/render/CameraMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/CameraMixin.java @@ -41,18 +41,14 @@ private void injectQuickPerspectiveSwap(BlockView area, Entity focusedEntity, bo } @Inject(method = "clipToSpace", at = @At("HEAD"), cancellable = true) - private void onClipToSpace(double desiredCameraDistance, CallbackInfoReturnable info) { - if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) { - info.setReturnValue(desiredCameraDistance); - } + private void onClipToSpace(float f, CallbackInfoReturnable cir) { + if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) cir.setReturnValue(f); } - @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(D)D")) - private double onDistanceUpdate(double desiredCameraDistance) { - if (CameraTweaks.INSTANCE.isEnabled()) { - return CameraTweaks.getCamDistance(); - } + @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(F)F")) + private float onDistanceUpdate(float f) { + if (CameraTweaks.INSTANCE.isEnabled()) return CameraTweaks.getCamDistance(); - return desiredCameraDistance; + return f; } } diff --git a/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java b/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java index 683686ee7..f5be4a189 100644 --- a/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/GameRendererMixin.java @@ -2,9 +2,7 @@ import com.lambda.event.EventFlow; import com.lambda.event.events.RenderEvent; -import com.lambda.graphics.RenderMain; import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -12,15 +10,8 @@ @Mixin(GameRenderer.class) public class GameRendererMixin { - @Inject(method = "updateTargetedEntity", at = @At("HEAD"), cancellable = true) + @Inject(method = "updateCrosshairTarget", at = @At("HEAD"), cancellable = true) private void updateTargetedEntityInvoke(float tickDelta, CallbackInfo info) { - if (EventFlow.post(new RenderEvent.UpdateTarget()).isCanceled()) { - info.cancel(); - } - } - - @Inject(method = "renderWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;FJZLnet/minecraft/client/render/Camera;Lnet/minecraft/client/render/GameRenderer;Lnet/minecraft/client/render/LightmapTextureManager;Lorg/joml/Matrix4f;)V", shift = At.Shift.AFTER)) - private void onRenderWorld(float tickDelta, long limitTime, MatrixStack matrix, CallbackInfo ci) { - RenderMain.render3D(matrix.peek().getPositionMatrix()); + if (EventFlow.post(new RenderEvent.UpdateTarget()).isCanceled()) info.cancel(); } } diff --git a/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java b/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java index f98c97947..b632ac626 100644 --- a/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java @@ -3,6 +3,7 @@ import com.lambda.graphics.RenderMain; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.hud.InGameHud; +import net.minecraft.client.render.RenderTickCounter; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -11,7 +12,7 @@ @Mixin(InGameHud.class) public class InGameHudMixin { @Inject(method = "render", at = @At("TAIL")) - private void onRender(DrawContext context, float tickDelta, CallbackInfo ci) { + private void onRender(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) { RenderMain.render2D(); } } diff --git a/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java b/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java index dd0f62f6e..6d86e3994 100644 --- a/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/RenderTickCounterMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -@Mixin(RenderTickCounter.class) +@Mixin(RenderTickCounter.Dynamic.class) public class RenderTickCounterMixin { @Shadow @@ -18,7 +18,7 @@ public class RenderTickCounterMixin { @Shadow private long prevTimeMillis; - @Inject(method = "beginRenderTick", at = @At("HEAD"), cancellable = true) + @Inject(method = "beginRenderTick*", at = @At("HEAD"), cancellable = true) private void beginRenderTick(long timeMillis, CallbackInfoReturnable ci) { lastFrameDuration = (timeMillis - prevTimeMillis) / TimerManager.getTickLength(); prevTimeMillis = timeMillis; diff --git a/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java b/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java index 6c3584660..bb7836bab 100644 --- a/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/VertexBufferMixin.java @@ -3,7 +3,7 @@ import com.lambda.graphics.gl.VaoUtils; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gl.VertexBuffer; -import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.BuiltBuffer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,8 +17,8 @@ public class VertexBufferMixin { @Shadow private int indexBufferId; - @Inject(method = "uploadIndexBuffer", at = @At("RETURN")) - private void onConfigureIndexBuffer(BufferBuilder.DrawParameters parameters, ByteBuffer vertexBuffer, CallbackInfoReturnable cir) { + @Inject(method = "uploadIndexBuffer(Lnet/minecraft/client/render/BuiltBuffer$DrawParameters;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer;", at = @At("RETURN")) + private void onConfigureIndexBuffer(BuiltBuffer.DrawParameters parameters, ByteBuffer indexBuffer, CallbackInfoReturnable cir) { RenderSystem.ShapeIndexBuffer value = cir.getReturnValue(); VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id; } diff --git a/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java b/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java index e95ee1303..eff16d8d4 100644 --- a/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java +++ b/common/src/main/java/com/lambda/mixin/render/WorldRendererMixin.java @@ -1,12 +1,15 @@ package com.lambda.mixin.render; +import com.lambda.graphics.RenderMain; import com.lambda.module.modules.player.Freecam; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.render.*; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(WorldRenderer.class) public class WorldRendererMixin { @@ -19,4 +22,9 @@ private boolean renderIsThirdPerson(Camera camera) { private boolean renderSetupTerrainModifyArg(boolean spectator) { return Freecam.INSTANCE.isEnabled() || spectator; } + + @Inject(method = "render", at = @At(value = "TAIL")) + private void onRenderWorld(RenderTickCounter tickCounter, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f matrix4f, Matrix4f matrix4f2, CallbackInfo ci) { + RenderMain.render3D(matrix4f); + } } diff --git a/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt b/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt index 8c33f8913..350a5e378 100644 --- a/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt +++ b/common/src/main/kotlin/com/lambda/config/serializer/BlockSerializer.kt @@ -21,5 +21,5 @@ object BlockSerializer : JsonSerializer, JsonDeserializer { typeOfT: Type?, context: JsonDeserializationContext?, ): Block = - Registries.BLOCK.getOrEmpty(Identifier(json?.asString)).orElseThrow() -} \ No newline at end of file + Registries.BLOCK.getOrEmpty(Identifier.ofVanilla(json?.asString)).orElseThrow() +} diff --git a/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt b/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt index b75318aaf..25028d817 100644 --- a/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt +++ b/common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt @@ -28,7 +28,6 @@ import net.minecraft.block.pattern.CachedBlockPosition import net.minecraft.item.BlockItem import net.minecraft.item.ItemPlacementContext import net.minecraft.item.ItemUsageContext -import net.minecraft.registry.RegistryKeys import net.minecraft.util.Hand import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.HitResult @@ -178,10 +177,8 @@ object BuildSimulator { usageContext.blockPos, false ) - val canBePlacedOn = optimalStack.canPlaceOn( - usageContext.world.registryManager.get(RegistryKeys.BLOCK), - cachePos, - ) + val canBePlacedOn = optimalStack.canPlaceOn(cachePos) + if (!player.abilities.allowModifyWorld && !canBePlacedOn) { acc.add(PlaceResult.IllegalUsage(pos)) return@forEach @@ -244,7 +241,7 @@ object BuildSimulator { acc.add(BuildResult.WrongStack(pos, placeContext, target.copy)) return@forEach } - + if (optimalStack.item != currentHandStack.item) { acc.add(BuildResult.WrongItem(pos, placeContext, optimalStack.item)) return@forEach @@ -411,4 +408,4 @@ object BuildSimulator { // val aabb = Box(pBox.minX, pBox.minY - 1.0E-6, pBox.minZ, pBox.maxX, pBox.minY, pBox.maxZ) // return world.findSupportingBlockPos(player, aabb).orElse(null) // } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt b/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt index ad4d35bbf..4f3a23fde 100644 --- a/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt +++ b/common/src/main/kotlin/com/lambda/interaction/material/ContainerManager.kt @@ -19,7 +19,7 @@ import net.minecraft.item.ItemStack import net.minecraft.screen.GenericContainerScreenHandler import net.minecraft.screen.ScreenHandler import net.minecraft.screen.ScreenHandlerType -import java.util.TreeSet +import java.util.* // ToDo: Make this a Configurable to save container caches. Should use a cached region based storage system. object ContainerManager : Loadable { @@ -109,10 +109,10 @@ object ContainerManager : Loadable { blockState: BlockState, availableTools: Set = ItemUtils.tools, ) = availableTools.map { - it to it.getMiningSpeedMultiplier(it.defaultStack, blockState) + it to it.getMiningSpeed(it.defaultStack, blockState) }.filter { (item, speed) -> speed > 1.0 - && item.isSuitableFor(blockState) + && item.isCorrectForDrops(item.defaultStack, blockState) && findContainerWithSelection(item.select()) != null }.maxByOrNull { it.second @@ -121,4 +121,4 @@ object ContainerManager : Loadable { // fun SafeContext.nextDisposable() = player.combined.firstOrNull { it.item in TaskFlow.disposables } class NoContainerFound(selection: StackSelection): Exception("No container found matching $selection") -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt b/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt index 857bbbf71..e352c2691 100644 --- a/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt +++ b/common/src/main/kotlin/com/lambda/interaction/material/StackSelection.kt @@ -4,9 +4,9 @@ import com.lambda.util.BlockUtils.item import com.lambda.util.item.ItemStackUtils.shulkerBoxContents import net.minecraft.block.Block import net.minecraft.enchantment.Enchantment -import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.item.Item import net.minecraft.item.ItemStack +import net.minecraft.registry.entry.RegistryEntry import net.minecraft.screen.slot.Slot import kotlin.reflect.KClass @@ -138,10 +138,8 @@ class StackSelection { * @return A predicate that matches the [Enchantment] and `level`. */ fun hasEnchantment(enchantment: Enchantment, level: Int = -1): (ItemStack) -> Boolean = { - if (level < 0) { - EnchantmentHelper.getLevel(enchantment, it) > 0 - } else { - EnchantmentHelper.getLevel(enchantment, it) == level + it.enchantments.getLevel(RegistryEntry.of(enchantment)).let { enchantmentLevel -> + level == -1 || enchantmentLevel >= level } } diff --git a/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt b/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt index 5e8d6a6f2..e8d5d82b7 100644 --- a/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt +++ b/common/src/main/kotlin/com/lambda/interaction/visibilty/VisibilityChecker.kt @@ -10,6 +10,7 @@ import com.lambda.module.modules.client.TaskFlow import com.lambda.util.BlockUtils.blockState import com.lambda.util.math.VecUtils.distSq import com.lambda.util.primitives.extension.component6 +import com.lambda.util.primitives.extension.tickDelta import com.lambda.util.world.raycast.RayCastUtils.blockResult import com.lambda.util.world.raycast.RayCastUtils.entityResult import net.minecraft.entity.Entity diff --git a/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt b/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt index f67665104..d1353925a 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/movement/EntityControl.kt @@ -20,7 +20,7 @@ object EntityControl : Module( /* General */ private val forceMount by setting("Force Mount", true, description = "Attempts to force mount chested entities.", visibility = { page == Page.GENERAL }).apply { onValueChange { _, _ -> - horses.forEach { horse -> horse.updateSaddle() } + horses.forEach { horse -> horse.updateSaddledFlag() } } } diff --git a/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt b/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt index 1001cb814..d0b79061e 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/network/ServerSpoof.kt @@ -32,7 +32,7 @@ object ServerSpoof : Module( if (packet !is CustomPayloadC2SPacket) return@unsafeListener val payload = packet.payload if (payload !is BrandCustomPayload) return@unsafeListener - if (!spoofClientBrand || payload.id() != BrandCustomPayload.ID) return@unsafeListener + if (!spoofClientBrand || payload.id != BrandCustomPayload.ID) return@unsafeListener payload.write(PacketByteBuf(Unpooled.buffer()).writeString(spoofName)) } @@ -54,4 +54,4 @@ object ServerSpoof : Module( }) } } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt b/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt index d6c0f891f..1961a990f 100644 --- a/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt +++ b/common/src/main/kotlin/com/lambda/module/modules/render/CameraTweaks.kt @@ -9,7 +9,7 @@ object CameraTweaks : Module( defaultTags = setOf(ModuleTag.RENDER) ) { @JvmStatic - val camDistance by setting("Camera Distance", 4.0, 1.0..20.0, 0.1) + val camDistance by setting("Camera Distance", 4.0f, 1.0f..20.0f, 0.1f) @JvmStatic val noClipCam by setting("No Clip Camera", true) -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/sound/SoundManager.kt b/common/src/main/kotlin/com/lambda/sound/SoundManager.kt index be081fcec..7249ca5ec 100644 --- a/common/src/main/kotlin/com/lambda/sound/SoundManager.kt +++ b/common/src/main/kotlin/com/lambda/sound/SoundManager.kt @@ -22,5 +22,5 @@ object SoundManager { ) } - fun String.toIdentifier() = Identifier(Lambda.MOD_ID, this) + fun String.toIdentifier(): Identifier = Identifier.of(Lambda.MOD_ID, this) } diff --git a/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt b/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt index fc27eb6f3..d8706e60d 100644 --- a/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt +++ b/common/src/main/kotlin/com/lambda/task/tasks/BuildStructure.kt @@ -17,6 +17,7 @@ import com.lambda.module.modules.client.TaskFlow import com.lambda.task.Task import com.lambda.util.BaritoneUtils import com.lambda.util.Communication.info +import com.lambda.util.primitives.extension.tickDelta import net.minecraft.util.math.BlockPos class BuildStructure @Ta5kBuilder constructor( @@ -142,4 +143,4 @@ class BuildStructure @Ta5kBuilder constructor( blockPos.toStructure(TargetState.Air).toBlueprint() ) } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt b/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt index b0fd34c96..37bdb79f9 100644 --- a/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt +++ b/common/src/main/kotlin/com/lambda/task/tasks/PlaceContainer.kt @@ -5,12 +5,12 @@ import com.lambda.interaction.construction.Blueprint.Companion.toStructure import com.lambda.interaction.construction.StaticBlueprint.Companion.toBlueprint import com.lambda.interaction.construction.result.BuildResult import com.lambda.interaction.construction.result.PlaceResult -import com.lambda.interaction.construction.result.Resolvable import com.lambda.interaction.construction.simulation.BuildSimulator.simulate import com.lambda.interaction.construction.verify.TargetState import com.lambda.task.Task import com.lambda.task.tasks.BuildStructure.Companion.buildStructure import com.lambda.util.BlockUtils.blockPos +import com.lambda.util.primitives.extension.tickDelta import net.minecraft.item.ItemStack import net.minecraft.util.math.BlockPos @@ -50,4 +50,4 @@ class PlaceContainer @Ta5kBuilder constructor( fun placeContainer(stack: ItemStack) = PlaceContainer(stack) } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt b/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt index c735a7b4f..a089ebb0d 100644 --- a/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt +++ b/common/src/main/kotlin/com/lambda/util/DebugInfoHud.kt @@ -6,6 +6,7 @@ import com.lambda.command.CommandRegistry import com.lambda.event.EventFlow import com.lambda.module.ModuleRegistry import com.lambda.util.Formatting.asString +import com.lambda.util.primitives.extension.tickDelta import net.minecraft.util.Formatting import net.minecraft.util.hit.BlockHitResult import net.minecraft.util.hit.EntityHitResult diff --git a/common/src/main/kotlin/com/lambda/util/FolderRegister.kt b/common/src/main/kotlin/com/lambda/util/FolderRegister.kt index ee6ffc8e6..bdb712ffe 100644 --- a/common/src/main/kotlin/com/lambda/util/FolderRegister.kt +++ b/common/src/main/kotlin/com/lambda/util/FolderRegister.kt @@ -42,7 +42,7 @@ object FolderRegister { val path = resolve( hostName.sanitizeForFilename() ).resolve( - mc.world?.dimensionKey?.value?.path?.sanitizeForFilename() ?: "unknown" + mc.world?.dimensionEntry?.value()?.toString()?.sanitizeForFilename() ?: "unknown" ) path.createIfNotExists() return path diff --git a/common/src/main/kotlin/com/lambda/util/combat/Damage.kt b/common/src/main/kotlin/com/lambda/util/combat/Damage.kt index e3c31c1c1..430051619 100644 --- a/common/src/main/kotlin/com/lambda/util/combat/Damage.kt +++ b/common/src/main/kotlin/com/lambda/util/combat/Damage.kt @@ -1,12 +1,10 @@ package com.lambda.util.combat -import net.minecraft.enchantment.EnchantmentHelper import net.minecraft.entity.LivingEntity import net.minecraft.entity.damage.DamageSource import net.minecraft.entity.effect.StatusEffects import net.minecraft.registry.tag.DamageTypeTags import kotlin.math.max -import kotlin.math.min object Damage { /** @@ -24,9 +22,9 @@ object Damage { if (source.isIn(DamageTypeTags.BYPASSES_ENCHANTMENTS)) return damage - val protectionAmount = EnchantmentHelper.getProtectionAmount(entity.armorItems, source) + //val protectionAmount = EnchantmentHelper.getProtectionAmount(entity.armorItems, source) - if (protectionAmount > 0) return damage * (1.0 - min(protectionAmount, 20) / 25.0) + //if (protectionAmount > 0) return damage * (1.0 - min(protectionAmount, 20) / 25.0) return damage } diff --git a/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt b/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt index ac559c39c..1413dd312 100644 --- a/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt +++ b/common/src/main/kotlin/com/lambda/util/combat/Explosion.kt @@ -3,10 +3,7 @@ package com.lambda.util.combat import com.lambda.context.SafeContext import com.lambda.util.BlockUtils.blockState import com.lambda.util.BlockUtils.fluidState -import com.lambda.util.math.VecUtils.minus -import com.lambda.util.math.VecUtils.times import com.lambda.util.world.WorldUtils.getFastEntities -import net.minecraft.enchantment.ProtectionEnchantment import net.minecraft.entity.LivingEntity import net.minecraft.util.math.BlockPos import net.minecraft.util.math.Vec3d @@ -75,13 +72,14 @@ object Explosion { val distance = entity.pos.distanceTo(position) val size = power * 2.0 - val vel = ProtectionEnchantment.transformExplosionKnockback( + /*val vel = ProtectionEnchantment.transformExplosionKnockback( entity, (1.0 - distance / size) * Explosion.getExposure(position, entity) ) val diff = entity.eyePos - position - return diff.normalize() * vel + return diff.normalize() * vel*/ + return Vec3d.ZERO } fun SafeContext.explosionDestruction(source: Explosion): List { diff --git a/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt b/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt index aa15c663a..15676551d 100644 --- a/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt +++ b/common/src/main/kotlin/com/lambda/util/item/ItemStackUtils.kt @@ -1,11 +1,8 @@ package com.lambda.util.item import com.lambda.util.collections.Cacheable.Companion.cacheable -import net.minecraft.inventory.Inventories -import net.minecraft.item.BlockItem +import net.minecraft.component.DataComponentTypes import net.minecraft.item.ItemStack -import net.minecraft.nbt.NbtElement -import net.minecraft.util.collection.DefaultedList object ItemStackUtils { val ItemStack.spaceLeft get() = maxCount - count @@ -41,13 +38,8 @@ object ItemStackUtils { } val ItemStack.shulkerBoxContents: List by cacheable { stack -> - BlockItem.getBlockEntityNbt(stack)?.takeIf { - it.contains("Items", NbtElement.LIST_TYPE.toInt()) - }?.let { - val list = DefaultedList.ofSize(27, ItemStack.EMPTY) - Inventories.readNbt(it, list) - list - } ?: emptyList() + stack.components.get(DataComponentTypes.CONTAINER)?.stream()?.toList() + ?: emptyList() } /** @@ -60,5 +52,6 @@ object ItemStackUtils { */ fun ItemStack?.equal(other: ItemStack?) = ItemStack.areEqual(this, other) - fun ItemStack.combines(other: ItemStack) = ItemStack.canCombine(this, other) -} \ No newline at end of file + // TODO: Find the new method for this + //fun ItemStack.combines(other: ItemStack) = ItemStack.canCombine(this, other) +} diff --git a/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt b/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt index 32f197782..530153c20 100644 --- a/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt +++ b/common/src/main/kotlin/com/lambda/util/player/MovementUtils.kt @@ -12,7 +12,6 @@ import com.lambda.util.math.VecUtils.times import net.minecraft.client.input.Input import net.minecraft.client.input.KeyboardInput import net.minecraft.client.network.ClientPlayerEntity -import net.minecraft.enchantment.EnchantmentHelper.getSwiftSneakSpeedBoost import net.minecraft.entity.Entity import net.minecraft.util.math.EightWayDirection import net.minecraft.util.math.Vec3d @@ -30,7 +29,7 @@ object MovementUtils { player.input } else { val multiplier = if (!player.shouldSlowDown()) 1f - else (0.3f + getSwiftSneakSpeedBoost(player)).coerceIn(0f, 1f) + else (0.3f + /*getSwiftSneakSpeedBoost(player)*/0).coerceIn(0f, 1f) KeyboardInput(mc.options).apply { tick(true, multiplier) @@ -132,4 +131,4 @@ object MovementUtils { val directionIndex = ((normalizedYaw + 22.5) / 45.0).toInt() % 8 return EightWayDirection.entries[directionIndex] } -} \ No newline at end of file +} diff --git a/common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt b/common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt new file mode 100644 index 000000000..27b91c457 --- /dev/null +++ b/common/src/main/kotlin/com/lambda/util/primitives/extension/Minecraft.kt @@ -0,0 +1,9 @@ +package com.lambda.util.primitives.extension + +import net.minecraft.client.MinecraftClient + +val MinecraftClient.tickDelta: Float + get() = renderTickCounter.tickDelta + +val MinecraftClient.pausedTickDelta: Float + get() = renderTickCounter.tickDeltaBeforePause diff --git a/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt b/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt index 972153633..6464d0d85 100644 --- a/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt +++ b/common/src/main/kotlin/com/lambda/util/text/TextEvents.kt @@ -18,9 +18,7 @@ package com.lambda.util.text import net.minecraft.entity.Entity import net.minecraft.entity.EntityType -import net.minecraft.item.Item import net.minecraft.item.ItemStack -import net.minecraft.nbt.NbtCompound import net.minecraft.text.ClickEvent import net.minecraft.text.HoverEvent import net.minecraft.text.Text @@ -104,25 +102,6 @@ object HoverEvents { return HoverEvent(HoverEvent.Action.SHOW_ITEM, HoverEvent.ItemStackContent(itemStack)) } - /** - * Creates a [HoverEvent] showing an [ItemStack] created from the given [NBT Compound][nbt]. - * - * @see HoverEvent.Action.SHOW_ITEM - */ - fun showItem(nbt: NbtCompound): HoverEvent { - return showItem(ItemStack.fromNbt(nbt)) - } - - /** - * Creates a [HoverEvent] showing an [ItemStack] created from the given [item] - * with an optional [NBT tag][nbt]. - * - * @see HoverEvent.Action.SHOW_ITEM - */ - fun showItem(item: Item, nbt: NbtCompound? = null): HoverEvent { - return showItem(item.defaultStack.also { it.nbt = nbt }) - } - /** * Creates a [HoverEvent] showing an [Entity] of a specified [type][entityType] * with the specified [uuid] and an optional [name]. diff --git a/common/src/main/resources/lambda.accesswidener b/common/src/main/resources/lambda.accesswidener index 4a8c265d5..24d7ff9a2 100644 --- a/common/src/main/resources/lambda.accesswidener +++ b/common/src/main/resources/lambda.accesswidener @@ -3,12 +3,12 @@ accessWidener v2 named accessible field net/minecraft/client/MinecraftClient itemUseCooldown I accessible field net/minecraft/client/MinecraftClient attackCooldown I accessible field net/minecraft/client/MinecraftClient paused Z -accessible field net/minecraft/client/MinecraftClient pausedTickDelta F accessible field net/minecraft/client/MinecraftClient thread Ljava/lang/Thread; +accessible field net/minecraft/client/MinecraftClient renderTickCounter Lnet/minecraft/client/render/RenderTickCounter$Dynamic; # World -accessible field net/minecraft/client/world/ClientWorld entityManager Lnet/minecraft/client/world/ClientEntityManager; -accessible field net/minecraft/client/world/ClientEntityManager cache Lnet/minecraft/world/entity/SectionedEntityCache; +accessible field net/minecraft/client/world/ClientWorld entityManager Lnet/minecraft/world/entity/ClientEntityManager; +accessible field net/minecraft/world/entity/ClientEntityManager cache Lnet/minecraft/world/entity/SectionedEntityCache; accessible field net/minecraft/world/entity/EntityTrackingSection collection Lnet/minecraft/util/collection/TypeFilterableList; accessible field net/minecraft/client/world/ClientChunkManager chunks Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap; accessible field net/minecraft/client/world/ClientChunkManager$ClientChunkMap chunks Ljava/util/concurrent/atomic/AtomicReferenceArray; @@ -17,7 +17,7 @@ accessible field net/minecraft/client/world/ClientChunkManager$ClientChunkMap ch accessible field net/minecraft/entity/projectile/FireworkRocketEntity shooter Lnet/minecraft/entity/LivingEntity; accessible method net/minecraft/entity/Entity movementInputToVelocity (Lnet/minecraft/util/math/Vec3d;FF)Lnet/minecraft/util/math/Vec3d; accessible method net/minecraft/entity/passive/AbstractHorseEntity setHorseFlag (IZ)V -accessible method net/minecraft/entity/passive/AbstractHorseEntity updateSaddle ()V +accessible method net/minecraft/entity/passive/AbstractHorseEntity updateSaddledFlag ()V # Camera accessible method net/minecraft/client/render/Camera setPos (DDD)V @@ -27,6 +27,8 @@ accessible method net/minecraft/client/render/Camera setRotation (FF)V accessible field com/mojang/blaze3d/systems/RenderSystem$ShapeIndexBuffer id I accessible field net/minecraft/client/render/BufferRenderer currentVertexBuffer Lnet/minecraft/client/gl/VertexBuffer; accessible field net/minecraft/client/texture/NativeImage pointer J +accessible field net/minecraft/client/render/RenderTickCounter$Dynamic tickDelta F +accessible field net/minecraft/client/render/RenderTickCounter$Dynamic tickDeltaBeforePause F # Text accessible field net/minecraft/text/Style color Lnet/minecraft/text/TextColor; @@ -46,6 +48,7 @@ accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPa accessible field net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket type Lnet/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler; accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractTypeHandler accessible class net/minecraft/network/packet/c2s/play/PlayerInteractEntityC2SPacket$InteractAtHandler +accessible method net/minecraft/network/packet/BrandCustomPayload write (Lnet/minecraft/network/PacketByteBuf;)V accessible method net/minecraft/network/ClientConnection handlePacket (Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/listener/PacketListener;)V accessible field net/minecraft/network/ClientConnection packetsReceivedCounter I accessible field net/minecraft/network/ClientConnection packetsSentCounter I diff --git a/fabric/build.gradle.kts b/fabric/build.gradle.kts index b82926a0c..b901c6c71 100644 --- a/fabric/build.gradle.kts +++ b/fabric/build.gradle.kts @@ -1,3 +1,4 @@ +val modVersion: String by project val minecraftVersion: String by project val fabricLoaderVersion: String by project val fabricApiVersion: String by project @@ -5,6 +6,10 @@ val kotlinFabricVersion: String by project base.archivesName = "${base.archivesName.get()}-fabric" +plugins { + id("com.github.johnrengelman.shadow") version "8.1.1" +} + architectury { platformSetupLoomIde() fabric() @@ -40,11 +45,6 @@ fun DependencyHandlerScope.setupConfigurations() { modImplementation(it) include(it) } - - shadowBundle.dependencies.forEach { - shadowCommon(it) - shadow(it) - } } dependencies { @@ -73,10 +73,23 @@ dependencies { } tasks { - // Access wideners are the successor of the mixins accessor - // that were used in the past to access private fields and methods. - // They allow you to make field, method, and class access public. + shadowJar { + archiveVersion = "$modVersion+$minecraftVersion" + configurations = listOf(shadowBundle) + archiveClassifier = "dev-shadow" + } + remapJar { + dependsOn(shadowJar) + + // Access wideners are the successor of the mixins accessor + // that were used in the past to access private fields and methods. + // They allow you to make field, method, and class access public. injectAccessWidener = true } + + remapJar { + dependsOn(processResources, shadowJar) + inputFile = shadowJar.get().archiveFile + } } diff --git a/forge/build.gradle.kts b/forge/build.gradle.kts index 5c416a023..12f45e61d 100644 --- a/forge/build.gradle.kts +++ b/forge/build.gradle.kts @@ -1,3 +1,4 @@ +val modVersion: String by project val minecraftVersion: String by project val forgeVersion: String by project val mixinExtrasVersion: String by project @@ -5,6 +6,10 @@ val kotlinForgeVersion: String by project base.archivesName = "${base.archivesName.get()}-forge" +plugins { + id("com.github.johnrengelman.shadow") version "8.1.1" +} + architectury { platformSetupLoomIde() forge() @@ -62,11 +67,6 @@ fun DependencyHandlerScope.setupConfigurations() { forgeRuntimeLibrary(it) include(it) } - - shadowBundle.dependencies.forEach { - shadowCommon(it) - shadow(it) - } } dependencies { @@ -85,9 +85,6 @@ dependencies { implementation("io.github.llamalad7:mixinextras-forge:$mixinExtrasVersion") compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:$mixinExtrasVersion")!!) - // Fix KFF - compileOnly(kotlin("stdlib")) - // Disable reflections logging include("org.slf4j:slf4j-nop:2.0.13") @@ -105,4 +102,15 @@ tasks { it.output.setResourcesDir(dir) it.java.destinationDirectory.set(dir) } + + shadowJar { + archiveVersion = "$modVersion+$minecraftVersion" + configurations = listOf(shadowBundle) + archiveClassifier = "dev-shadow" + } + + remapJar { + dependsOn(processResources, shadowJar) + inputFile = shadowJar.get().archiveFile + } } diff --git a/gradle.properties b/gradle.properties index bda234554..d9770261e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,24 +6,23 @@ mavenGroup=com.lambda modAuthors=Constructor, Blade, Edouard127 # General -minecraftVersion=1.20.4 +minecraftVersion=1.21 mixinExtrasVersion=0.3.6 kotlinVersion=2.0.0 kotlinxCoroutinesVersion=1.9.0-RC # Fabric https://fabricmc.net/develop/ fabricLoaderVersion=0.15.11 -yarnMappings=build.3 -fabricApiVersion=0.97.1 +yarnMappings=build.7 +fabricApiVersion=0.100.4 kotlinFabricVersion=1.11.0+kotlin.2.0.0 # Forge https://files.minecraftforge.net/ -# Please do not change this version it will implode and create a black hole -forgeVersion=49.0.31 -kotlinForgeVersion=4.11.0 +forgeVersion=51.0.21 +kotlinForgeVersion=5.3.0 # NeoForge https://neoforged.net -neoVersion=20.4.237 +neoVersion=21.0.47-beta # Kotlin https://kotlinlang.org/ kotlin.code.style=official diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 44b5c300a..cc66931b3 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -1,8 +1,14 @@ +val modVersion: String by project +val minecraftVersion: String by project val neoVersion: String by project val kotlinForgeVersion: String by project base.archivesName = "${base.archivesName.get()}-neoforge" +plugins { + id("com.github.johnrengelman.shadow") version "8.1.1" +} + architectury { platformSetupLoomIde() neoForge() @@ -42,11 +48,6 @@ fun DependencyHandlerScope.setupConfigurations() { implementation(it) include(it) } - - shadowBundle.dependencies.forEach { - shadowCommon(it) - shadow(it) - } } dependencies { @@ -79,8 +80,14 @@ tasks { } } + shadowJar { + archiveVersion = "$modVersion+$minecraftVersion" + configurations = listOf(shadowBundle) + archiveClassifier = "dev-shadow" + } + remapJar { - dependsOn(processResources) - atAccessWideners.add("lambda.accesswidener") // Add the access widener to the remapper + dependsOn(processResources, shadowJar) + inputFile = shadowJar.get().archiveFile } }