Skip to content

Commit

Permalink
More files
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Jan 13, 2024
1 parent 43cdbd9 commit 18ead32
Show file tree
Hide file tree
Showing 19 changed files with 368 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
/.idea/
/artifacts/

/common/build/
/fabric/build/
/forge/build/
/fabric/.gradle/
/forge/.gradle/
/common/.gradle/
/fabric/run/
/forge/run/
13 changes: 13 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,13 @@
package dev.tonimatas.packetfixer;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class PacketFixer {
public static final Logger LOGGER = LogManager.getLogger();
public static final String MOD_ID = "packetfixer";

public static void init() {
LOGGER.info("Packet Fixer has been initialized successfully");
}
}
11 changes: 11 additions & 0 deletions common/src/main/java/dev/tonimatas/packetfixer/util/Hooks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.tonimatas.packetfixer.util;

import dev.architectury.injectables.annotations.ExpectPlatform;
import org.apache.commons.lang3.NotImplementedException;

public class Hooks {
@ExpectPlatform
public static boolean isModLoaded(String modId) {
throw new NotImplementedException("Problems on implement isModLoaded method.");
}
}
24 changes: 24 additions & 0 deletions common/src/main/resources/packetfixer-common.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.tonimatas.packetfixer.mixins",
"priority": 499,
"compatibilityLevel": "JAVA_8",
"plugin": "dev.tonimatas.packetfixer.mixins.MixinConfigPlugin",
"mixins": [
"ClientboundCustomPayloadPacketMixin",
"ClientboundCustomQueryPacketMixin",
"CompressionDecoderMixin",
"NbtAccounterMixin",
"PacketBufferMixin",
"ServerboundCustomPayloadPacketMixin",
"ServerboundCustomQueryPacketMixin",
"Varint21FrameDecoderMixin",
"Varint21LengthFieldPrependerMixin"
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}
71 changes: 71 additions & 0 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@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("com.github.johnrengelman.shadow") version "7.1.2"
}

architectury {
platformSetupLoomIde()
fabric()
}

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 {
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("modVersion" to modVersion, "minecraftVersion" to minecraftVersion)

inputs.properties(replaceProperties)

filesMatching("fabric.mod.json") {
expand(replaceProperties)
}
}

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

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

tasks.jar {
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()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.tonimatas.packetfixer;

import net.fabricmc.api.ModInitializer;

public class PacketFixerFabric implements ModInitializer {
@Override
public void onInitialize() {
PacketFixer.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.tonimatas.packetfixer.util.fabric;

import net.fabricmc.loader.api.FabricLoader;

@SuppressWarnings("unused")
public class HooksImpl {
public static boolean isModLoaded(String modId) {
return FabricLoader.getInstance().isModLoaded(modId);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "packetfixer",
"version": "${modVersion}",
"name": "Packet Fixer",
"description": "A simple mod to solve various problems with packets/NBT's.",
"authors": [
"TonimatasDEV"
],
"contact": {
"repo": "https://github.com/TonimatasDEV/PacketFixer"
},
"license": "MIT",
"icon": "assets/packetfixer/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"dev.tonimatas.packetfixerfabric.PacketFixerFabric"
]
},
"mixins": [
"packetfixer-common.mixins.json",
"packetfixer-fabric.mixins.json"
],
"depends": {
"fabricloader": ">=0.12.12",
"minecraft": "${minecraftVersion}"
}
}
11 changes: 11 additions & 0 deletions fabric/src/main/resources/packetfixer-fabric.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.tonimatas.packetfixer.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}
79 changes: 79 additions & 0 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
@file:Suppress("DEPRECATION")

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

plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
}

val modVersion: String by extra
val minecraftVersion: String by extra
val forgeVersion: String by extra
val forgeVersionRange: String by extra

architectury {
platformSetupLoomIde()
forge()
}

loom {
forge {
mixinConfig("packetfixer-common.mixins.json")
mixinConfig("packetfixer-forge.mixins.json")
}
}

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

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

dependencies {
forge("net.minecraftforge:forge:$minecraftVersion-$forgeVersion")

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

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

filesMatching("META-INF/mods.toml") {
expand(replaceProperties)
}
}

tasks.withType<ShadowJar> {
exclude("fabric.mod.json")

configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}

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

tasks.jar {
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()
}
}
1 change: 1 addition & 0 deletions forge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=forge
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.tonimatas.packetfixer;

import net.minecraftforge.fml.common.Mod;

@Mod(PacketFixer.MOD_ID)
public class PacketFixerForge {
public PacketFixerForge() {
PacketFixer.init();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package dev.tonimatas.packetfixer.mixin;

import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

import java.util.List;
import java.util.Set;

public class MixinConfigPluginForge implements IMixinConfigPlugin {

@Override
public void onLoad(String mixinPackage) {
System.getProperties().setProperty("forge.disablePacketCompressionDebug", "true");
}

@Override
public String getRefMapperConfig() {
return null;
}

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}

@Override
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {

}

@Override
public List<String> getMixins() {
return null;
}

@Override
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}

@Override
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.tonimatas.packetfixer.util.forge;

import net.minecraftforge.fml.loading.FMLLoader;

@SuppressWarnings("unused")
public class HooksImpl {
public static boolean isModLoaded(String modId) {
return FMLLoader.getLoadingModList().getModFileById(modId) != null;
}
}
29 changes: 29 additions & 0 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
modLoader="javafml"
loaderVersion="[${forgeVersionRange},)"
license="MIT"
issueTrackerURL="https://github.com/TonimatasDEV/PacketFixer/issues"

[[mods]]
modId="packetfixer"
version="${modVersion}"
displayName="Packet Fixer"
logoFile="icon.png"
updateJSONURL="https://api.modrinth.com/updates/packet-fixer/forge_updates.json"
authors="TonimatasDEV"
description='''
A simple mod to solve various problems with packets/NBT's.
'''

[[dependencies.packetfixer]]
modId="forge"
mandatory=true
versionRange="[${forgeVersionRange},)"
ordering="NONE"
side="BOTH"

[[dependencies.packetfixer]]
modId="minecraft"
mandatory=true
versionRange="[${minecraftVersion}]"
ordering="NONE"
side="BOTH"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
12 changes: 12 additions & 0 deletions forge/src/main/resources/packetfixer-forge.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "dev.tonimatas.packetfixer.mixin",
"compatibilityLevel": "JAVA_8",
"plugin": "dev.tonimatas.packetfixer.mixin.MixinConfigPluginForge",
"injectors": {
"defaultRequire": 1
},
"mixins": [
]
}

0 comments on commit 18ead32

Please sign in to comment.