Skip to content

Commit 876d902

Browse files
committed
Merge branch 'master' into refactor/ui
2 parents 2c7c377 + 9d0d382 commit 876d902

File tree

239 files changed

+6210
-3362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+6210
-3362
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,7 @@ First of all, make sure to read or simply check the [Official Kotlin Coding Conv
103103

104104
This is required for pull requests to be accepted, or even reviewed.
105105

106-
You will need the following before contributing:
107-
- GitHub CLI / Desktop
108-
- IntelliJ IDEA
109-
- Java 17 SDK
110-
- [Minecraft Development Plugin](https://plugins.jetbrains.com/plugin/8327-minecraft-development)
111-
112-
After you have everything you can do the following:
113-
- Clone the repository `git clone https://github.com/lambda-client/lambda`
114-
- Open the project, **inside the project folder**, in IntelliJ IDEA
115-
- Set the java runtime in `File > Project Structure > SDK > JDK 17`
116-
- Wait for Gradle to resolve dependencies and to set up the project.
117-
- And you should now be able to run the project using the [run configurations](https://www.jetbrains.com/help/idea/run-debug-configuration.html)
106+
After this, you can read the [getting started](https://github.com/lambda-client/wiki/Getting-Started) section in the wiki
118107

119108
### Improving The Documentation
120109
If you believe that some documentation can be improved or added, please discuss with us on our [Discord](https://discord.gg/QjfBxJzE5x)

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
# Pull Request Guidelines
2+
23
### This is a template, modify before submitting your PR
34

45
Please ensure that your PR title follows this format:
5-
- `[Minecraft Version] [Mod loader] Feat, Fix, Ref, Docs, ..., : Description`
6+
- `[Minecraft Version] <Mod loader> Feat, Fix, Ref, Docs, ..., : Description`
67

78
**Examples:**
8-
- `[1.20.x] [Forge] Feat: Add new block types`
9-
- `[1.19.x] [All] Fix: Crash on startup`
10-
- `[1.20.x] [Fabric] Refactor: Optimize rendering engine`
9+
- `[1.20.4] Feat: Add new block types`
10+
- `[1.21.4] [All] Fix: Crash on startup`
11+
- `[1.21.3] [Forge] Fix: GUI does not render`
12+
- `[1.20.1] Ref: Optimize rendering engine`
1113

12-
# Issue Link
13-
Please create an issue if there are none applicable before submitting this pull request.
14+
### Issue Link
15+
If your PR addresses one or more issues, be sure to link them. Use appropriate keywords like `closes`, `fixes`, or `resolves` to automatically close the linked issues when the PR is merged.
1416

15-
Then link the issue as follows:`Closes #123`
17+
#### **Examples:**
18+
- `This PR fixes a memory leak in foo() and closes #4. It also resolves #5, which is a duplicate issue.`
19+
- `Closes #1, resolves #2, and fixes #3`
20+
- `Fixes #1`
1621

17-
# Description
22+
### Description
23+
Provide a concise yet detailed summary of the changes introduced in this PR. Include the purpose of the changes and any relevant context.
1824

19-
Provide a brief description of the changes made in this PR:
25+
#### **Examples:**
26+
- `This pull request improves compatibility with version 1.21.4 by addressing rendering issues and adding support for new block types.`
27+
- `Refactors the rendering engine to enhance performance and reduce memory usage.`
28+
- `Adds a new feature for biome-specific block spawning to align with gameplay mechanics introduced in version 1.20.4.`
2029

21-
- **What does this PR do?**
22-
- **Why is this change needed?**
30+
### Checklist Before Submitting
31+
To ensure the quality and maintainability of your PR, confirm the following before submission:
32+
1. Code adheres to the project's style guide and conventions.
33+
2. All tests pass, including newly added tests.
34+
3. Documentation has been updated to reflect any new features or changes.
35+
4. Your PR is limited to a single purpose, avoiding unrelated changes.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ build/
1010
.idea/compiler.xml
1111
.idea/libraries/
1212
.idea/
13+
!.idea/scopes
1314
*.iws
1415
*.iml
1516
*.ipr
@@ -53,4 +54,3 @@ logs/
5354

5455
### Kotlin ###
5556
*.kotlin_module
56-
.kotlin/

.idea/scopes/UsageScope.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright 2024 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
118
import org.gradle.internal.jvm.*
219
import net.fabricmc.loom.api.LoomGradleExtensionAPI
320
import org.apache.tools.ant.taskdefs.condition.Os

common/src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.lambda.Lambda;
2121
import com.lambda.event.EventFlow;
2222
import com.lambda.event.events.ClientEvent;
23-
import com.lambda.event.events.ScreenHandlerEvent;
23+
import com.lambda.event.events.InventoryEvent;
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.module.modules.player.Interact;
2626
import net.minecraft.client.MinecraftClient;
@@ -78,15 +78,15 @@ private void onStartup(CallbackInfo ci) {
7878
private void onScreenOpen(@Nullable Screen screen, CallbackInfo ci) {
7979
if (screen == null) return;
8080
if (screen instanceof ScreenHandlerProvider<?> handledScreen) {
81-
EventFlow.post(new ScreenHandlerEvent.Open(handledScreen.getScreenHandler()));
81+
EventFlow.post(new InventoryEvent.Open(handledScreen.getScreenHandler()));
8282
}
8383
}
8484

8585
@Inject(method = "setScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;removed()V", shift = At.Shift.AFTER))
8686
private void onScreenRemove(@Nullable Screen screen, CallbackInfo ci) {
8787
if (currentScreen == null) return;
8888
if (currentScreen instanceof ScreenHandlerProvider<?> handledScreen) {
89-
EventFlow.post(new ScreenHandlerEvent.Close(handledScreen.getScreenHandler()));
89+
EventFlow.post(new InventoryEvent.Close(handledScreen.getScreenHandler()));
9090
}
9191
}
9292

common/src/main/java/com/lambda/mixin/client/sound/SoundSystemMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
@Mixin(SoundSystem.class)
3030
public class SoundSystemMixin {
31-
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At(value = "HEAD"), cancellable = true)
31+
@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
3232
public void onPlay(SoundInstance sound, CallbackInfo ci) {
3333
if (EventFlow.post(new ClientEvent.Sound(sound)).isCanceled()) {
3434
ci.cancel();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import com.lambda.event.EventFlow;
2121
import com.lambda.event.events.PlayerEvent;
22-
import net.minecraft.client.MinecraftClient;
2322
import net.minecraft.client.network.ClientPlayerEntity;
2423
import net.minecraft.client.network.ClientPlayerInteractionManager;
2524
import net.minecraft.entity.Entity;
@@ -31,7 +30,6 @@
3130
import net.minecraft.util.hit.EntityHitResult;
3231
import net.minecraft.util.math.BlockPos;
3332
import net.minecraft.util.math.Direction;
34-
import org.spongepowered.asm.mixin.Final;
3533
import org.spongepowered.asm.mixin.Mixin;
3634
import org.spongepowered.asm.mixin.Shadow;
3735
import org.spongepowered.asm.mixin.injection.At;
@@ -66,9 +64,11 @@ public void interactItemHead(PlayerEntity player, Hand hand, CallbackInfoReturna
6664
}
6765
}
6866

69-
@Inject(method = "attackBlock", at = @At("HEAD"))
67+
@Inject(method = "attackBlock", at = @At("HEAD"), cancellable = true)
7068
public void onAttackBlock(BlockPos pos, Direction side, CallbackInfoReturnable<Boolean> cir) {
71-
if (EventFlow.post(new PlayerEvent.Attack.Block(pos, side)).isCanceled()) cir.cancel();
69+
if (EventFlow.post(new PlayerEvent.Attack.Block(pos, side)).isCanceled()) {
70+
cir.setReturnValue(false);
71+
}
7272
}
7373

7474
@Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true)

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919

2020
import com.lambda.Lambda;
2121
import com.lambda.event.EventFlow;
22-
import com.lambda.event.events.PlayerEvent;
2322
import com.lambda.event.events.MovementEvent;
23+
import com.lambda.event.events.PlayerEvent;
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.interaction.PlayerPacketManager;
2626
import com.lambda.interaction.RotationManager;
2727
import net.minecraft.client.input.Input;
2828
import net.minecraft.client.network.ClientPlayerEntity;
2929
import net.minecraft.entity.MovementType;
30+
import net.minecraft.entity.damage.DamageSource;
3031
import net.minecraft.util.Hand;
3132
import net.minecraft.util.math.Vec3d;
3233
import org.spongepowered.asm.mixin.Mixin;
@@ -124,4 +125,11 @@ float fixHeldItemPitch(ClientPlayerEntity instance) {
124125
void onSwingHandPre(Hand hand, CallbackInfo ci) {
125126
if (EventFlow.post(new PlayerEvent.SwingHand(hand)).isCanceled()) ci.cancel();
126127
}
128+
129+
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
130+
public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
131+
if (EventFlow.post(new PlayerEvent.Damage(source, amount)).isCanceled()) {
132+
cir.setReturnValue(false);
133+
}
134+
}
127135
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
import com.lambda.Lambda;
2121
import com.lambda.event.EventFlow;
22+
import com.lambda.event.events.EntityEvent;
2223
import com.lambda.event.events.PlayerEvent;
23-
import com.lambda.event.events.WorldEvent;
2424
import com.lambda.interaction.RotationManager;
2525
import com.lambda.util.math.Vec2d;
2626
import net.minecraft.entity.Entity;
2727
import net.minecraft.entity.MovementType;
28+
import net.minecraft.entity.damage.DamageSource;
2829
import net.minecraft.entity.data.TrackedData;
2930
import net.minecraft.util.math.Vec3d;
3031
import org.spongepowered.asm.mixin.Mixin;
@@ -33,6 +34,7 @@
3334
import org.spongepowered.asm.mixin.injection.Inject;
3435
import org.spongepowered.asm.mixin.injection.Redirect;
3536
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
37+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3638

3739
@Mixin(Entity.class)
3840
public abstract class EntityMixin {
@@ -94,6 +96,16 @@ private void changeLookDirection(double cursorDeltaX, double cursorDeltaY, Callb
9496
public void onTrackedDataSet(TrackedData<?> data, CallbackInfo ci) {
9597
Entity entity = (Entity) (Object) this;
9698

97-
EventFlow.post(new WorldEvent.EntityUpdate(entity, data));
99+
EventFlow.post(new EntityEvent.EntityUpdate(entity, data));
100+
}
101+
102+
// ToDo: Does not trigger for some reason.
103+
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
104+
public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
105+
Entity entity = (Entity) (Object) this;
106+
107+
if (EventFlow.post(new EntityEvent.Damage(entity, source, amount)).isCanceled()) {
108+
cir.setReturnValue(false);
109+
}
98110
}
99111
}

0 commit comments

Comments
 (0)