Skip to content

Commit

Permalink
Rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
TonimatasDEV committed Aug 31, 2023
1 parent cf93456 commit 2665e1c
Show file tree
Hide file tree
Showing 33 changed files with 348 additions and 234 deletions.
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Project exclude paths
/.gradle/
/.idea/
/build/
/common/.gradle/
/common/build/
/fabric/.gradle/
/build/classes/java/main/
/run/
/.idea/
/artifacts/

/fabric/build/
/forge/build/
/fabric/.gradle/
/forge/.gradle/
/forge/build/
/fabric/run/
/forge/run/
44 changes: 4 additions & 40 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,51 +1,15 @@
import net.fabricmc.loom.api.LoomGradleExtensionAPI

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

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

architectury {
minecraft = minecraftVersion
}
val minecraftVersion: String by extra

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
group = "net.tonimatasdev.packetfixer"

repositories {

}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
version = "$modVersion-$minecraftVersion"
group = "net.tonimatasdev"

java {
withSourcesJar()
}
base.archivesName.set("PacketFixer-" + project.name)
}
9 changes: 0 additions & 9 deletions common/build.gradle.kts

This file was deleted.

11 changes: 0 additions & 11 deletions common/src/main/java/net/tonimatasdev/packetfixer/PacketFixer.java

This file was deleted.

19 changes: 0 additions & 19 deletions common/src/main/resources/packetfixer-common.mixins.json

This file was deleted.

62 changes: 18 additions & 44 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,38 +1,23 @@
@file:Suppress("DEPRECATION")

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import net.fabricmc.loom.task.RemapJarTask
import org.gradle.api.component.AdhocComponentWithVariants
@file:Suppress("UnstableApiUsage")

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

architectury {
platformSetupLoomIde()
fabric()
id("fabric-loom") version "1.3-SNAPSHOT"
}

val minecraftVersion: String by extra
val fabricLoaderVersion: String by extra
val loaderVersion: String by extra
val yarnMappings: 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)
val minecraftVersion: String by extra

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

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, "minecraftVersionRange" to minecraftVersion)
val replaceProperties = mapOf("version" to modVersion, "minecraftVersion" to minecraftVersion)

inputs.properties(replaceProperties)

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

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.withType<JavaCompile> {
options.release.set(17)
}

tasks.jar {
archiveClassifier.set("dev")
}
java {
withSourcesJar()

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

components.getByName<AdhocComponentWithVariants>("java").apply {
withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) {
skip()
tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}"}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package net.tonimatasdev.packetfixerfabric;

import com.mojang.logging.LogUtils;
import net.fabricmc.api.ModInitializer;
import net.tonimatasdev.packetfixer.PacketFixer;

public class PacketFixerFabric implements ModInitializer {
@Override
public void onInitialize() {
PacketFixer.init();
LogUtils.getLogger().info("PacketFixer (Fabric) has been initialized successfully");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.tonimatasdev.packetfixerfabric.mixin;


import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = CustomPayloadC2SPacket.class, priority = 999)
public class CustomPayloadC2SPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", constant = @Constant(intValue = 32767))
private int newSize(int value) {
return value * 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = CustomPayloadS2CPacket.class, priority = 999)
public class CustomPayloadS2CPacketMixin {
@ModifyConstant(method = "<init>*", constant = @Constant(intValue = 1048576))
private int newSize(int value) {
return value * 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.packet.s2c.login.LoginQueryRequestS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = LoginQueryRequestS2CPacket.class, priority = 999)
public class LoginQueryRequestS2CPacketMixin {
@ModifyConstant(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", constant = @Constant(intValue = 1048576))
private int newSize(int value) {
return value * 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = LoginQueryResponseC2SPacket.class, priority = 999)
public class LoginQueryResponseC2SPacketMixin {

@SuppressWarnings({"UnusedAssignment", "ParameterCanBeLocal"})
@Redirect(method = "<init>(Lnet/minecraft/network/PacketByteBuf;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/network/packet/c2s/login/LoginQueryResponseC2SPacket;response:Lnet/minecraft/network/PacketByteBuf;", opcode = Opcodes.PUTFIELD))
private void newSize(LoginQueryResponseC2SPacket instance, PacketByteBuf data, PacketByteBuf value) {
data = value.readNullable((p_238039_) -> {
int i = p_238039_.readableBytes();
return new PacketByteBuf(p_238039_.readBytes(i));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.nbt.NbtTagSizeTracker;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = NbtTagSizeTracker.class, priority = 999)
public abstract class NbtTagSizeTrackerMixin {
@Redirect(method = "add", at = @At(value = "FIELD", target = "Lnet/minecraft/nbt/NbtTagSizeTracker;maxBytes:J", opcode = Opcodes.GETFIELD))
public long accountBits(NbtTagSizeTracker instance) {
return 2097152 * 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.PacketEncoder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = PacketEncoder.class, priority = 999)
public class PacketEncoderMixin {
@ModifyConstant(method = "encode(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/packet/Packet;Lio/netty/buffer/ByteBuf;)V", constant = @Constant(intValue = 8388608))
private int newSize(int value) {
return value * 100;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.tonimatasdev.packetfixerfabric.mixin;

import net.minecraft.network.PacketInflater;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;

@Mixin(value = PacketInflater.class, priority = 999)
public class PacketInflaterMixin {
@ModifyConstant(method = "decode", constant = @Constant(intValue = 8388608), require = 0)
private int newSize(int value) {
return value * 100;
}
}
5 changes: 2 additions & 3 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
]
},
"mixins": [
"packetfixer-fabric.mixins.json",
"packetfixer-common.mixins.json"
"packetfixer.mixins.json"
],
"depends": {
"fabricloader": ">=0.12.12",
"minecraft": "${minecraftVersionRange}"
"minecraft": "${minecraftVersion}"
}
}
8 changes: 0 additions & 8 deletions fabric/src/main/resources/packetfixer-fabric.mixins.json

This file was deleted.

17 changes: 17 additions & 0 deletions fabric/src/main/resources/packetfixer.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"required": true,
"package": "net.tonimatasdev.packetfixerfabric.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"CustomPayloadC2SPacketMixin",
"CustomPayloadS2CPacketMixin",
"LoginQueryRequestS2CPacketMixin",
"LoginQueryResponseC2SPacketMixin",
"NbtTagSizeTrackerMixin",
"PacketEncoderMixin",
"PacketInflaterMixin"
],
"injectors": {
"defaultRequire": 1
}
}
Loading

0 comments on commit 2665e1c

Please sign in to comment.