2026-09-06 18:22:00 +03:00
|
|
|
package online.astradev.packs.mixin;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.network.protocol.common.ServerboundResourcePackPacket;
|
2026-09-06 19:25:26 +03:00
|
|
|
import net.minecraft.server.network.ServerCommonPacketListenerImpl;
|
|
|
|
|
import net.minecraft.server.network.ServerConfigurationPacketListenerImpl;
|
2026-09-06 18:22:00 +03:00
|
|
|
import online.astradev.packs.PackRuntime;
|
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
2026-09-06 19:25:26 +03:00
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
2026-09-06 18:22:00 +03:00
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
|
|
|
|
|
|
@Mixin(ServerConfigurationPacketListenerImpl.class)
|
|
|
|
|
public abstract class ConfigurationResponseMixin {
|
|
|
|
|
@Inject(method = "handleResourcePackResponse", at = @At("HEAD"), cancellable = true)
|
2026-09-06 19:25:26 +03:00
|
|
|
private void astrapacks$handleResponse(ServerboundResourcePackPacket packet, CallbackInfo callback) {
|
2026-09-06 18:22:00 +03:00
|
|
|
PackRuntime runtime = PackRuntime.INSTANCE;
|
2026-09-06 19:25:26 +03:00
|
|
|
if (runtime == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// At runtime, this mixin is part of the Minecraft listener.
|
|
|
|
|
var listener = (ServerCommonPacketListenerImpl) (Object) this;
|
|
|
|
|
if (runtime.intercept(listener, packet)) {
|
|
|
|
|
callback.cancel();
|
|
|
|
|
}
|
2026-09-06 18:22:00 +03:00
|
|
|
}
|
|
|
|
|
}
|