Skip to content

Commit b55cade

Browse files
committed
My changes from a long time ago
1 parent be7fd72 commit b55cade

39 files changed

+247
-340
lines changed

build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ subprojects {
5454

5555
dependencies {
5656
"minecraft"("com.mojang:minecraft:$minecraftVersion")
57-
"mappings"(loom.layered {
58-
mappings("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2")
59-
mappings("dev.architectury:yarn-mappings-patch-neoforge:1.21+build.4")
60-
})
57+
"mappings"("net.fabricmc:yarn:$minecraftVersion+$yarnMappings:v2")
6158
}
6259

6360
publishing {

common/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Lambda
2+
* Copyright 2025 Lambda
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -23,18 +23,18 @@
2323
import com.lambda.event.events.PlayerEvent;
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.interaction.PlayerPacketManager;
26-
import com.lambda.interaction.request.rotation.RotationManager;
26+
import com.lambda.interaction.request.rotating.RotationManager;
2727
import com.lambda.module.modules.player.PortalGui;
28+
import com.lambda.module.modules.render.ViewModel;
2829
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
2930
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
3031
import net.minecraft.client.MinecraftClient;
31-
import net.minecraft.client.gui.screen.DeathScreen;
3232
import net.minecraft.client.gui.screen.Screen;
33-
import net.minecraft.client.gui.screen.ingame.HandledScreen;
3433
import net.minecraft.client.input.Input;
34+
import net.minecraft.client.network.AbstractClientPlayerEntity;
3535
import net.minecraft.client.network.ClientPlayerEntity;
3636
import net.minecraft.entity.MovementType;
37-
import net.minecraft.entity.damage.DamageSource;
37+
import net.minecraft.util.Hand;
3838
import net.minecraft.util.math.Vec3d;
3939
import org.spongepowered.asm.mixin.Final;
4040
import org.spongepowered.asm.mixin.Mixin;
@@ -118,7 +118,7 @@ void redirectSneaking(CallbackInfoReturnable<Boolean> cir) {
118118
if (self != Lambda.getMc().player) return;
119119

120120
if (self.input == null) return;
121-
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.sneaking)).getSneak());
121+
cir.setReturnValue(EventFlow.post(new MovementEvent.Sneak(self.input.playerInput.sneak())).getSneak());
122122
}
123123

124124
/**
@@ -148,6 +148,11 @@ float fixHeldItemPitch(ClientPlayerEntity instance) {
148148
return Objects.requireNonNullElse(RotationManager.getHandPitch(), instance.getPitch());
149149
}
150150

151+
@Inject(method = "swingHand", at = @At("HEAD"), cancellable = true)
152+
void onSwing(Hand hand, CallbackInfo ci) {
153+
if (EventFlow.post(new PlayerEvent.SwingHand(hand)).isCanceled()) ci.cancel();
154+
}
155+
151156
@Redirect(method = "swingHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;swingHand(Lnet/minecraft/util/Hand;)V"))
152157
private void adjustSwing(AbstractClientPlayerEntity instance, Hand hand) {
153158
ViewModel viewModel = ViewModel.INSTANCE;
@@ -160,9 +165,9 @@ private void adjustSwing(AbstractClientPlayerEntity instance, Hand hand) {
160165
viewModel.adjustSwing(hand, instance);
161166
}
162167

163-
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
164-
public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
165-
if (EventFlow.post(new PlayerEvent.Damage(source, amount)).isCanceled()) cir.setReturnValue(false);
168+
@Inject(method = "updateHealth", at = @At("HEAD"))
169+
public void damage(float health, CallbackInfo ci) {
170+
EventFlow.post(new PlayerEvent.Damage(health));
166171
}
167172

168173
/**

common/src/main/java/com/lambda/mixin/entity/PlayerInventoryMixin.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

common/src/main/java/com/lambda/mixin/render/HeldItemRendererMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void onRenderArmHoldingItem(AbstractClientPlayerEntity player, float tic
3434
ViewModel.INSTANCE.transform(itemStack, hand, matrices);
3535
}
3636

37-
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
37+
@Inject(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
3838
private void onRenderFirstPersonItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand, float swingProgress, ItemStack itemStack, float equipProgress, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
3939
if (!ViewModel.INSTANCE.isEnabled()) return;
4040

@@ -85,4 +85,4 @@ private float modifySwing(float swingProgress) {
8585

8686
return swingProgress;
8787
}
88-
}
88+
}

common/src/main/java/com/lambda/mixin/render/InGameHudMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Lambda
2+
* Copyright 2025 Lambda
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -41,8 +41,8 @@ private void onRender(DrawContext context, RenderTickCounter tickCounter, Callba
4141
RenderMain.render2D();
4242
}
4343

44-
@Redirect(method = "tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getMainHandStack()Lnet/minecraft/item/ItemStack;"))
44+
@Redirect(method = "tick()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSelectedStack()Lnet/minecraft/item/ItemStack;"))
4545
private ItemStack onTick(PlayerInventory inventory) {
46-
return isValidHotbarIndex(inventory.selectedSlot) ? inventory.main.get(inventory.selectedSlot) : ItemStack.EMPTY;
46+
return isValidHotbarIndex(inventory.getSelectedSlot()) ? inventory.getMainStacks().get(inventory.getSelectedSlot()) : ItemStack.EMPTY;
4747
}
4848
}

common/src/main/java/com/lambda/mixin/render/LivingEntityRendererMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ public class LivingEntityRendererMixin {
4747
*/
4848
@Redirect(method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getLerpedPitch(F)F", ordinal = 0), require = 0)
4949
private float injectRotationPitch(LivingEntity instance, float v) {
50-
return Objects.requireNonNullElse(RotationManager.getRenderPitch(), v);
50+
return Objects.requireNonNullElse(RotationManager.getHeadPitch(), v);
5151
}
5252
}

