Skip to content
Closed
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
45 changes: 10 additions & 35 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
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
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

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
}

Expand All @@ -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>("shadowJar") {
archiveVersion = versionWithMCVersion
archiveClassifier.set("shadow")
configurations = listOf(shadowCommon)
}

named<RemapJarTask>("remapJar") {
dependsOn(shadow)
inputFile = shadow.flatMap { it.archiveFile }
archiveVersion = versionWithMCVersion
archiveClassifier = ""
}

jar {
enabled = false
}

processResources {
// Replaces placeholders in the mod info files
filesMatching(targets) {
Expand Down
12 changes: 4 additions & 8 deletions common/src/main/java/com/lambda/mixin/ClientConnectionMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"))
Expand Down
16 changes: 6 additions & 10 deletions common/src/main/java/com/lambda/mixin/render/CameraMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Double> info) {
if (CameraTweaks.INSTANCE.isEnabled() && CameraTweaks.getNoClipCam()) {
info.setReturnValue(desiredCameraDistance);
}
private void onClipToSpace(float f, CallbackInfoReturnable<Float> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@

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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Integer> ci) {
lastFrameDuration = (timeMillis - prevTimeMillis) / TimerManager.getTickLength();
prevTimeMillis = timeMillis;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<RenderSystem.ShapeIndexBuffer> 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<RenderSystem.ShapeIndexBuffer> cir) {
RenderSystem.ShapeIndexBuffer value = cir.getReturnValue();
VaoUtils.lastIbo = value == null ? this.indexBufferId : value.id;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ object BlockSerializer : JsonSerializer<Block>, JsonDeserializer<Block> {
typeOfT: Type?,
context: JsonDeserializationContext?,
): Block =
Registries.BLOCK.getOrEmpty(Identifier(json?.asString)).orElseThrow()
}
Registries.BLOCK.getOrEmpty(Identifier.ofVanilla(json?.asString)).orElseThrow()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -109,10 +109,10 @@ object ContainerManager : Loadable {
blockState: BlockState,
availableTools: Set<Item> = 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
Expand All @@ -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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -54,4 +54,4 @@ object ServerSpoof : Module(
})
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion common/src/main/kotlin/com/lambda/sound/SoundManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ object SoundManager {
)
}

fun String.toIdentifier() = Identifier(Lambda.MOD_ID, this)
fun String.toIdentifier(): Identifier = Identifier.of(Lambda.MOD_ID, this)
}
Loading