Skip to content

Commit

Permalink
neoforge 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Apr 24, 2024
1 parent ecd424a commit b636352
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 129 deletions.
8 changes: 8 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ allprojects {
options.encoding = StandardCharsets.UTF_8.name()
options.release.set(21)
}

task("listPluginVersions") {
doLast {
project.plugins.forEach {
println("$it -> ${it.javaClass.protectionDomain.codeSource.location.toURI().toString().lowercase()}")
}
}
}
}

subprojects {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
org.gradle.jvmargs = -Xmx1G

minecraft = 1.20.5-pre1
minecraft = 1.20.5

archiveBaseName = badpackets
group = lol.bai
majorVersion = 0

fabricLoader = 0.15.9
fabricApi = 0.96.15+1.20.5
fabricLoader = 0.15.10
fabricApi = 0.97.6+1.20.5
forge = 49.0.19
neo = 20.4.171
neo = 20.5.0-beta

cf.projectId = 615134
mr.projectId = ftdbN0KK
2 changes: 1 addition & 1 deletion platform/fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("fabric-loom") version "1.6.6"
id("fabric-loom") version "1.6.11"
}

setupPlatform()
Expand Down
4 changes: 2 additions & 2 deletions platform/neo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import net.neoforged.gradle.dsl.common.runs.run.Run

plugins {
idea
id("net.neoforged.gradle.userdev") version "7.0.+"
id("net.neoforged.gradle.userdev") version "7.0.107"
}

setupPlatform()
Expand All @@ -24,7 +24,7 @@ runs {
tasks.processResources {
inputs.property("version", project.version)

filesMatching("META-INF/mods.toml") {
filesMatching("META-INF/neoforge.mods.toml") {
expand("version" to project.version)
}
}
Expand Down
2 changes: 1 addition & 1 deletion platform/neo/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ cf.loader = NeoForge
cf.gameVersion = 1.20.4

# Modrinth
mr.releaseType = release
mr.releaseType = stable
mr.loader = neoforge
mr.gameVersion = 1.20.4

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import lol.bai.badpackets.test.BadPacketTest;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod.EventBusSubscriber;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.EventBusSubscriber.Bus;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;

import static net.neoforged.fml.common.Mod.EventBusSubscriber.Bus;

@EventBusSubscriber(modid = Constants.MOD_ID, bus = Bus.MOD, value = Dist.CLIENT)
public class ForgeBadPacketTestClient {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import lol.bai.badpackets.impl.Constants;
import lol.bai.badpackets.test.BadPacketTest;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.Mod.EventBusSubscriber;
import net.neoforged.fml.common.Mod.EventBusSubscriber.Bus;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.EventBusSubscriber.Bus;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;

@EventBusSubscriber(modid = Constants.MOD_ID, bus = Bus.MOD)
public class NeoBadPacketTest {

@SubscribeEvent
static void setup(FMLCommonSetupEvent event) {
BadPacketTest.server();
BadPacketTest.common();
}

}
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ platform("mojmap")

platform("fabric")
//platform("forge")
//platform("neo")
platform("neo")
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package lol.bai.badpackets.impl.mixin;

import java.util.List;
import java.util.function.Function;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
Expand All @@ -11,7 +11,6 @@
import net.minecraft.network.protocol.common.ClientCommonPacketListener;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload.FallbackProvider;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -31,36 +30,16 @@ private void badpackets_handle(ClientCommonPacketListener listener, CallbackInfo
}
}

@WrapOperation(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 0, target = "net/minecraft/network/protocol/common/custom/CustomPacketPayload.codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;"))
private static StreamCodec<?, ?> badpackets_attachPlayChannelCodecs(FallbackProvider<?> fallbackProvider, List<?> list, Operation<StreamCodec<?, ?>> original) {
var codec = original.call(fallbackProvider, list);
@WrapOperation(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 0, target = "net/minecraft/network/codec/StreamCodec.map(Ljava/util/function/Function;Ljava/util/function/Function;)Lnet/minecraft/network/codec/StreamCodec;"))
private static StreamCodec<?, ?> badpackets_attachPlayChannelCodecs(StreamCodec<?, ?> codec, Function<?, ?> to, Function<?, ?> from, Operation<StreamCodec<?, ?>> map) {
ChannelCodecFinder.attach(codec, ChannelRegistry.PLAY_S2C);
return codec;
return map.call(codec, to, from);
}

@WrapOperation(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 1, target = "net/minecraft/network/protocol/common/custom/CustomPacketPayload.codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;"))
private static StreamCodec<?, ?> badpackets_attachConfigChannelCodecs(FallbackProvider<?> fallbackProvider, List<?> list, Operation<StreamCodec<?, ?>> original) {
var codec = original.call(fallbackProvider, list);
@WrapOperation(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 1, target = "net/minecraft/network/codec/StreamCodec.map(Ljava/util/function/Function;Ljava/util/function/Function;)Lnet/minecraft/network/codec/StreamCodec;"))
private static StreamCodec<?, ?> badpackets_attachConfigChannelCodecs(StreamCodec<?, ?> codec, Function<?, ?> to, Function<?, ?> from, Operation<StreamCodec<?, ?>> map) {
ChannelCodecFinder.attach(codec, ChannelRegistry.CONFIG_S2C);
return codec;
return map.call(codec, to, from);
}

