1.21 Update

Co-authored-by: RealMangoRage <[email protected]>
Co-authored-by: Daniel Norris <[email protected]>
Co-authored-by: Ven <[email protected]>
This commit is contained in:
committed 2024-06-13 10:42:32 -07:00
1 parent 3d9e12a71d
commit 4a2db246e0
941 files changed
+3119 -4266

No files matched your search

@@ -36,7 +36,7 @@ public class ChannelBuilder {
* @param channelName The name of the channel
*/
public static ChannelBuilder named(String channelName) {
return named(new ResourceLocation(channelName));
return named(ResourceLocation.parse(channelName));
}
/**
@@ -31,7 +31,7 @@ import java.util.List;
public class ChannelListManager {
private static final Logger LOGGER = LogUtils.getLogger();
public static final ResourceLocation NAME = new ResourceLocation("forge", "channel_registration");
public static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "channel_registration");
static final Channel<CustomPacketPayload> CHANNEL = ChannelBuilder
.named(NAME)
@@ -44,7 +44,7 @@ public class ChannelListManager {
.build();
private record Register(List<String> channels) implements CustomPacketPayload {
private static Type<Register> TYPE = CustomPacketPayload.createType("minecraft:register");
private static Type<Register> TYPE = CustomPacketPayload.createType("register");
private static StreamCodec<FriendlyByteBuf, Register> CODEC = StreamCodec.of(
(buf, v) -> encode(buf, v.channels),
buf -> new Register(decode(buf))
@@ -57,7 +57,7 @@ public class ChannelListManager {
}
private record Unregister(List<String> channels) implements CustomPacketPayload {
private static Type<Unregister> TYPE = CustomPacketPayload.createType("minecraft:unregister");
private static Type<Unregister> TYPE = CustomPacketPayload.createType("unregister");
private static StreamCodec<FriendlyByteBuf, Unregister> CODEC = StreamCodec.of(
(buf, v) -> encode(buf, v.channels),
buf -> new Unregister(decode(buf))
@@ -153,7 +153,7 @@ public class ChannelListManager {
continue;
try {
changed.add(new ResourceLocation(channel));
changed.add(ResourceLocation.parse(channel));
} catch (ResourceLocationException ex) {
// Vanilla packet deserializers now force this to be a resource location, so we should never get this, but just in case.
LOGGER.warn("Invalid channel name received: {}. Ignoring", channel);
@@ -215,7 +215,7 @@ public class ForgePacketHandler {
var mismatched = new HashMap<ResourceLocation, NetworkMismatchData.Version>();
var missing = new HashSet<ResourceLocation>();
for (var id : missingMods) {
var key = new ResourceLocation(id, "");
var key = ResourceLocation.fromNamespaceAndPath(id, "");
var container = ModList.get().getModContainerById(id).orElse(null);
if (container != null)
mismatched.put(key, new NetworkMismatchData.Version(container.getModInfo().getVersion().toString(), ""));
@@ -21,8 +21,8 @@ import java.util.function.BiConsumer;
public final class NetworkInitialization {
private static final Logger LOGGER = LogManager.getLogger();
private static final Marker MARKER = MarkerManager.getMarker("FORGE_NETWORK");
public static final ResourceLocation LOGIN_NAME = new ResourceLocation("forge", "login");
private static final ResourceLocation HANDSHAKE_NAME = new ResourceLocation("forge", "handshake");
public static final ResourceLocation LOGIN_NAME = ResourceLocation.fromNamespaceAndPath("forge", "login");
private static final ResourceLocation HANDSHAKE_NAME = ResourceLocation.fromNamespaceAndPath("forge", "handshake");
//private static final ResourceLocation PLAY_NAME = new ResourceLocation("forge", "network");
public static final AttributeKey<ForgePacketHandler> CONTEXT = AttributeKey.newInstance(HANDSHAKE_NAME.toString());
@@ -227,7 +227,7 @@ public record ServerStatusPing(
var channelName = buf.readUtf();
var channelVersion = buf.readVarInt();
var requiredOnClient = buf.readBoolean();
final ResourceLocation id = new ResourceLocation(modId, channelName);
final ResourceLocation id = ResourceLocation.fromNamespaceAndPath(modId, channelName);
channels.put(id, new ChannelData(id, channelVersion, requiredOnClient));
}
@@ -32,14 +32,14 @@ public record MismatchData(
public static MismatchData decode(FriendlyByteBuf buf) {
var mismatched = buf.readMap(
i -> new ResourceLocation(i.readUtf(MAX_LENGTH)),
i -> ResourceLocation.parse(i.readUtf(MAX_LENGTH)),
i -> new Version(
i.readUtf(MAX_LENGTH),
i.readUtf(MAX_LENGTH)
)
);
var missing = buf.readCollection(HashSet::new,
i -> new ResourceLocation(i.readUtf(MAX_LENGTH))
i -> ResourceLocation.parse(i.readUtf(MAX_LENGTH))
);
return new MismatchData(mismatched, missing);
}