Skip to content

Commit 41d4d4f

Browse files
Merge pull request #47 from Exterminate5573/master
Update for 1.21.11
2 parents e91117b + 58c3ccb commit 41d4d4f

36 files changed

Lines changed: 768 additions & 742 deletions

File tree

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ configure(
77

88
group = $group
99
version = $version
10-
archivesBaseName = $modBaseName
10+
tasks.withType(Jar).configureEach {
11+
archiveBaseName.set("${$modBaseName}")
12+
}
1113

1214
configurations {
1315
library

common/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ apply plugin: 'maven-publish'
22

33
group = $group
44
version = $version
5-
archivesBaseName = $commonBaseName
5+
tasks.withType(Jar).configureEach {
6+
archiveBaseName.set("${$commonBaseName}")
7+
}
68

79
dependencies {
810
compileOnly 'org.apache.logging.log4j:log4j-api:2.0-beta9'

common/src/test/java/CodeTesting.java

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
2-
id 'fabric-loom' version "1.11-SNAPSHOT"
2+
id 'fabric-loom' version "1.14-SNAPSHOT"
33

4-
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
4+
id "me.modmuss50.mod-publish-plugin" version "1.1.0"
55
}
66

77
loom.runs.client.runDir = "../runs/run"
88

99
dependencies {
1010
minecraft "com.mojang:minecraft:${project.minecraft_version}"
11-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
11+
mappings loom.officialMojangMappings()
1212
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
1313

1414
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
@@ -34,7 +34,7 @@ publishMods {
3434
modrinth {
3535
projectId = "412tAvWq"
3636
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
37-
minecraftVersions.add("1.21.9")
37+
minecraftVersions.add("1.21.11")
3838
}
3939
/*github {
4040
repository = "MPKMod/MPKMod2"
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Done to increase the memory available to gradle.
2-
org.gradle.jvmargs=-Xmx1G
2+
org.gradle.jvmargs=-Xmx3G
33
org.gradle.parallel=true
44

55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.9
8-
yarn_mappings=1.21.9+build.1
9-
loader_version=0.17.2
7+
minecraft_version=1.21.11
8+
loader_version=0.18.2
109

1110
# Fabric API
12-
fabric_version=0.133.14+1.21.9
11+
fabric_version=0.139.5+1.21.11
1312

1413
jdkVersion=21
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package io.github.kurrycat.mpkmod.compatibility.fabric_1_21_11;
2+
3+
import com.mojang.blaze3d.platform.InputConstants;
4+
import com.mojang.blaze3d.vertex.PoseStack;
5+
import io.github.kurrycat.mpkmod.compatibility.API;
6+
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player;
7+
import io.github.kurrycat.mpkmod.compatibility.fabric_1_21_11.mixin.KeyMappingAccessor;
8+
import io.github.kurrycat.mpkmod.ticks.ButtonMS;
9+
import io.github.kurrycat.mpkmod.ticks.ButtonMSList;
10+
import io.github.kurrycat.mpkmod.util.BoundingBox3D;
11+
import io.github.kurrycat.mpkmod.util.Vector3D;
12+
import net.fabricmc.fabric.api.networking.v1.PacketSender;
13+
import net.minecraft.client.DeltaTracker;
14+
import net.minecraft.client.Minecraft;
15+
import net.minecraft.client.Options;
16+
import net.minecraft.client.gui.GuiGraphics;
17+
import net.minecraft.client.input.KeyEvent;
18+
import net.minecraft.client.multiplayer.ClientPacketListener;
19+
import net.minecraft.client.player.LocalPlayer;
20+
import net.minecraft.util.Util;
21+
import net.minecraft.world.phys.AABB;
22+
import net.minecraft.world.phys.Vec3;
23+
24+
public class EventHandler {
25+
private static final ButtonMSList timeQueue = new ButtonMSList();
26+
27+
/**
28+
* @param keyInput The Minecraft {@link KeyEvent} object.
29+
* @param action The action, where 0 = unpressed, 1 = pressed, 2 = held.
30+
*/
31+
public void onKey(KeyEvent keyInput, int action) {
32+
Options options = Minecraft.getInstance().options;
33+
long eventNanos = Util.getNanos();
34+
35+
InputConstants.Key inputKey = InputConstants.getKey(new KeyEvent(keyInput.key(), keyInput.scancode(), keyInput.modifiers()));
36+
37+
int[] keys = {
38+
((KeyMappingAccessor) options.keyUp).getKey().getValue(),
39+
((KeyMappingAccessor) options.keyLeft).getKey().getValue(),
40+
((KeyMappingAccessor) options.keyDown).getKey().getValue(),
41+
((KeyMappingAccessor) options.keyRight).getKey().getValue(),
42+
((KeyMappingAccessor) options.keySprint).getKey().getValue(),
43+
((KeyMappingAccessor) options.keyShift).getKey().getValue(),
44+
((KeyMappingAccessor) options.keyJump).getKey().getValue()
45+
};
46+
47+
for (int i = 0; i < keys.length; i++) {
48+
if (keyInput.key() == keys[i]) {
49+
timeQueue.add(ButtonMS.of(ButtonMS.Button.values()[i], eventNanos, action == 1));
50+
}
51+
}
52+
53+
if (action == 1) {
54+
FunctionCompatibility.pressedButtons.add(inputKey.getValue());
55+
} else if (action == 0) {
56+
FunctionCompatibility.pressedButtons.remove(inputKey.getValue());
57+
}
58+
59+
API.Events.onKeyInput(keyInput.key(), inputKey.getDisplayName().getString(), action == 1);
60+
61+
MPKMod.keyBindingMap.forEach((id, keyBinding) -> {
62+
if (keyBinding.isDown()) {
63+
API.Events.onKeybind(id);
64+
}
65+
});
66+
}
67+
68+
public void onInGameOverlayRender(GuiGraphics drawContext, DeltaTracker renderTickCounter) {
69+
drawContext.pose().pushMatrix();
70+
API.<FunctionCompatibility>getFunctionHolder().drawContext = drawContext;
71+
API.Events.onRenderOverlay();
72+
drawContext.pose().popMatrix();
73+
}
74+
75+
public void onRenderWorldOverlay(PoseStack matrixStack, float tickDelta) {
76+
MPKMod.INSTANCE.matrixStack = matrixStack;
77+
matrixStack.pushPose();
78+
Vec3 pos = Minecraft.getInstance().gameRenderer.getMainCamera().position().reverse();
79+
MPKMod.INSTANCE.matrixStack.translate(pos);
80+
API.Events.onRenderWorldOverlay(tickDelta);
81+
matrixStack.popPose();
82+
}
83+
84+
public void onClientTickStart(Minecraft mc) {
85+
if (mc.isPaused() || mc.level == null) return;
86+
API.Events.onTickStart();
87+
}
88+
89+
public void onClientTickEnd(Minecraft mc) {
90+
if (mc.isPaused() || mc.level == null) return;
91+
LocalPlayer mcPlayer = mc.player;
92+
93+
if (mcPlayer != null) {
94+
AABB playerBB = mcPlayer.getBoundingBox();
95+
new Player()
96+
.setPos(new Vector3D(mcPlayer.getX(), mcPlayer.getY(), mcPlayer.getZ()))
97+
.setLastPos(new Vector3D(mcPlayer.xo, mcPlayer.yo, mcPlayer.zo))
98+
.setMotion(new Vector3D(mcPlayer.getDeltaMovement().x, mcPlayer.getDeltaMovement().y, mcPlayer.getDeltaMovement().z))
99+
.setRotation(mcPlayer.getRotationVector().y, mcPlayer.getRotationVector().x)
100+
.setOnGround(mcPlayer.onGround())
101+
.setSprinting(mcPlayer.isSprinting())
102+
.setBoundingBox(new BoundingBox3D(
103+
new Vector3D(playerBB.minX, playerBB.minY, playerBB.minZ),
104+
new Vector3D(playerBB.maxX, playerBB.maxY, playerBB.maxZ)
105+
))
106+
.setFlying(mcPlayer.getAbilities().flying)
107+
.constructKeyInput()
108+
.setKeyMSList(timeQueue)
109+
.buildAndSave();
110+
timeQueue.clear();
111+
}
112+
113+
API.Events.onTickEnd();
114+
}
115+
116+
117+
public void onServerConnect(ClientPacketListener clientPlayNetworkHandler, PacketSender packetSender, Minecraft minecraftClient) {
118+
API.Events.onServerConnect(clientPlayNetworkHandler.getConnection().isMemoryConnection());
119+
}
120+
121+
public void onServerDisconnect(ClientPacketListener clientPlayNetworkHandler, Minecraft minecraftClient) {
122+
API.Events.onServerDisconnect();
123+
}
124+
}

0 commit comments

Comments
 (0)