Skip to content

Commit

Permalink
Setup architectury
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Dec 17, 2023
1 parent 1855ecb commit 0bcb0aa
Show file tree
Hide file tree
Showing 56 changed files with 443 additions and 666 deletions.
135 changes: 118 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,118 @@
# Project exclude paths
/.gradle/
/build/
/build/classes/java/main/
/run/
/.idea/
/artifacts/

/fabric/build/
/forge/build/
/neoforge/build/
/fabric/.gradle/
/forge/.gradle/
/neoforge/.gradle/
/fabric/run/
/forge/run/
/neoforge/run/
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Cache of project
.gradletasknamecache

**/build/

# Common working directory
run/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
40 changes: 37 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
import net.fabricmc.loom.api.LoomGradleExtensionAPI

plugins {
java
id("architectury-plugin") version "3.4-SNAPSHOT"
id("dev.architectury.loom") version "1.4-SNAPSHOT" apply false
}

val modVersion: String by extra
val minecraftVersion: String by extra

architectury {
minecraft = minecraftVersion
}

subprojects {
apply(plugin = "dev.architectury.loom")

base.archivesName.set("PacketFixer-" + project.name)

configure<LoomGradleExtensionAPI> {
silentMojangMappingsLicense()
}

dependencies {
"minecraft"("com.mojang:minecraft:$minecraftVersion")
"mappings"(project.the<LoomGradleExtensionAPI>().officialMojangMappings())
}
}

allprojects {
apply(plugin = "java")
apply(plugin = "architectury-plugin")

version = "$modVersion-$minecraftVersion"
group = "net.tonimatasdev"
version = modVersion
group = "dev.tonimatas"

base.archivesName.set("PacketFixer-" + project.name)
repositories {

}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

java {
withSourcesJar()
}
}
9 changes: 9 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
val fabricLoaderVersion: String by extra

dependencies {
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")
}

architectury {
common("fabric", "forge", "neoforge")
}
10 changes: 10 additions & 0 deletions common/src/main/java/dev/tonimatas/packetfixer/PacketFixer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.tonimatas.packetfixer;

import com.mojang.logging.LogUtils;
public class PacketFixer {
public static final String MOD_ID = "packetfixer";

public static void init() {
LogUtils.getLogger().info("Packet Fixer has been initialized successfully");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;


import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.network.protocol.login.ClientboundCustomQueryPacket;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.network.CompressionDecoder;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import com.mojang.logging.LogUtils;
import net.neoforged.fml.loading.FMLLoader;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand All @@ -23,13 +22,14 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
boolean krypton = FMLLoader.getLoadingModList().getModFileById("krypton") != null || FMLLoader.getLoadingModList().getModFileById("pluto") != null;
// TODO: Fix this
//boolean krypton = FMLLoader.getLoadingModList().getModFileById("krypton") != null || FMLLoader.getLoadingModList().getModFileById("pluto") != null;

if (mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.Varint21FrameDecoderMixin") || mixinClassName.equalsIgnoreCase("net.tonimatasdev.packetfixerforge.mixin.Varint21LengthFieldPrependerMixin")) {
if (krypton) {
LogUtils.getLogger().warn("For can't fit X into 3 error fix. Delete Krypton or Pluto.");
return false;
}
//if (krypton) {
// LogUtils.getLogger().warn("For can't fit X into 3 error fix. Delete Krypton or Pluto.");
// return false;
//}
}

return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.nbt.NbtAccounter;
import org.objectweb.asm.Opcodes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.network.PacketEncoder;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.network.protocol.login.ServerboundCustomQueryAnswerPacket;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.tonimatasdev.packetfixerforge.mixin;
package dev.tonimatas.packetfixer.mixins;

import net.minecraft.network.Varint21LengthFieldPrepender;
import org.spongepowered.asm.mixin.Mixin;
Expand Down
13 changes: 13 additions & 0 deletions common/src/main/resources/packetfixer-common.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.tonimatas.packetfixer.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}
63 changes: 45 additions & 18 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
@file:Suppress("UnstableApiUsage")
@file:Suppress("DEPRECATION", "HasPlatformType")

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.task.RemapJarTask
import org.gradle.api.component.AdhocComponentWithVariants

plugins {
id("fabric-loom") version "1.3-SNAPSHOT"
id("com.github.johnrengelman.shadow") version "7.1.2"
}

architectury {
platformSetupLoomIde()
fabric()
}

val loaderVersion: String by extra
val yarnMappings: String by extra
val modVersion: String by extra
val minecraftVersion: String by extra
val fabricLoaderVersion: String by extra
val fabricMinecraftVersionRange: String by extra
val modVersion: String by extra

val common by configurations.creating
val shadowCommon by configurations.creating

configurations["compileClasspath"].extendsFrom(common)
configurations["runtimeClasspath"].extendsFrom(common)
configurations["developmentFabric"].extendsFrom(common)

dependencies {
minecraft("com.mojang:minecraft:$minecraftVersion")
mappings("net.fabricmc:yarn:$minecraftVersion+build.$yarnMappings:v2")
modImplementation("net.fabricmc:fabric-loader:$loaderVersion")
modImplementation("net.fabricmc:fabric-loader:$fabricLoaderVersion")

common(project(path = ":common", configuration = "namedElements")) { isTransitive = false }
shadowCommon(project(path = ":common", configuration = "transformProductionFabric")) { isTransitive = false }
}

tasks.withType<ProcessResources> {
val replaceProperties = mapOf("version" to modVersion, "minecraftVersion" to minecraftVersion)
val replaceProperties = mapOf("modVersion" to modVersion, "minecraftVersion" to minecraftVersion)

inputs.properties(replaceProperties)

Expand All @@ -26,19 +42,30 @@ tasks.withType<ProcessResources> {
}
}

tasks.withType<JavaCompile> {
options.release.set(17)
tasks.withType<ShadowJar> {
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}

java {
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
tasks.withType<RemapJarTask> {
val shadowTask = tasks.shadowJar.get()
input.set(shadowTask.archiveFile)
dependsOn(shadowTask)
archiveClassifier.set("")
}

tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
archiveClassifier.set("dev")
}

tasks.sourcesJar {
val commonSources = project(":common").tasks.sourcesJar.get()
dependsOn(commonSources)
from(commonSources.archiveFile.map { zipTree(it) })
}

components.getByName<AdhocComponentWithVariants>("java").apply {
withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) {
skip()
}
}
Loading

0 comments on commit 0bcb0aa

Please sign in to comment.