common/src/main/kotlin/com/lambda/config/groups/InventorySettings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Lambda
2+
* Copyright 2025 Lambda
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by

common/src/main/kotlin/com/lambda/interaction/construction/blueprint/Blueprint.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.lambda.interaction.construction.blueprint
1919

2020
import com.lambda.interaction.construction.verify.TargetState
21-
import com.lambda.util.BlockUtils.blockPos
2221
import com.lambda.util.collections.updatableLazy
2322
import com.lambda.util.extension.Structure
2423
import com.lambda.util.math.roundedBlockPos
@@ -53,20 +52,18 @@ abstract class Blueprint {
5352

5453
fun isOutOfBounds(vec3d: Vec3d): Boolean = bounds.value?.contains(vec3d.roundedBlockPos) == false
5554

56-
val center get() = bounds.value?.center?.blockPos
55+
val center get() = bounds.value?.center
5756

5857
companion object {
5958
fun emptyStructure(): Structure = emptyMap()
6059

6160
fun Box.toStructure(targetState: TargetState): Structure =
6261
BlockPos.stream(this)
63-
.map { it.blockPos }
6462
.toList()
6563
.associateWith { targetState }
6664

6765
fun BlockBox.toStructure(targetState: TargetState): Structure =
6866
BlockPos.stream(this)
69-
.map { it.blockPos }
7067
.toList()
7168
.associateWith { targetState }
7269

common/src/main/kotlin/com/lambda/interaction/construction/context/PlaceContext.kt

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Lambda
2+
* Copyright 2025 Lambda
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -29,8 +29,6 @@ import com.lambda.interaction.request.rotating.RotationRequest
2929
import com.lambda.util.BlockUtils
3030
import com.lambda.util.BlockUtils.blockState
3131
import net.minecraft.block.BlockState
32-
import net.minecraft.util.ActionResult
33-
import net.minecraft.util.Hand
3432
import net.minecraft.util.hit.BlockHitResult
3533
import net.minecraft.util.math.BlockPos
3634
import java.awt.Color
@@ -49,26 +47,6 @@ data class PlaceContext(
4947
private val baseColor = Color(35, 188, 254, 25)
5048
private val sideColor = Color(35, 188, 254, 100)
5149

52-
override fun interact(swingHand: Boolean) {
53-
runSafe {
54-
val actionResult = interaction.interactBlock(
55-
player, hand, result
56-
)
57-
58-
if (actionResult is ActionResult.Success) {
59-
if (actionResult.swingSource() == ActionResult.SwingSource.CLIENT && swingHand) {
60-
player.swingHand(hand)
61-
}
62-
63-
if (!player.getStackInHand(hand).isEmpty && player.isCreative) {
64-
mc.gameRenderer.firstPersonRenderer.resetEquipProgress(hand)
65-
}
66-
} else {
67-
warn("Internal interaction failed with $actionResult")
68-
}
69-
}
70-
}
71-
7250
override fun compareTo(other: BuildContext) =
7351
when (other) {
7452
is PlaceContext -> compareBy<PlaceContext> {

common/src/main/kotlin/com/lambda/interaction/construction/simulation/BuildSimulator.kt

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Lambda
2+
* Copyright 2025 Lambda
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -62,9 +62,9 @@ import com.lambda.util.BlockUtils.hasFluid
6262
import com.lambda.util.BlockUtils.instantBreakable
6363
import com.lambda.util.BlockUtils.isEmpty
6464
import com.lambda.util.BlockUtils.isNotEmpty
65-
import com.lambda.util.BlockUtils.vecOf
6665
import com.lambda.util.Communication.warn
6766
import com.lambda.util.math.distSq
67+
import com.lambda.util.math.vec3d
6868
import com.lambda.util.player.SlotUtils.hotbar
6969
import com.lambda.util.player.copyPlayer
7070
import com.lambda.util.player.gamemode
@@ -85,7 +85,6 @@ import net.minecraft.item.Item
8585
import net.minecraft.item.ItemPlacementContext
8686
import net.minecraft.item.ItemStack
8787
import net.minecraft.item.ItemUsageContext
88-
import net.minecraft.registry.RegistryKeys
8988
import net.minecraft.state.property.Properties
9089
import net.minecraft.util.Hand
9190
import net.minecraft.util.hit.BlockHitResult
@@ -256,7 +255,7 @@ object BuildSimulator {
256255
acc.add(BuildResult.OutOfReach(pos, eye, misses))
257256
} else {
258257
//ToDo: Must clean up surface scan usage / renders. Added temporary direction until changes are made
259-
acc.add(BuildResult.NotVisible(pos, pos, Direction.UP, eye.distanceTo(pos.vecOf(Direction.UP))))
258+
acc.add(BuildResult.NotVisible(pos, pos, Direction.UP, eye.distanceTo(pos.offset(Direction.UP).vec3d)))
260259
}
261260
return@interactBlock
262261
}
@@ -421,7 +420,7 @@ object BuildSimulator {
421420
return@forEach
422421
}
423422

424-
acc.add(BuildResult.NotVisible(pos, hitPos, hitSide, eye.distanceTo(hitPos.vecOf(hitSide))))
423+
acc.add(BuildResult.NotVisible(pos, hitPos, hitSide, eye.distanceTo(hitPos.offset(hitSide).vec3d)))
425424
return@forEach
426425
}
427426

@@ -444,10 +443,7 @@ object BuildSimulator {
444443
val cachePos = CachedBlockPosition(
445444
usageContext.world, usageContext.blockPos, false
446445
)
447-
val canBePlacedOn = optimalStack.canPlaceOn(
448-
usageContext.world.registryManager.get(RegistryKeys.BLOCK),
449-
cachePos,
450-
)
446+
val canBePlacedOn = optimalStack.canPlaceOn(cachePos)
451447
if (!player.abilities.allowModifyWorld && !canBePlacedOn) {
452448
acc.add(PlaceResult.IllegalUsage(pos))
453449
return@forEach
@@ -767,22 +763,21 @@ object BuildSimulator {
767763
}
768764

769765
val stackSelection = selectStack(
770-
block = {
771-
run {
772-
if (breaking.suitableToolsOnly) isSuitableForBreaking(state)
773-
else StackSelection.EVERYTHING
774-
} and if (breaking.forceSilkTouch) {
775-
hasEnchantment(Enchantments.SILK_TOUCH)
776-
} else if (breaking.forceFortunePickaxe) {
777-
hasEnchantment(Enchantments.FORTUNE, breaking.minFortuneLevel)
778-
} else StackSelection.EVERYTHING
779-
},
780766
sorter = compareByDescending<ItemStack> {
781-
it.canDestroy(world.registryManager.get(RegistryKeys.BLOCK), CachedBlockPosition(world, pos, false))
767+
it.canBreak(CachedBlockPosition(world, pos, false))
782768
}.thenByDescending {
783769
state.calcItemBlockBreakingDelta(player, world, pos, it)
784770
}
785-
)
771+
) {
772+
run {
773+
if (breaking.suitableToolsOnly) isSuitableForBreaking(state)
774+
else StackSelection.EVERYTHING
775+
} and if (breaking.forceSilkTouch) {
776+
hasEnchantment(Enchantments.AQUA_AFFINITY)
777+
} else if (breaking.forceFortunePickaxe) {
778+
hasEnchantment(Enchantments.FORTUNE, breaking.minFortuneLevel)
779+
} else StackSelection.EVERYTHING
780+
}
786781

787782
val silentSwapSelection = selectContainer {
788783
ofAnyType(MaterialContainer.Rank.HOTBAR)

0 commit comments

Comments
 (0)