diff --git a/build.gradle b/build.gradle index 06d547f0..23756331 100644 --- a/build.gradle +++ b/build.gradle @@ -129,17 +129,20 @@ configure( // Fix unimined runs bug afterEvaluate { - runClient.doFirst { - var classPathFile = null - if (project.name.startsWith("forge")) classPathFile = "legacy_classpath" - if (project.name.startsWith("fabric")) classPathFile = "remapClasspath" - - if (classPathFile != null) { - logger.lifecycle("Fixing ${classPathFile}") - copy { - from "${rootProject.buildDir}/unimined/classpaths/${classPathFile}-${project.name}.txt" - into "${rootProject.buildDir}/unimined" - rename { "${classPathFile}.txt" } + def runClientTask = project.tasks.findByName('runClient') + if (runClientTask != null) { + runClientTask.doFirst { + var classPathFile = null + if (project.name.startsWith("forge")) classPathFile = "legacy_classpath" + if (project.name.startsWith("fabric")) classPathFile = "remapClasspath" + + if (classPathFile != null) { + logger.lifecycle("Fixing ${classPathFile}") + copy { + from "${rootProject.buildDir}/unimined/classpaths/${classPathFile}-${project.name}.txt" + into "${rootProject.buildDir}/unimined" + rename { "${classPathFile}.txt" } + } } } } diff --git a/common/src/main/java/io/github/kurrycat/mpkmod/gui/components/AnglePath.java b/common/src/main/java/io/github/kurrycat/mpkmod/gui/components/AnglePath.java index 98cd7929..c1274094 100644 --- a/common/src/main/java/io/github/kurrycat/mpkmod/gui/components/AnglePath.java +++ b/common/src/main/java/io/github/kurrycat/mpkmod/gui/components/AnglePath.java @@ -166,7 +166,7 @@ protected void updateDataPoints() { } int movementCount = p.deltaMouseX.length; - if (movementCount == 0) return; + if (movementCount == 0 || dataPoints.isEmpty()) return; int x = dataPoints.getFirst().x[dataPoints.getFirst().x.length - 1]; int y = dataPoints.getFirst().y[dataPoints.getFirst().y.length - 1]; diff --git a/fabric-26.3/build.gradle b/fabric-26.3/build.gradle index bdf03210..f58bc364 100644 --- a/fabric-26.3/build.gradle +++ b/fabric-26.3/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'net.fabricmc.fabric-loom' version "1.15-SNAPSHOT" + id 'net.fabricmc.fabric-loom' version "1.18-SNAPSHOT" id "me.modmuss50.mod-publish-plugin" version "1.1.0" } diff --git a/fabric-26.3/gradle.properties b/fabric-26.3/gradle.properties index 47b08425..e59df651 100644 --- a/fabric-26.3/gradle.properties +++ b/fabric-26.3/gradle.properties @@ -8,6 +8,6 @@ minecraft_version=26.3 loader_version=0.19.5 # Fabric API -fabric_version=0.160.5+26.3 +fabric_version=0.162.0+26.3 jdkVersion=25 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d205b54b..e51710be 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/ornithe-1.8.9/build.gradle b/ornithe-1.8.9/build.gradle new file mode 100644 index 00000000..c6c93b94 --- /dev/null +++ b/ornithe-1.8.9/build.gradle @@ -0,0 +1,49 @@ +plugins { + id 'net.fabricmc.fabric-loom-remap' version '1.18.3' + id 'ploceus' version '1.18.1' + id "me.modmuss50.mod-publish-plugin" version "1.1.0" +} + +loom { + runs.client.runDir = "../runs/run" +} + +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + mappings ploceus.featherMappings(project.feather_build) + + ploceus.dependOsl(project.osl_version) + + modImplementation "com.terraformersmc:modmenu:0.5.0+mc1.8.9" + + implementation "com.github.MPKMod.MPKNetworkAPI:common:${project.networkApiVersion}" +} + +processResources { + inputs.property 'version', version + + filesMatching('fabric.mod.json') { + expand 'version': version + } +} + +publishMods { + file = remapJar.archiveFile + changelog = "" + type = STABLE + version = project.version + modLoaders.add("ornithe") + + modrinth { + projectId = "412tAvWq" + accessToken = providers.environmentVariable("MODRINTH_TOKEN") + minecraftVersions.add("1.8.9") + } + /*github { + repository = "MPKMod/MPKMod2" + accessToken = providers.environmentVariable("GITHUB_TOKEN") + commitish = "main" + }*/ +} \ No newline at end of file diff --git a/ornithe-1.8.9/gradle.properties b/ornithe-1.8.9/gradle.properties new file mode 100644 index 00000000..5f2c50ce --- /dev/null +++ b/ornithe-1.8.9/gradle.properties @@ -0,0 +1,11 @@ +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx3G +org.gradle.parallel=true + +minecraft_version=1.8.9 +loader_version=0.19.5 +osl_version = 0.22.1 + +feather_build = 2 + +jdkVersion=8 diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/EventListener.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/EventListener.java new file mode 100644 index 00000000..571a5e6f --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/EventListener.java @@ -0,0 +1,130 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9; + +import io.github.kurrycat.mpkmod.compatibility.API; +import io.github.kurrycat.mpkmod.compatibility.MCClasses.InputConstants; +import io.github.kurrycat.mpkmod.compatibility.MCClasses.Player; +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.Mouse; +import io.github.kurrycat.mpkmod.util.Vector3D; +import net.minecraft.client.Minecraft; +import net.minecraft.client.options.GameOptions; +import net.minecraft.client.options.KeyBinding; +import net.minecraft.entity.Entity; +import net.minecraft.entity.living.player.PlayerEntity; +import net.minecraft.util.math.Box; +import net.ornithemc.osl.networking.api.client.ClientConnectionEvents; +import org.lwjgl.input.Keyboard; + +import java.util.Map; + +@SuppressWarnings("unused") +public class EventListener { + private static final ButtonMSList timeQueue = new ButtonMSList(); + + public static void onKey() { + int keyCode = Keyboard.getEventKey(); + String key = Keyboard.getKeyName(keyCode); + boolean pressed = Keyboard.getEventKeyState(); + + if (keyCode == 0) { + char c = Keyboard.getEventCharacter(); + keyCode = 256 + c; + key = String.valueOf(c); + } + + GameOptions gameSettings = Minecraft.getInstance().options; + + int[] keys = { + gameSettings.forwardKey.getKeyCode(), + gameSettings.leftKey.getKeyCode(), + gameSettings.backKey.getKeyCode(), + gameSettings.rightKey.getKeyCode(), + gameSettings.sprintKey.getKeyCode(), + gameSettings.sneakKey.getKeyCode(), + gameSettings.jumpKey.getKeyCode() + }; + + for (int i = 0; i < keys.length; i++) + if (keyCode == keys[i]) + timeQueue.add(ButtonMS.of(ButtonMS.Button.values()[i], Keyboard.getEventNanoseconds(), pressed)); + + + API.Events.onKeyInput(InputConstants.convert(keyCode), key, pressed); + + if (pressed) { + checkKeyBinding(keyCode); + } + } + + public static void onMouseEvent(int button, boolean buttonstate, int x, int y, int dx, int dy, int dwheel, long nanoseconds) { + API.Events.onMouseInput( + Mouse.Button.fromInt(button), + button == -1 ? Mouse.State.NONE : (buttonstate ? Mouse.State.DOWN : Mouse.State.UP), + x, y, dx, dy, + dwheel, nanoseconds + ); + + if (buttonstate) + checkKeyBinding(button - 100); + } + + private static void checkKeyBinding(int keyCode) { + if (Minecraft.getInstance().screen != null) return; + + for (Map.Entry keyBindingEntry : MPKMod.keyBindingMap.entrySet()) { + KeyBinding keyBinding = keyBindingEntry.getValue(); + String keyBindingId = keyBindingEntry.getKey(); + + if (keyBinding.getKeyCode() == keyCode) { + API.Events.onKeybind(keyBindingId); + return; + } + } + } + + public static void onTickStart(Minecraft mc) { + if (mc.isPaused() || mc.world == null) return; + API.Events.onTickStart(); + } + + public static void onTickEnd(Minecraft mc) { + if (mc.isPaused() || mc.world == null) return; + Entity cameraEntity = mc.getCamera(); + + if (cameraEntity != null) { + Box cameraEntityBB = cameraEntity.getShape(); + Player mpkPlayer = new Player() + .setPos(new Vector3D(cameraEntity.x, cameraEntity.y, cameraEntity.z)) + .setLastPos(new Vector3D(cameraEntity.lastX, cameraEntity.lastY, cameraEntity.lastZ)) + .setMotion(new Vector3D(cameraEntity.velocityX, cameraEntity.velocityY, cameraEntity.velocityZ)) + .setRotation(cameraEntity.yaw, cameraEntity.pitch) + .setOnGround(cameraEntity.onGround) + .setSprinting(cameraEntity.isSprinting()) + .setBoundingBox(new BoundingBox3D( + new Vector3D(cameraEntityBB.minX, cameraEntityBB.minY, cameraEntityBB.minZ), + new Vector3D(cameraEntityBB.maxX, cameraEntityBB.maxY, cameraEntityBB.maxZ) + )) + .constructKeyInput() + .setKeyMSList(timeQueue.copy()); + + if (cameraEntity instanceof PlayerEntity) { + mpkPlayer.setFlying(((PlayerEntity) cameraEntity).abilities.flying); + } + + mpkPlayer.buildAndSave(); + + timeQueue.clear(); + } + API.Events.onTickEnd(); + } + + public static void onServerConnect(ClientConnectionEvents.PlayReadyContext ctx) { + API.Events.onServerConnect(ctx.isServerLocal()); + } + + public static void onServerDisconnect(ClientConnectionEvents.DisconnectContext ctx) { + API.Events.onServerDisconnect(); + } +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/FunctionCompatibility.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/FunctionCompatibility.java new file mode 100644 index 00000000..e2d72adf --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/FunctionCompatibility.java @@ -0,0 +1,505 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9; + +import io.github.kurrycat.mpkmod.compatibility.API; +import io.github.kurrycat.mpkmod.compatibility.MCClasses.*; +import io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin.aw.LivingEntityAccessor; +import io.github.kurrycat.mpkmod.util.*; +import io.github.kurrycat.mpknetapi.common.network.packet.MPKPacket; +import net.minecraft.block.Block; +import net.minecraft.block.state.BlockState; +import net.minecraft.block.state.property.Property; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.living.player.LocalClientPlayerEntity; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.options.GameOptions; +import net.minecraft.client.options.ServerListEntry; +import net.minecraft.client.render.Window; +import net.minecraft.client.render.platform.GlStateManager; +import net.minecraft.client.render.vertex.BufferBuilder; +import net.minecraft.client.render.vertex.DefaultVertexFormat; +import net.minecraft.client.sound.instance.SimpleSoundInstance; +import net.minecraft.entity.Entity; +import net.minecraft.entity.living.LivingEntity; +import net.minecraft.resource.Identifier; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.MathHelper; +import net.minecraft.world.World; +import net.minecraft.world.gen.WorldGeneratorType; +import net.minecraft.client.render.vertex.Tesselator; +import net.ornithemc.osl.networking.api.client.ClientPlayNetworking; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +import java.awt.Color; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; +import java.util.*; +import java.util.List; +import java.util.stream.Collectors; + +public class FunctionCompatibility implements FunctionHolder, + SoundManager.Interface, + WorldInteraction.Interface, + Renderer3D.Interface, + Renderer2D.Interface, + FontRenderer.Interface, + io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.Interface, + io.github.kurrycat.mpkmod.compatibility.MCClasses.Keyboard.Interface, + Profiler.Interface { + private static final Stack scissorStack = new Stack<>(); + + /** + * Is called in {@link SoundManager.Interface} + */ + public void playButtonSound() { + Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.of(new Identifier("gui.button.press"), 1.0F)); + } + + /** + * Is called in {@link WorldInteraction.Interface} + */ + public List getCollisionBoundingBoxes(Vector3D blockPosVec) { + BlockPos blockPos = new BlockPos(blockPosVec.getX(), blockPosVec.getY(), blockPosVec.getZ()); + World world = Minecraft.getInstance().world; + BlockState blockState = world.getBlockState(blockPos); + Box mask = new Box(blockPosVec.getX() - 1, blockPosVec.getY() - 1, blockPosVec.getZ() - 1, blockPosVec.getX() + 1, blockPosVec.getY() + 1, blockPosVec.getZ() + 1); + ArrayList result = new ArrayList<>(); + blockState.getBlock().addCollisions(world, blockPos, blockState, mask, result, null); + + return result.stream().map((aabb) -> new BoundingBox3D(new Vector3D(aabb.minX, aabb.minY, aabb.minZ), new Vector3D(aabb.maxX, aabb.maxY, aabb.maxZ))).collect(Collectors.toList()); + } + + /** + * Is called in {@link WorldInteraction.Interface} + */ + public Vector3D getLookingAt() { + BlockPos blockPos = Minecraft.getInstance().player.rayTrace(20, 0).getPos(); + if (blockPos == null) return null; + return new Vector3D(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + } + + /** + * Is called in {@link WorldInteraction.Interface WorldInteraction.Interface} + */ + public String getBlockName(Vector3D blockPos) { + String blockName = ""; + //if (Minecraft.getMinecraft().objectMouseOver != null && Minecraft.getMinecraft().objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && Minecraft.getMinecraft().objectMouseOver.getBlockPos() != null && !(Minecraft.getMinecraft().thePlayer.hasReducedDebug() || Minecraft.getMinecraft().gameSettings.reducedDebugInfo)) { + BlockPos blockpos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + BlockState iblockstate = Minecraft.getInstance().world.getBlockState(blockpos); + if (Minecraft.getInstance().world.getGeneratorType() != WorldGeneratorType.DEBUG_ALL_BLOCK_STATES) { + iblockstate = iblockstate.getBlock().resolveVirtualProperties(iblockstate, Minecraft.getInstance().world, blockpos); + } + blockName = String.valueOf(Block.REGISTRY.getId(iblockstate.getBlock())); + //} + return blockName; + } + + public HashMap getBlockProperties(Vector3D blockPos) { + HashMap properties = new HashMap<>(); + BlockPos blockpos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); + BlockState iblockstate = Minecraft.getInstance().world.getBlockState(blockpos); + if (Minecraft.getInstance().world.getGeneratorType() != WorldGeneratorType.DEBUG_ALL_BLOCK_STATES) { + iblockstate = iblockstate.getBlock().resolveVirtualProperties(iblockstate, Minecraft.getInstance().world, blockpos); + } + //noinspection rawtypes + for (Map.Entry e : iblockstate.values().entrySet()) { + properties.put(e.getKey().getName(), e.getValue().toString()); + } + return properties; + } + + /** + * Is called in {@link Renderer3D.Interface} + */ + public void drawBox(BoundingBox3D bb, Color color, float partialTicks) { + int r = color.getRed(), g = color.getGreen(), b = color.getBlue(), a = color.getAlpha(); + + GlStateManager.pushMatrix(); + GlStateManager.disableTexture(); + GlStateManager.disableAlphaTest(); + GlStateManager.enableBlend(); + GL11.glLineWidth(2.0F); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + + Tesselator tesselator = Tesselator.getInstance(); + BufferBuilder wr = tesselator.getBuffer(); + + Entity entity = Minecraft.getInstance().getCamera(); + + double entityX = entity.lastX + (entity.x - entity.lastX) * (double) partialTicks; + double entityY = entity.lastY + (entity.y - entity.lastY) * (double) partialTicks; + double entityZ = entity.lastZ + (entity.z - entity.lastZ) * (double) partialTicks; + + wr.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR); + wr.offset(-entityX, -entityY, -entityZ); + + wr.vertex(bb.minX(), bb.maxY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.maxY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.minY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.minY(), bb.minZ()).color(r, g, b, a).nextVertex(); + + wr.vertex(bb.minX(), bb.minY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.minY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.maxY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.maxY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + + wr.vertex(bb.minX(), bb.minY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.minY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.minY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.minY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + + wr.vertex(bb.minX(), bb.maxY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.maxY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.maxY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.maxY(), bb.minZ()).color(r, g, b, a).nextVertex(); + + wr.vertex(bb.minX(), bb.minY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.maxY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.maxY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.minX(), bb.minY(), bb.minZ()).color(r, g, b, a).nextVertex(); + + wr.vertex(bb.maxX(), bb.minY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.maxY(), bb.minZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.maxY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + wr.vertex(bb.maxX(), bb.minY(), bb.maxZ()).color(r, g, b, a).nextVertex(); + + wr.offset(0, 0, 0); + + tesselator.end(); + + GlStateManager.enableTexture(); + GlStateManager.enableAlphaTest(); + GlStateManager.disableBlend(); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GlStateManager.popMatrix(); + } + + /** + * Is called in {@link Renderer2D.Interface} + */ + public void drawRect(Vector2D pos, Vector2D size, Color color) { + int r = color.getRed(), g = color.getGreen(), b = color.getBlue(), a = color.getAlpha(); + double x = pos.getX(), y = pos.getY(), w = size.getX(), h = size.getY(); + + Tesselator tesselator = Tesselator.getInstance(); + BufferBuilder wr = tesselator.getBuffer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture(); + //GlStateManager.shadeModel(GL11.GL_SMOOTH); // - for gradients + wr.begin(GL11.GL_QUADS, DefaultVertexFormat.POSITION_COLOR); + wr.vertex(x, y + h, 0.0).color(r, g, b, a).nextVertex(); + wr.vertex(x + w, y + h, 0.0).color(r, g, b, a).nextVertex(); + wr.vertex(x + w, y, 0.0).color(r, g, b, a).nextVertex(); + wr.vertex(x, y, 0.0).color(r, g, b, a).nextVertex(); + tesselator.end(); + //GlStateManager.shadeModel(GL11.GL_FLAT); + GlStateManager.enableTexture(); + GlStateManager.disableBlend(); + } + + /** + * Is called in {@link Renderer2D.Interface} + */ + public void drawLines(Collection points, Color color) { + if (points.size() < 2) { + Debug.stacktrace("At least two points expected, got: " + points.size()); + return; + } + int r = color.getRed(), g = color.getGreen(), b = color.getBlue(), a = color.getAlpha(); + + GlStateManager.pushMatrix(); + GlStateManager.disableTexture(); + GlStateManager.disableAlphaTest(); + GlStateManager.enableBlend(); + GL11.glLineWidth(1.0F); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + + Tesselator tessellator = Tesselator.getInstance(); + BufferBuilder wr = tessellator.getBuffer(); + + wr.begin(GL11.GL_LINE_STRIP, DefaultVertexFormat.POSITION_COLOR); + + for (Vector2D p : points) { + wr.vertex(p.getX(), p.getY(), 0).color(r, g, b, a).nextVertex(); + } + + wr.offset(0, 0, 0); + + tessellator.end(); + + GlStateManager.enableTexture(); + GlStateManager.enableAlphaTest(); + GlStateManager.disableBlend(); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GlStateManager.popMatrix(); + } + + /** + * Is called in {@link Renderer2D.Interface} + */ + public Vector2D getScaledSize() { + Window r = new Window(Minecraft.getInstance()); + return new Vector2D( + r.getScaledWidth(), + r.getScaledHeight() + ); + } + + public Vector2D getScreenSize() { + return new Vector2D(Minecraft.getInstance().width, Minecraft.getInstance().height); + } + + public void enableScissor(double x, double y, double w, double h) { + ScissorBox box; + if (scissorStack.isEmpty()) box = new ScissorBox(x, y, w, h); + else { + ScissorBox prev = scissorStack.peek(); + double bx = Math.max(prev.x, x), by = Math.max(prev.y, y); + box = new ScissorBox(bx, by, + Math.min(x + w, prev.x + prev.w) - bx, + Math.min(y + h, prev.y + prev.h) - by + ); + } + scissorStack.push(box); + setScissor(box); + } + + public void disableScissor() { + if (!scissorStack.isEmpty()) scissorStack.pop(); + if (scissorStack.isEmpty()) setScissor(null); + else setScissor(scissorStack.peek()); + } + + public void clearScissors() { + scissorStack.clear(); + setScissor(null); + } + + private void setScissor(ScissorBox box) { + if (box == null) { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } else { + GL11.glEnable(GL11.GL_SCISSOR_TEST); + + Window r = new Window(Minecraft.getInstance()); + + double scaleFactor = r.getScale(); + double posX = box.x * scaleFactor; + double posY = Minecraft.getInstance().height - (box.y + box.h) * scaleFactor; + double width = box.w * scaleFactor; + double height = box.h * scaleFactor; + GL11.glScissor((int) posX, (int) posY, Math.max(0, (int) width), Math.max(0, (int) height)); + } + } + + public boolean scissorContains(Vector2D point) { + return scissorStack.isEmpty() || scissorStack.peek().contains(point); + } + + /** + * Is called in {@link FontRenderer.Interface} + */ + public void drawString(String text, double x, double y, Color color, double fontSize, boolean shadow) { + GlStateManager.enableBlend(); + GlStateManager.pushMatrix(); + GlStateManager.translated(x, y, 0); + double scale = fontSize / (Minecraft.getInstance().textRenderer.fontHeight * 1F); + GlStateManager.scaled(scale, scale, 1); + Minecraft.getInstance().textRenderer.draw(text, 0, 0, color.getRGB(), shadow); + GlStateManager.popMatrix(); + GlStateManager.disableBlend(); + } + + /** + * Is called in {@link FontRenderer.Interface} + */ + public Vector2D getStringSize(String text, double fontSize) { + double scale = fontSize / (Minecraft.getInstance().textRenderer.fontHeight * 1F); + return new Vector2D( + Minecraft.getInstance().textRenderer.getWidth(text) * scale, + fontSize + ); + } + + /** + * Is called in {@link io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.Interface Minecraft.Interface} + */ + public String getIP() { + ServerListEntry d = Minecraft.getInstance().getCurrentServerEntry(); + if (d == null) return "Multiplayer"; + else return d.ip; + } + + /** + * Is called in {@link io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.Interface Minecraft.Interface} + */ + public String getFPS() { + return String.valueOf(Minecraft.getCurrentFps()); + } + + public int getPing() { + return Minecraft.getInstance().getNetworkHandler().getOnlinePlayer(Minecraft.getInstance().player.getUuid()).getPing(); + } + + /** + * Is called in {@link io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.Interface Minecraft.Interface} + */ + public void displayGuiScreen(io.github.kurrycat.mpkmod.gui.MPKGuiScreen screen) { + Minecraft.getInstance().executeTask(() -> + Minecraft.getInstance().openScreen( + screen == null ? null : new MPKGuiScreen(screen))); + } + + /** + * Is called in {@link io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.Interface Minecraft.Interface} + */ + public String getCurrentGuiScreen() { + Screen curr = Minecraft.getInstance().screen; + if (curr == null) return null; + else if (curr instanceof MPKGuiScreen) { + String id = ((MPKGuiScreen) curr).eventReceiver.getID(); + if (id == null) id = "unknown"; + return id; + } + return curr.getClass().getSimpleName(); + } + + /** + * Is called in {@link io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.Interface Minecraft.Interface} + */ + public String getUserName() { + if (Minecraft.getInstance().player == null) return null; + return Minecraft.getInstance().player.getName(); + } + + public void copyToClipboard(String content) { + StringSelection selection = new StringSelection(content); + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + clipboard.setContents(selection, selection); + } + + public boolean isF3Enabled() { + return Minecraft.getInstance().options.debugEnabled; + } + + public void sendPacket(MPKPacket packet) { + ClientPlayNetworking.send(MPKMod.MPK_ID, packet.getData()); + } + + public boolean setInputs(Float yaw, boolean relYaw, Float pitch, boolean relPitch, int pressedInputs, int releasedInputs, int L, int R) { + if (!io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.isSingleplayer()) return false; + LocalClientPlayerEntity player = Minecraft.getInstance().player; + GameOptions gs = Minecraft.getInstance().options; + + float prevPitch = player.pitch; + float prevYaw = player.yaw; + + if (yaw != null) { + player.yaw = relYaw ? (float) ((double) player.yaw + (double) yaw) : yaw; + player.lastYaw += player.yaw - prevYaw; + } + if (pitch != null) { + player.pitch = relPitch ? (float) ((double) player.pitch - (double) pitch) : pitch; + player.pitch = MathHelper.clamp(player.pitch, -90.0F, 90.0F); + player.lastPitch += player.pitch - prevPitch; + } + + int[] keys = new int[]{ + gs.forwardKey.getKeyCode(), + gs.leftKey.getKeyCode(), + gs.backKey.getKeyCode(), + gs.rightKey.getKeyCode(), + gs.sprintKey.getKeyCode(), + gs.sneakKey.getKeyCode(), + gs.jumpKey.getKeyCode() + }; + + for (int i = 0; i < keys.length; i++) { + if ((releasedInputs & 1 << i) != 0) { + net.minecraft.client.options.KeyBinding.set(keys[i], false); + } + if ((pressedInputs & 1 << i) != 0) { + net.minecraft.client.options.KeyBinding.set(keys[i], true); + net.minecraft.client.options.KeyBinding.click(keys[i]); + } + } + + net.minecraft.client.options.KeyBinding.set(gs.attackKey.getKeyCode(), L > 0); + for (int i = 0; i < L; i++) + net.minecraft.client.options.KeyBinding.click(gs.attackKey.getKeyCode()); + + net.minecraft.client.options.KeyBinding.set(gs.useKey.getKeyCode(), R > 0); + for (int i = 0; i < R; i++) + net.minecraft.client.options.KeyBinding.click(gs.useKey.getKeyCode()); + + return true; + } + + /** + * Is called in {@link io.github.kurrycat.mpkmod.compatibility.MCClasses.Keyboard.Interface Keyboard.Interface} + */ + public List getPressedButtons() { + List keysDown = new ArrayList<>(); + for (int i = 0; i < Keyboard.getKeyCount(); i++) + if (Keyboard.isKeyDown(i)) + keysDown.add(InputConstants.convert(i)); + return keysDown; + } + + /** + * Is called in {@link Profiler.Interface} + */ + public void startSection(String name) { + Minecraft.getInstance().profiler.push(name); + } + + /** + * Is called in {@link Profiler.Interface} + */ + public void endStartSection(String name) { + Minecraft.getInstance().profiler.getResults(name); + } + + /** + * Is called in {@link Profiler.Interface} + */ + public void endSection() { + Minecraft.getInstance().profiler.pop(); + } + + @Override + public Player.KeyInput getKeyInput() { + Entity ce = Minecraft.getInstance().getCamera(); + if (!(ce instanceof LivingEntity)) return new Player.KeyInput(); + + boolean w, a, s, d, sprint, sneak, jump; + if (ce instanceof LocalClientPlayerEntity) { + GameOptions gs = Minecraft.getInstance().options; + + w = gs.forwardKey.isPressed(); + a = gs.leftKey.isPressed(); + s = gs.backKey.isPressed(); + d = gs.rightKey.isPressed(); + + sprint = gs.sprintKey.isPressed(); + sneak = gs.sneakKey.isPressed(); + jump = gs.jumpKey.isPressed(); + } else { + LivingEntity elb = (LivingEntity) ce; + + w = elb.forwardSpeed > 0; + a = elb.sidewaysSpeed > 0; + s = elb.forwardSpeed < 0; + d = elb.sidewaysSpeed < 0; + + sprint = elb.isSprinting(); + sneak = elb.isSneaking(); + + jump = ((LivingEntityAccessor) elb).isJumping(); + } + + return new Player.KeyInput(w, a, s, d, sprint, sneak, jump); + } +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKGuiScreen.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKGuiScreen.java new file mode 100644 index 00000000..b4b1262e --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKGuiScreen.java @@ -0,0 +1,110 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9; + +import io.github.kurrycat.mpkmod.compatibility.API; +import io.github.kurrycat.mpkmod.compatibility.MCClasses.InputConstants; +import io.github.kurrycat.mpkmod.compatibility.MCClasses.Profiler; +import io.github.kurrycat.mpkmod.util.Vector2D; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.render.Window; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +public class MPKGuiScreen extends Screen { + public boolean repeatEventsEnabled; + public io.github.kurrycat.mpkmod.gui.MPKGuiScreen eventReceiver; + + public MPKGuiScreen(io.github.kurrycat.mpkmod.gui.MPKGuiScreen screen) { + super(); + eventReceiver = screen; + } + + public static int createModifiers() { + int i = 0; + if (Screen.isShiftDown()) i |= 1; + if (Screen.isControlDown()) i |= 2; + if (Screen.isAltDown()) i |= 4; + return i; + } + + @Override + public void init() { + repeatEventsEnabled = Keyboard.areRepeatEventsEnabled(); + Keyboard.enableRepeatEvents(true); + super.init(); + eventReceiver.onInit(); + } + + @Override + public void resize(Minecraft mcIn, int width, int height) { + super.resize(mcIn, width, height); + eventReceiver.onResize(width, height); + } + + @Override + public void render(int mouseX, int mouseY, float partialTicks) { + Profiler.startSection(eventReceiver.getID() == null ? "unknown" : eventReceiver.getID()); + try { + eventReceiver.drawScreen(new Vector2D(mouseX, mouseY), partialTicks); + } catch (Exception e) { + API.LOGGER.warn("Error in drawScreen with id: " + eventReceiver.getID(), e); + } + Profiler.endSection(); + } + + @Override + public void removed() { + Keyboard.enableRepeatEvents(repeatEventsEnabled); + super.removed(); + eventReceiver.onGuiClosed(); + } + + @Override + protected void keyPressed(char typedChar, int keyCode) { + super.keyPressed(typedChar, keyCode); + char c = Keyboard.getEventCharacter(); + + eventReceiver.onKeyEvent(InputConstants.convert(Keyboard.getEventKey()), 0, createModifiers(), false); + if (c >= 32 && c != 127) + eventReceiver.onKeyEvent(c, 0, createModifiers(), true); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { + super.mouseClicked(mouseX, mouseY, mouseButton); + eventReceiver.onMouseClicked(new Vector2D(mouseX, mouseY), io.github.kurrycat.mpkmod.util.Mouse.Button.fromInt(mouseButton)); + } + + @Override + protected void mouseDragged(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseDragged(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + eventReceiver.onMouseClickMove(new Vector2D(mouseX, mouseY), io.github.kurrycat.mpkmod.util.Mouse.Button.fromInt(clickedMouseButton), timeSinceLastClick); + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + eventReceiver.onMouseReleased(new Vector2D(mouseX, mouseY), io.github.kurrycat.mpkmod.util.Mouse.Button.fromInt(state)); + } + + @Override + public void handleMouse() { + super.handleMouse(); + + if (Mouse.getEventDWheel() != 0) { + Window scaledresolution = new Window(this.minecraft); + eventReceiver.onMouseScroll( + new Vector2D( + Mouse.getX() * scaledresolution.getScaledWidth() / this.minecraft.width, + scaledresolution.getScaledHeight() - Mouse.getY() * scaledresolution.getScaledHeight() / this.minecraft.height - 1 + ), + Mouse.getEventDWheel() / 40 + ); + } + } + + @Override + public boolean shouldPauseGame() { + return false; + } +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKMod.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKMod.java new file mode 100644 index 00000000..cf4624fd --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKMod.java @@ -0,0 +1,94 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9; + +import io.github.kurrycat.mpkmod.compatibility.API; +import io.github.kurrycat.mpknetapi.common.MPKNetworking; +import io.github.kurrycat.mpknetapi.common.network.packet.MPKPacket; +import net.fabricmc.api.ModInitializer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.options.GameOptions; +import net.minecraft.client.options.KeyBinding; +import net.minecraft.resource.Identifier; +import net.ornithemc.osl.core.api.util.NamespacedIdentifier; +import net.ornithemc.osl.core.impl.util.MinecraftVersion; +import net.ornithemc.osl.keybinds.api.KeybindEvents; +import net.ornithemc.osl.keybinds.api.KeybindRegistry; +import net.ornithemc.osl.lifecycle.api.client.MinecraftClientEvents; +import net.ornithemc.osl.networking.api.ChannelRegistry; +import net.ornithemc.osl.networking.api.client.ClientConnectionEvents; +import net.ornithemc.osl.networking.api.client.ClientPlayNetworking; +import org.lwjgl.input.Keyboard; + +import java.util.HashMap; +import java.util.Map; + +public class MPKMod implements ModInitializer { + + public static NamespacedIdentifier MPK_ID = new Identifier(MPKNetworking.CHANNEL_NAMESPACE, MPKNetworking.CHANNEL_PATH); + + public static Map keyBindingMap = new HashMap<>(); + + @Override + public void onInitialize() { + API.LOGGER.info("Loading " + API.NAME + " " + API.VERSION); + API.preInit(getClass()); + + MinecraftClientEvents.TICK_START.register(EventListener::onTickStart); + MinecraftClientEvents.TICK_END.register(EventListener::onTickEnd); + ClientConnectionEvents.PLAY_READY.register(EventListener::onServerConnect); + ClientConnectionEvents.DISCONNECT.register(EventListener::onServerDisconnect); + + KeybindEvents.REGISTER_KEYBINDS.register(() -> { + API.guiScreenMap.forEach((id, guiScreen) -> { + if (guiScreen.shouldCreateKeyBind()) + registerKeyBinding(id); + }); + + API.keyBindingMap.forEach((id, consumer) -> registerKeyBinding(id)); + }); + + ChannelRegistry.register(MPK_ID); + ClientPlayNetworking.registerListener(MPK_ID, (context, payload) -> { + byte[] data = new byte[payload.readableBytes()]; + payload.readBytes(data); + MPKPacket packet = MPKPacket.handle(API.PACKET_LISTENER_CLIENT, data, null); + if (packet != null) { + API.Events.onPluginMessage(packet); + } + }); + } + + public static void onPostInit() { + API.LOGGER.info(API.COMPATIBILITY_MARKER, "Registering compatibility functions..."); + API.registerFunctionHolder(new FunctionCompatibility()); + API.LOGGER.info(API.COMPATIBILITY_MARKER, "Done"); + + registerKeyBindings(); + API.init(MinecraftVersion.resolve().semanticVersion()); + + API.Events.onLoadComplete(); + } + + public static void registerKeyBinding(String id) { + KeyBinding keyBinding = new KeyBinding( + API.MODID + ".key." + id + ".desc", + Keyboard.KEY_NONE, + API.KEYBINDING_CATEGORY + ); + keyBindingMap.put(id, keyBinding); + KeybindRegistry.register(keyBinding); + } + + private static void registerKeyBindings() { + for (KeyBinding k : Minecraft.getInstance().options.keyBindings) { + new io.github.kurrycat.mpkmod.compatibility.MCClasses.KeyBinding( + () -> GameOptions.getKeyName(k.getKeyCode()), + k.getName(), + () -> GameOptions.isPressed(k) + ); + } + API.LOGGER.info(API.COMPATIBILITY_MARKER, "Registered {} Keybindings", + io.github.kurrycat.mpkmod.compatibility.MCClasses.KeyBinding.getKeyMap().size()); + } + + +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKModMenu.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKModMenu.java new file mode 100644 index 00000000..e36bfe61 --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/MPKModMenu.java @@ -0,0 +1,14 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9; + +import com.terraformersmc.modmenu.api.ConfigScreenFactory; +import com.terraformersmc.modmenu.api.ModMenuApi; +import io.github.kurrycat.mpkmod.Main; + +public class MPKModMenu implements ModMenuApi { + + @Override + public ConfigScreenFactory getModConfigScreenFactory() { + return parent -> new MPKGuiScreen(Main.mainGUI); + } + +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinGameGui.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinGameGui.java new file mode 100644 index 00000000..113e6947 --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinGameGui.java @@ -0,0 +1,23 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin; + +import com.llamalad7.mixinextras.expression.Definition; +import com.llamalad7.mixinextras.expression.Expression; +import io.github.kurrycat.mpkmod.compatibility.API; +import net.minecraft.client.gui.GameGui; +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(GameGui.class) +public class MixinGameGui { + + @Definition(id = "overlayMessageCooldown", field = "Lnet/minecraft/client/gui/GameGui;overlayMessageCooldown:I") + @Expression("this.overlayMessageCooldown > 0") + @Inject(method = "render(F)V", at = @At(value = "MIXINEXTRAS:EXPRESSION", shift = At.Shift.BEFORE)) + public void onRenderGameOverlay(float tickDelta, CallbackInfo ci) { + API.Events.onRenderOverlay(); + } + + +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinGameRenderer.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinGameRenderer.java new file mode 100644 index 00000000..84663bdb --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinGameRenderer.java @@ -0,0 +1,22 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin; + +import com.llamalad7.mixinextras.sugar.Local; +import io.github.kurrycat.mpkmod.compatibility.API; +import net.minecraft.client.render.GameRenderer; +import net.minecraft.util.profiler.Profiler; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(GameRenderer.class) +public class MixinGameRenderer { + + @Redirect(method = "render(IFJ)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V")) + private void onRenderLast(Profiler profiler, String name, @Local(argsOnly = true) float tickDelta) { + if (name.equals("hand")) { // Inject before rendering the hand + API.Events.onRenderWorldOverlay(tickDelta); + } + profiler.swap(name); + } + +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinMinecraft.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinMinecraft.java new file mode 100644 index 00000000..2b543057 --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinMinecraft.java @@ -0,0 +1,39 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin; + +import io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.EventListener; +import io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.MPKMod; +import net.minecraft.client.Minecraft; +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(Minecraft.class) +public class MixinMinecraft { + + @Inject(method = "init", at = @At("TAIL")) + private void onInit(CallbackInfo ci) { + MPKMod.onPostInit(); + } + + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Mouse;getEventButton()I")) + private void onMouse(CallbackInfo ci) { + int eventButton = org.lwjgl.input.Mouse.getEventButton(); + boolean buttonstate = org.lwjgl.input.Mouse.getEventButtonState(); + int x = org.lwjgl.input.Mouse.getEventX(); + int y = org.lwjgl.input.Mouse.getEventY(); + int dx = org.lwjgl.input.Mouse.getEventDX(); + int dy = org.lwjgl.input.Mouse.getEventDY(); + int dwheel = org.lwjgl.input.Mouse.getEventDWheel(); + long nanoseconds = org.lwjgl.input.Mouse.getEventNanoseconds(); + + EventListener.onMouseEvent(eventButton, buttonstate, x, y, dx, dy, dwheel, nanoseconds); + } + + @Inject(method = "tick", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventKey()I", ordinal = 0)) + private void onKey(CallbackInfo ci) { + EventListener.onKey(); + } + +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinToggleSprintKey.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinToggleSprintKey.java new file mode 100644 index 00000000..8031a6c3 --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/MixinToggleSprintKey.java @@ -0,0 +1,22 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.options.KeyBinding; +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.CallbackInfoReturnable; + +@Mixin(KeyBinding.class) +public class MixinToggleSprintKey { + + @Inject(method = "isPressed", at = @At("HEAD"), cancellable = true) + private void sprintOverride(CallbackInfoReturnable cir) { + KeyBinding self = (KeyBinding) (Object) this; + KeyBinding sprintKey = Minecraft.getInstance().options.sprintKey; + + if (self == sprintKey && io.github.kurrycat.mpkmod.compatibility.MCClasses.Minecraft.isSprintToggled()) + cir.setReturnValue(true); + } + +} diff --git a/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/aw/LivingEntityAccessor.java b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/aw/LivingEntityAccessor.java new file mode 100644 index 00000000..69ac2105 --- /dev/null +++ b/ornithe-1.8.9/src/main/java/io/github/kurrycat/mpkmod/compatibility/ornithe_1_8_9/mixin/aw/LivingEntityAccessor.java @@ -0,0 +1,13 @@ +package io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin.aw; + +import net.minecraft.entity.living.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(LivingEntity.class) +public interface LivingEntityAccessor { + + @Accessor("jumping") + boolean isJumping(); + +} diff --git a/ornithe-1.8.9/src/main/resources/assets/mpkmod/lang/en_US.lang b/ornithe-1.8.9/src/main/resources/assets/mpkmod/lang/en_US.lang new file mode 100644 index 00000000..52d01e9e --- /dev/null +++ b/ornithe-1.8.9/src/main/resources/assets/mpkmod/lang/en_US.lang @@ -0,0 +1,8 @@ +mpkmod.key.category=MPK Mod 2 +mpkmod.key.main_gui.desc=Open MPK Mod GUI +mpkmod.key.lb_gui.desc=Open Landing Block GUI +mpkmod.key.lb_set.desc=Set Landing Block +mpkmod.key.options_gui.desc=Open Options GUI +mpkmod.key.togglesprint.desc=Toggle Sprint +mpkmod.main_gui.title=MPK Mod GUI +mpkmod.lb_gui.title=Landing Block GUI \ No newline at end of file diff --git a/ornithe-1.8.9/src/main/resources/assets/mpkmod/lang/pl_PL.lang b/ornithe-1.8.9/src/main/resources/assets/mpkmod/lang/pl_PL.lang new file mode 100644 index 00000000..fe4ca2b7 --- /dev/null +++ b/ornithe-1.8.9/src/main/resources/assets/mpkmod/lang/pl_PL.lang @@ -0,0 +1,6 @@ +mpkmod.key.lb_gui.desc=Otwórz menu Bloku Lądowania +mpkmod.key.lb_set.desc=Ustaw Blok Lądowania +mpkmod.key.main_gui.desc=Otwórz menu MPK +mpkmod.key.options_gui.desc=Otwórz menu opcji +mpkmod.lb_gui.title=Menu Bloku Lądowania +mpkmod.main_gui.title=Menu MPK \ No newline at end of file diff --git a/ornithe-1.8.9/src/main/resources/fabric.mod.json b/ornithe-1.8.9/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..7ae03c7f --- /dev/null +++ b/ornithe-1.8.9/src/main/resources/fabric.mod.json @@ -0,0 +1,35 @@ +{ + "schemaVersion": 1, + "id": "mpkmod", + "version": "${version}", + "name": "MPK Mod", + "description": "A Mod that adds some features that help parkour to the game.", + "authors": [ + "kurrycat", + "Exterminate", + "Zpiboo", + "Contributors" + ], + "contact": { + "sources": "https://github.com/MPKMod/MPKMod2" + }, + "license": "MIT", + "icon": "mpkmod_logo.png", + "environment": "client", + "entrypoints": { + "main": [ + "io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.MPKMod" + ], + "modmenu": [ + "io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.MPKModMenu" + ] + }, + "mixins": [ + "mpkmod.mixins.json" + ], + "depends": { + "fabricloader": ">=0.19.5", + "minecraft": "1.8.9", + "osl-entrypoints": ">=0.4.0" + } +} \ No newline at end of file diff --git a/ornithe-1.8.9/src/main/resources/mpkmod.mixins.json b/ornithe-1.8.9/src/main/resources/mpkmod.mixins.json new file mode 100644 index 00000000..e05e4277 --- /dev/null +++ b/ornithe-1.8.9/src/main/resources/mpkmod.mixins.json @@ -0,0 +1,17 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "io.github.kurrycat.mpkmod.compatibility.ornithe_1_8_9.mixin", + "compatibilityLevel": "JAVA_8", + "mixinextras": {"minVersion": "0.5.5"}, + "client": [ + "aw.LivingEntityAccessor", + "MixinGameGui", + "MixinGameRenderer", + "MixinMinecraft", + "MixinToggleSprintKey" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index f7b82df8..86d69959 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,10 @@ pluginManagement { name = "FabricMaven" url = uri("https://maven.fabricmc.net/") } + maven { + name = "Ornithe Releases" + url = uri("https://maven.ornithemc.net/releases") + } mavenCentral() gradlePluginPortal() } @@ -25,6 +29,7 @@ include("common") if (System.getenv("JITPACK") == null) { include("forge-1.8.9") + include("ornithe-1.8.9") include("forge-1.12.2") include("fabric-26.3") } \ No newline at end of file