feat: update to 1.21-pre4
This commit is contained in:
parent
5b1fbcbb76
commit
01f562339a
@ -1,11 +1,11 @@
|
||||
# jf-scripts version is in settings.gradle.kts
|
||||
[versions]
|
||||
minecraft = "1.20.6"
|
||||
yarn = "build.1"
|
||||
minecraft = "1.21-pre4"
|
||||
yarn = "build.3"
|
||||
fabric-loader = "0.15.11"
|
||||
fabric-api = "0.97.8+1.20.6"
|
||||
fabric-api = "0.100.0+1.21"
|
||||
jf-commons = "1.7-SNAPSHOT"
|
||||
modmenu = "10.0.0-beta.1"
|
||||
modmenu = "11.0.0-beta.1"
|
||||
annotations = "24.1.0"
|
||||
javapoet = "1.13.0"
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class ResourcePath {
|
||||
case "data" -> ResourceType.SERVER_DATA;
|
||||
default -> throw new IllegalStateException("Unexpected value for resource type: " + s1[0] + " in: " + name);
|
||||
};
|
||||
id = new Identifier(s1[1], s1[2]);
|
||||
id = Identifier.of(s1[1], s1[2]);
|
||||
}
|
||||
|
||||
public Identifier getId() {
|
||||
|
@ -39,6 +39,15 @@ public interface CategoryBuilder<Builder extends CategoryBuilder<Builder>> {
|
||||
<T> Builder value(String id, T def, double min, double max, Type type, int width, Supplier<T> get, Consumer<T> set);
|
||||
<T> Builder value(EntryInfo<T> entry);
|
||||
|
||||
/**
|
||||
* Adds a migration to the category.
|
||||
* Migrations are used to update the config when the format changes.
|
||||
* They MUST consume the element and may use it to update the internal state.
|
||||
*
|
||||
* @param element The element to migrate
|
||||
* @param migration The migration to apply
|
||||
* @return this
|
||||
*/
|
||||
@ApiStatus.Experimental Builder addMigration(String element, Migration migration);
|
||||
|
||||
String getId();
|
||||
|
@ -40,8 +40,10 @@ public class DefaultConfigIO {
|
||||
try {
|
||||
if (reader.peek() != Token.BEGIN_OBJECT) {
|
||||
LibJf.LOGGER.error("Invalid config: Not a JSON object for " + id);
|
||||
reader.skipValue();
|
||||
return;
|
||||
}
|
||||
//TODO take advantage of commons-serialize's single-item view to permit illegal entries without messing up the rest
|
||||
Set<String> appeared = new HashSet<>();
|
||||
reader.beginObject();
|
||||
while (reader.peek() != Token.END_OBJECT) {
|
||||
|
@ -39,7 +39,7 @@ public class DslConfigCategory implements ConfigCategory {
|
||||
this.presets = presets.entrySet().stream().collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
t -> () -> t.getValue().accept(this),
|
||||
(u, v) -> v,
|
||||
(u, v) -> () -> { u.run(); v.run(); },
|
||||
LinkedHashMap::new
|
||||
));
|
||||
this.referencedConfigs = referencedConfigs;
|
||||
|
@ -10,6 +10,7 @@ import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -30,6 +31,10 @@ public class RequestRouter {
|
||||
PayloadTypeRegistry.configurationC2S().register(ConfigurationCompletePacket.ID, ConfigurationCompletePacket.CODEC);
|
||||
}
|
||||
|
||||
public static Identifier id(String path) {
|
||||
return Identifier.of(MOD_ID, path);
|
||||
}
|
||||
|
||||
public static void acceptResponse(ResponsePacket response, PacketSender responseSender) {
|
||||
Request request = currentRequests.remove(response.request());
|
||||
if (request != null) {
|
||||
|
@ -4,10 +4,9 @@ import io.gitlab.jfronny.libjf.config.impl.network.RequestRouter;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public record ConfigurationCompletePacket() implements CustomPayload {
|
||||
public static final CustomPayload.Id<ConfigurationCompletePacket> ID = new CustomPayload.Id<>(new Identifier(RequestRouter.MOD_ID, "handshake_complete"));
|
||||
public static final CustomPayload.Id<ConfigurationCompletePacket> ID = new CustomPayload.Id<>(RequestRouter.id("handshake_complete"));
|
||||
public static final PacketCodec<ByteBuf, ConfigurationCompletePacket> CODEC = PacketCodec.unit(new ConfigurationCompletePacket());
|
||||
|
||||
@Override
|
||||
|
@ -5,10 +5,9 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.codec.PacketCodecs;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public record ConfigurationPacket(int version) implements CustomPayload {
|
||||
public static final CustomPayload.Id<ConfigurationPacket> ID = new CustomPayload.Id<>(new Identifier(RequestRouter.MOD_ID, "handshake"));
|
||||
public static final CustomPayload.Id<ConfigurationPacket> ID = new CustomPayload.Id<>(RequestRouter.id("handshake"));
|
||||
public static final PacketCodec<ByteBuf, ConfigurationPacket> CODEC = PacketCodecs.INTEGER.xmap(ConfigurationPacket::new, ConfigurationPacket::version);
|
||||
|
||||
@Override
|
||||
|
@ -6,14 +6,12 @@ import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.codec.PacketCodecs;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
public record RequestPacket(long request, @Nullable Long parent, String name, PacketByteBuf aux) implements CustomPayload {
|
||||
public static final Id<RequestPacket> ID = new CustomPayload.Id<>(new Identifier(RequestRouter.MOD_ID, "request"));
|
||||
public static final Id<RequestPacket> ID = new CustomPayload.Id<>(RequestRouter.id("request"));
|
||||
public static final PacketCodec<PacketByteBuf, RequestPacket> CODEC = PacketCodec.tuple(
|
||||
PacketCodecs.VAR_LONG, RequestPacket::request,
|
||||
PacketCodecs.optional(PacketCodecs.VAR_LONG), RequestPacket::optionalParent,
|
||||
|
@ -6,10 +6,9 @@ import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.codec.PacketCodec;
|
||||
import net.minecraft.network.codec.PacketCodecs;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public record ResponsePacket(long request, int status, PacketByteBuf aux) implements CustomPayload {
|
||||
public static final CustomPayload.Id<ResponsePacket> ID = new CustomPayload.Id<>(new Identifier(RequestRouter.MOD_ID, "response"));
|
||||
public static final CustomPayload.Id<ResponsePacket> ID = new CustomPayload.Id<>(RequestRouter.id("response"));
|
||||
public static final PacketCodec<PacketByteBuf, ResponsePacket> CODEC = PacketCodec.tuple(
|
||||
PacketCodecs.VAR_LONG, ResponsePacket::request,
|
||||
PacketCodecs.INTEGER, ResponsePacket::status,
|
||||
|
@ -139,6 +139,7 @@ public class TinyConfigScreen extends ScreenWithSaveHook {
|
||||
}
|
||||
|
||||
private boolean tabsWouldOverflow(Collection<ConfigCategory> categories) {
|
||||
// Mirrors TabNavigationWidget#init
|
||||
int tabNavWidth = this.width;
|
||||
int headerWidth = Math.min(400, tabNavWidth) - 28;
|
||||
int singleHeaderWidth = MathHelper.roundUpToMultiple(headerWidth / categories.size(), 2);
|
||||
|
@ -26,15 +26,14 @@ public class TestConfig implements JfCustomConfig {
|
||||
.category("nestedCa", builder2 -> builder2.value("doubleValue", doubleValue2, 12, 47, () -> doubleValue2, v -> doubleValue2 = v))
|
||||
).category("ca2", builder1 -> builder1
|
||||
.value("value2", value2, () -> value2, v -> value2 = v)
|
||||
).category("ca3", builder1 -> builder1
|
||||
.value("value3", value3, () -> value3, v -> value3 = v)
|
||||
).category("ca3", builder1 -> builder1
|
||||
.value("value3", value4, -5, 12, () -> value4, v -> value4 = v)
|
||||
).category("ca4", builder1 -> builder1
|
||||
.value("value4", value4, -5, 12, () -> value4, v -> value4 = v)
|
||||
.value("value4", value5, () -> value5, v -> value5 = v)
|
||||
).category("ca5", builder1 -> builder1
|
||||
.value("value5", value5, () -> value5, v -> value5 = v)
|
||||
.value("value5", value6, () -> value6, v -> value6 = v)
|
||||
).category("ca6", builder1 -> builder1
|
||||
.value("value6", value6, () -> value6, v -> value6 = v)
|
||||
).category("ca7", builder1 -> builder1
|
||||
.value("mappy", map, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Type.ofToken(new TypeToken<String2ObjectMap<String>>() {}), 100, () -> map, v -> map = v)
|
||||
)
|
||||
);
|
||||
|
@ -18,5 +18,5 @@
|
||||
"libjf-config-ui-tiny-testmod.jfconfig.ca5.value5": "Value 5",
|
||||
"libjf-config-ui-tiny-testmod.jfconfig.ca6.title": "Category 6",
|
||||
"libjf-config-ui-tiny-testmod.jfconfig.ca6.tooltip": "This is category 6",
|
||||
"libjf-config-ui-tiny-testmod.jfconfig.ca6.value6": "Value 6"
|
||||
"libjf-config-ui-tiny-testmod.jfconfig.ca6.mappy": "Value 6"
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"tag.item.libjf.overpowered": "Overpowered",
|
||||
"tag.item.libjf.shulker_boxes_illegal": "Illegal in Shulker Boxes"
|
||||
}
|
@ -7,6 +7,6 @@ import net.minecraft.registry.tag.TagKey;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class Tags {
|
||||
public static final TagKey<Item> SHULKER_ILLEGAL = TagKey.of(RegistryKeys.ITEM, new Identifier(LibJf.MOD_ID, "shulker_boxes_illegal"));
|
||||
public static final TagKey<Item> OVERPOWERED = TagKey.of(RegistryKeys.ITEM, new Identifier(LibJf.MOD_ID, "overpowered"));
|
||||
public static final TagKey<Item> SHULKER_ILLEGAL = TagKey.of(RegistryKeys.ITEM, Identifier.of(LibJf.MOD_ID, "shulker_boxes_illegal"));
|
||||
public static final TagKey<Item> OVERPOWERED = TagKey.of(RegistryKeys.ITEM, Identifier.of(LibJf.MOD_ID, "overpowered"));
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(targets = "net.minecraft.server.ServerNetworkIo$1")
|
||||
public class ServerNetworkIo$1Mixin {
|
||||
@Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;addHandlers(Lio/netty/channel/ChannelPipeline;Lnet/minecraft/network/NetworkSide;Lnet/minecraft/network/handler/PacketSizeLogger;)V"))
|
||||
@Inject(method = "initChannel(Lio/netty/channel/Channel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;addHandlers(Lio/netty/channel/ChannelPipeline;Lnet/minecraft/network/NetworkSide;ZLnet/minecraft/network/handler/PacketSizeLogger;)V"))
|
||||
private void inject(Channel channel, CallbackInfo ci) {
|
||||
channel.pipeline().addAfter("legacy_query", "libjf_http", new HttpDecoder());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user