// @ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 0, target = "net/minecraft/network/protocol/common/custom/CustomPacketPayload.codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;"))
// private static CustomPacketPayload.FallbackProvider<?> badpackets_getPlayCodec(CustomPacketPayload.FallbackProvider<?> original) {
// return id -> {
// var codec = ChannelRegistry.PLAY_S2C.getCodec(id, null);
// if (codec != null) return codec;
// return original.create(id);
// };
// }
//
// @ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", ordinal = 1, target = "net/minecraft/network/protocol/common/custom/CustomPacketPayload.codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;"))
// private static CustomPacketPayload.FallbackProvider<FriendlyByteBuf> badpackets_getConfigCodec(CustomPacketPayload.FallbackProvider<FriendlyByteBuf> original) {
// return id -> {
// var codec = ChannelRegistry.CONFIG_S2C.getCodec(id);
// if (codec != null) return codec;
// return original.create(id);
// };
// }

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package lol.bai.badpackets.impl.mixin;

import java.util.List;
import java.util.function.Function;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
Expand Down Expand Up @@ -31,58 +31,13 @@ private void badpackets_handle(ServerCommonPacketListener listener, CallbackInfo
}
}

@WrapOperation(method = "<clinit>", at = @At(value = "INVOKE", target = "net/minecraft/network/protocol/common/custom/CustomPacketPayload.codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;"))
private static StreamCodec<?, ?> badpackets_attachChannelCodecs(CustomPacketPayload.FallbackProvider<?> fallbackProvider, List<?> list, Operation<StreamCodec<?, ?>> original) {
var codec = original.call(fallbackProvider, list);
@WrapOperation(method = "<clinit>", at = @At(value = "INVOKE", target = "net/minecraft/network/codec/StreamCodec.map(Ljava/util/function/Function;Ljava/util/function/Function;)Lnet/minecraft/network/codec/StreamCodec;"))
private static StreamCodec<?, ?> badpackets_attachChannelCodecs(StreamCodec<?, ?> codec, Function<?, ?> to, Function<?, ?> from, Operation<StreamCodec<?, ?>> map) {
ChannelCodecFinder.attach(codec, (id, buf) -> {
var registry = buf instanceof RegistryFriendlyByteBuf ? ChannelRegistry.PLAY_C2S : ChannelRegistry.CONFIG_C2S;
return registry.getCodec(id, buf);
});
return codec;
return map.call(codec, to, from);
}

// @ModifyArg(method = "<clinit>", at = @At(value = "INVOKE", target = "net/minecraft/network/protocol/common/custom/CustomPacketPayload.codec(Lnet/minecraft/network/protocol/common/custom/CustomPacketPayload$FallbackProvider;Ljava/util/List;)Lnet/minecraft/network/codec/StreamCodec;"))
// private static CustomPacketPayload.FallbackProvider<FriendlyByteBuf> badpackets_getCodec(CustomPacketPayload.FallbackProvider<FriendlyByteBuf> original) {
// return id -> {
// var playCodec = (StreamCodec<RegistryFriendlyByteBuf, CustomPacketPayload>) ChannelRegistry.PLAY_C2S.getCodec(id);
// var configCodec = (StreamCodec<FriendlyByteBuf, CustomPacketPayload>) ChannelRegistry.CONFIG_C2S.getCodec(id);
// var discardedCodec = (StreamCodec<FriendlyByteBuf, CustomPacketPayload>) original.create(id);
//
// if (playCodec != null || configCodec != null) {
// return new StreamCodec<>() {
// @Override
// public CustomPacketPayload decode(FriendlyByteBuf buf) {
// if (buf instanceof RegistryFriendlyByteBuf registryFriendlyByteBuf) {
// if (playCodec != null) return playCodec.decode(registryFriendlyByteBuf);
// } else {
// if (configCodec != null) return configCodec.decode(buf);
// }
//
// return discardedCodec.decode(buf);
// }
//
// @Override
// public void encode(FriendlyByteBuf buf, CustomPacketPayload payload) {
// if (buf instanceof RegistryFriendlyByteBuf registryFriendlyByteBuf) {
// if (playCodec != null) {
// playCodec.encode(registryFriendlyByteBuf, payload);
// return;
// }
// } else {
// if (configCodec != null) {
// configCodec.encode(buf, payload);
// return;
// }
// }
//
// discardedCodec.encode(buf, payload);
// }
// };
// }
//
// return discardedCodec;
// };
// }


}

0 comments on commit b636352

Please sign in to comment.