Skip to content

Commit

Permalink
refactor: Replace PacketThreadUtilTransformer with a Mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Feb 11, 2025
1 parent ecc8a15 commit 88e2a2e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Skytils - Hypixel Skyblock Quality of Life Mod
* Copyright (C) 2020-2025 Skytils
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package gg.skytils.skytilsmod.mixins.transformers.network;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import gg.skytils.skytilsmod.events.impl.MainReceivePacketEvent;
import net.minecraft.network.INetHandler;
import net.minecraft.network.Packet;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(targets = "net.minecraft.network.PacketThreadUtil$1")
public abstract class MixinPacketThreadUtil<T extends INetHandler> implements Runnable {
@WrapWithCondition(method="run", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/Packet;processPacket(Lnet/minecraft/network/INetHandler;)V"))
private boolean processMainThreadPacket(Packet<T> packet, T netHandler) {
return !(new MainReceivePacketEvent<>(
netHandler,
packet
).postAndCatch());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class SkytilsTransformer : BaseClassTransformer() {
addColoredNamesCheck()
injectSplashProgressTransformer()
changeRenderedName()
insertReceivePacketEvent()
injectNullCheck()
commitArson()
injectScoreboardScoreRemover()
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/main/resources/mixins.skytils.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"multiplayer.MixinPlayerControllerMP",
"network.MixinNetHandlerPlayClient",
"network.MixinNetworkManager",
"network.MixinPacketThreadUtil",
"neu.MixinCustomAH",
"neu.MixinGuiProfileViewer",
"neu.MixinStorageManager",
Expand Down

0 comments on commit 88e2a2e

Please sign in to comment.