Skip to content

Commit

Permalink
Support for 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Oct 30, 2022
1 parent 88896fd commit e0cd1a8
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 190 deletions.
77 changes: 77 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
143 changes: 0 additions & 143 deletions build.gradle.kts

This file was deleted.

16 changes: 16 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version = 1.19.2
yarn_mappings = 1.19.2+build.28
loader_version = 0.14.10

# Mod Properties
mod_version = 1.0.1
maven_group = io.github.ytg1234
archives_base_name = packet-ignore

# Dependencies
fabric_version = 0.64.0+1.19.2
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 10 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
12 changes: 0 additions & 12 deletions settings.gradle.kts

This file was deleted.

12 changes: 6 additions & 6 deletions src/main/java/io/github/ytg1234/packetignore/PacketIgnore.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package io.github.ytg1234.packetignore;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;

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

public class PacketIgnore implements ModInitializer {
public static Logger logger = LogManager.getLogger("PacketIgnore");
public static String MOD_ID = "packetignore";
public static String MOD_NAME = "Packet Ignore";
public static Logger logger = LoggerFactory.getLogger(MOD_ID);

@Override
public void onInitialize() {
logger.info("PacketIgnore initializing");
logger.info(MOD_NAME + " initialized.");
}
}

Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
package io.github.ytg1234.packetignore.mixin;

import java.util.Random;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.Packet;
Expand All @@ -17,25 +8,31 @@
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket;
import net.minecraft.network.packet.c2s.login.LoginKeyC2SPacket;
import net.minecraft.network.packet.c2s.login.LoginQueryResponseC2SPacket;
import net.minecraft.network.packet.s2c.login.LoginCompressionS2CPacket;
import net.minecraft.network.packet.s2c.login.LoginDisconnectS2CPacket;
import net.minecraft.network.packet.s2c.login.LoginQueryRequestS2CPacket;
import net.minecraft.network.packet.s2c.login.LoginSuccessS2CPacket;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.Random;

@Mixin(ClientConnection.class)
public abstract class ClientConnectionMixin {
@Shadow @Final private NetworkSide side;
@Shadow
@Final
private NetworkSide side;

@Shadow
private static <T extends PacketListener> void handlePacket(Packet<T> packet, PacketListener listener) {
}

@Unique
private Random random = new Random();
private final Random random = new Random();

@Redirect(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/Packet;Lnet/minecraft/network/listener/PacketListener;)V"))
private void stuff(Packet<?> packet, PacketListener listener) {
if (packet instanceof HandshakeC2SPacket ||
packet instanceof LoginHelloC2SPacket ||
packet instanceof LoginKeyC2SPacket ||
packet instanceof LoginQueryResponseC2SPacket) {
@Redirect(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;handlePacket(Lnet/minecraft/network/Packet;Lnet/minecraft/network/listener/PacketListener;)V"))
private void packetignore_ignorePackets(Packet<?> packet, PacketListener listener) {
if (packet instanceof HandshakeC2SPacket || packet instanceof LoginHelloC2SPacket || packet instanceof LoginKeyC2SPacket || packet instanceof LoginQueryResponseC2SPacket) {
handlePacket(packet, listener);
System.out.println("Handshake or login received");
return;
Expand All @@ -46,8 +43,4 @@ private void stuff(Packet<?> packet, PacketListener listener) {
}
if (random.nextBoolean()) handlePacket(packet, listener);
}

@Shadow
private static <T extends PacketListener> void handlePacket(Packet<T> packet, PacketListener listener) {
}
}
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"name": "PacketIgnore",
"description": "Ignores some packets",
"authors": [
"YTG1234"
"YTG1234",
"Kevinthegreat"
],
"contributors": [],
"contact": {},
Expand Down

0 comments on commit e0cd1a8

Please sign in to comment.