Skip to content
Merged
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
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ configure(

group = $group
version = $version
archivesBaseName = $modBaseName
tasks.withType(Jar).configureEach {
archiveBaseName.set("${$modBaseName}")
}

configurations {
library
Expand Down
4 changes: 3 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ apply plugin: 'maven-publish'

group = $group
version = $version
archivesBaseName = $commonBaseName
tasks.withType(Jar).configureEach {
archiveBaseName.set("${$commonBaseName}")
}

dependencies {
compileOnly 'org.apache.logging.log4j:log4j-api:2.0-beta9'
Expand Down
12 changes: 0 additions & 12 deletions common/src/test/java/CodeTesting.java

This file was deleted.

File renamed without changes.
8 changes: 4 additions & 4 deletions fabric-1.21.9/build.gradle → fabric-1.21.11/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
plugins {
id 'fabric-loom' version "1.11-SNAPSHOT"
id 'fabric-loom' version "1.14-SNAPSHOT"

id "me.modmuss50.mod-publish-plugin" version "0.8.4"
id "me.modmuss50.mod-publish-plugin" version "1.1.0"
}

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

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

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
Expand All @@ -34,7 +34,7 @@ publishMods {
modrinth {
projectId = "412tAvWq"
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
minecraftVersions.add("1.21.9")
minecraftVersions.add("1.21.11")
}
/*github {
repository = "MPKMod/MPKMod2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx3G
org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.9
yarn_mappings=1.21.9+build.1
loader_version=0.17.2
minecraft_version=1.21.11
loader_version=0.18.2

# Fabric API
fabric_version=0.133.14+1.21.9
fabric_version=0.139.5+1.21.11

jdkVersion=21
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package io.github.kurrycat.mpkmod.compatibility.fabric_1_21_11;

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import io.github.kurrycat.mpkmod.compatibility.API;
import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player;
import io.github.kurrycat.mpkmod.compatibility.fabric_1_21_11.mixin.KeyMappingAccessor;
import io.github.kurrycat.mpkmod.ticks.ButtonMS;
import io.github.kurrycat.mpkmod.ticks.ButtonMSList;
import io.github.kurrycat.mpkmod.util.BoundingBox3D;
import io.github.kurrycat.mpkmod.util.Vector3D;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.Options;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.util.Util;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

public class EventHandler {
private static final ButtonMSList timeQueue = new ButtonMSList();

/**
* @param keyInput The Minecraft {@link KeyEvent} object.
* @param action The action, where 0 = unpressed, 1 = pressed, 2 = held.
*/
public void onKey(KeyEvent keyInput, int action) {
Options options = Minecraft.getInstance().options;
long eventNanos = Util.getNanos();

InputConstants.Key inputKey = InputConstants.getKey(new KeyEvent(keyInput.key(), keyInput.scancode(), keyInput.modifiers()));

int[] keys = {
((KeyMappingAccessor) options.keyUp).getKey().getValue(),
((KeyMappingAccessor) options.keyLeft).getKey().getValue(),
((KeyMappingAccessor) options.keyDown).getKey().getValue(),
((KeyMappingAccessor) options.keyRight).getKey().getValue(),
((KeyMappingAccessor) options.keySprint).getKey().getValue(),
((KeyMappingAccessor) options.keyShift).getKey().getValue(),
((KeyMappingAccessor) options.keyJump).getKey().getValue()
};

for (int i = 0; i < keys.length; i++) {
if (keyInput.key() == keys[i]) {
timeQueue.add(ButtonMS.of(ButtonMS.Button.values()[i], eventNanos, action == 1));
}
}

if (action == 1) {
FunctionCompatibility.pressedButtons.add(inputKey.getValue());
} else if (action == 0) {
FunctionCompatibility.pressedButtons.remove(inputKey.getValue());
}

API.Events.onKeyInput(keyInput.key(), inputKey.getDisplayName().getString(), action == 1);

MPKMod.keyBindingMap.forEach((id, keyBinding) -> {
if (keyBinding.isDown()) {
API.Events.onKeybind(id);
}
});
}

public void onInGameOverlayRender(GuiGraphics drawContext, DeltaTracker renderTickCounter) {
drawContext.pose().pushMatrix();
API.<FunctionCompatibility>getFunctionHolder().drawContext = drawContext;
API.Events.onRenderOverlay();
drawContext.pose().popMatrix();
}

public void onRenderWorldOverlay(PoseStack matrixStack, float tickDelta) {
MPKMod.INSTANCE.matrixStack = matrixStack;
matrixStack.pushPose();
Vec3 pos = Minecraft.getInstance().gameRenderer.getMainCamera().position().reverse();
MPKMod.INSTANCE.matrixStack.translate(pos);
API.Events.onRenderWorldOverlay(tickDelta);
matrixStack.popPose();
}

public void onClientTickStart(Minecraft mc) {
if (mc.isPaused() || mc.level == null) return;
API.Events.onTickStart();
}

public void onClientTickEnd(Minecraft mc) {
if (mc.isPaused() || mc.level == null) return;
LocalPlayer mcPlayer = mc.player;

if (mcPlayer != null) {
AABB playerBB = mcPlayer.getBoundingBox();
new Player()
.setPos(new Vector3D(mcPlayer.getX(), mcPlayer.getY(), mcPlayer.getZ()))
.setLastPos(new Vector3D(mcPlayer.xo, mcPlayer.yo, mcPlayer.zo))
.setMotion(new Vector3D(mcPlayer.getDeltaMovement().x, mcPlayer.getDeltaMovement().y, mcPlayer.getDeltaMovement().z))
.setRotation(mcPlayer.getRotationVector().y, mcPlayer.getRotationVector().x)
.setOnGround(mcPlayer.onGround())
.setSprinting(mcPlayer.isSprinting())
.setBoundingBox(new BoundingBox3D(
new Vector3D(playerBB.minX, playerBB.minY, playerBB.minZ),
new Vector3D(playerBB.maxX, playerBB.maxY, playerBB.maxZ)
))
.setFlying(mcPlayer.getAbilities().flying)
.constructKeyInput()
.setKeyMSList(timeQueue)
.buildAndSave();
timeQueue.clear();
}

API.Events.onTickEnd();
}


public void onServerConnect(ClientPacketListener clientPlayNetworkHandler, PacketSender packetSender, Minecraft minecraftClient) {
API.Events.onServerConnect(clientPlayNetworkHandler.getConnection().isMemoryConnection());
}

public void onServerDisconnect(ClientPacketListener clientPlayNetworkHandler, Minecraft minecraftClient) {
API.Events.onServerDisconnect();
}
}
Loading