diff --git a/Fabric/build.gradle b/Fabric/build.gradle index 66ac6181..045846a3 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -63,13 +63,13 @@ dependencies { mappings loom.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:0.15.11" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.100.0+1.20.6" + modImplementation "net.fabricmc.fabric-api:fabric-api:0.100.7+1.21" compileOnly project(":Xplat") - modCompileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62" + modCompileOnly "mezz.jei:jei-1.21-common-api:19.1.1.19" modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:16.0.729") { transitive = false } - modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:14.0.126") { transitive = false } + modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:15.0.127") { transitive = false } } compileJava { diff --git a/Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java b/Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java index dfb41287..9942c7bf 100644 --- a/Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java +++ b/Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java @@ -3,7 +3,6 @@ import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; -import net.fabricmc.fabric.api.client.model.loading.v1.ModelModifier; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; import net.fabricmc.fabric.api.event.player.UseBlockCallback; @@ -12,8 +11,6 @@ import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.item.ItemProperties; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.resources.ResourceManager; @@ -36,8 +33,6 @@ import vazkii.patchouli.network.MessageOpenBookGui; import vazkii.patchouli.network.MessageReloadBookContents; -import org.jetbrains.annotations.Nullable; - import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; @@ -57,16 +52,19 @@ public void onInitializeClient() { ModelLoadingPlugin.register(pluginContext -> { for (Book book : BookRegistry.INSTANCE.books.values()) { - pluginContext.addModels(new ModelResourceLocation(book.model, "inventory")); + PatchouliAPI.LOGGER.info("Adding model {}", book.model); + pluginContext.addModels(book.model); } pluginContext.modifyModelAfterBake().register( - (@Nullable BakedModel oldModel, ModelModifier.AfterBake.Context ctx) -> { - if (ctx.id() instanceof ModelResourceLocation key - && PatchouliItems.BOOK_ID.equals(key) // checks namespace and path - && key.getVariant().equals("inventory") + (oldModel, ctx) -> { + if (ctx.topLevelId() != null && + PatchouliItems.BOOK_ID.equals(ctx.topLevelId().id()) // checks namespace and path + && ctx.topLevelId().getVariant().equals("inventory") && oldModel != null) { - return new BookModel(oldModel, ctx.loader()); + return new BookModel(oldModel, ctx.loader(), (model) -> { + return Minecraft.getInstance().getModelManager().getModel(model); + }); } return oldModel; } @@ -74,11 +72,11 @@ public void onInitializeClient() { }); ItemProperties.register(PatchouliItems.BOOK, - new ResourceLocation(PatchouliAPI.MOD_ID, "completion"), + ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "completion"), (stack, world, entity, seed) -> ItemModBook.getCompletion(stack)); ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new IdentifiableResourceReloadListener() { - private static final ResourceLocation id = new ResourceLocation(PatchouliAPI.MOD_ID, "resource_pack_books"); + private static final ResourceLocation id = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "resource_pack_books"); @Override public CompletableFuture reload(PreparationBarrier barrier, ResourceManager manager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor) { @@ -91,7 +89,7 @@ public ResourceLocation getFabricId() { } }); ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { - private static final ResourceLocation id = new ResourceLocation(PatchouliAPI.MOD_ID, "reload_hook"); + private static final ResourceLocation id = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "reload_hook"); @Override public ResourceLocation getFabricId() { diff --git a/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinGameRenderer.java b/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinGameRenderer.java index d2a5d2d0..d58925ec 100644 --- a/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinGameRenderer.java +++ b/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinGameRenderer.java @@ -1,5 +1,6 @@ package vazkii.patchouli.mixin.client; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.renderer.GameRenderer; import org.spongepowered.asm.mixin.Mixin; @@ -11,13 +12,13 @@ @Mixin(GameRenderer.class) public class MixinGameRenderer { - @Inject(at = @At("HEAD"), method = "render(FJZ)V") - public void patchouli_renderStart(float tickDelta, long startTime, boolean tick, CallbackInfo info) { - ClientTicker.renderTickStart(tickDelta); + @Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/client/DeltaTracker;Z)V") + public void patchouli_renderStart(DeltaTracker deltaTracker, boolean tick, CallbackInfo info) { + ClientTicker.renderTickStart(deltaTracker.getGameTimeDeltaPartialTick(false)); } - @Inject(at = @At("RETURN"), method = "render(FJZ)V") - public void patchouli_renderEnd(float tickDelta, long startTime, boolean tick, CallbackInfo info) { + @Inject(at = @At("RETURN"), method = "render(Lnet/minecraft/client/DeltaTracker;Z)V") + public void patchouli_renderEnd(DeltaTracker deltaTracker, boolean tick, CallbackInfo info) { ClientTicker.renderTickEnd(); } diff --git a/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelBakery.java b/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelBakery.java new file mode 100644 index 00000000..74c1ec33 --- /dev/null +++ b/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelBakery.java @@ -0,0 +1,4 @@ +package vazkii.patchouli.mixin.client; + +public class MixinModelBakery { +} diff --git a/Fabric/src/main/resources/fabric.mod.json b/Fabric/src/main/resources/fabric.mod.json index d19ee8de..1f2de8bd 100644 --- a/Fabric/src/main/resources/fabric.mod.json +++ b/Fabric/src/main/resources/fabric.mod.json @@ -35,8 +35,8 @@ ], "depends": { - "fabricloader": ">=0.15.10", - "fabric": ">=0.97.6", - "minecraft": ">=1.20.6 <1.21" + "fabricloader": ">=0.15.11", + "fabric": ">=0.100.3", + "minecraft": ">=1.21 <1.22" } } diff --git a/NeoForge/build.gradle b/NeoForge/build.gradle index 06002dea..000ebbd7 100644 --- a/NeoForge/build.gradle +++ b/NeoForge/build.gradle @@ -37,11 +37,11 @@ runs { } dependencies { - implementation "net.neoforged:neoforge:20.6.115" + implementation "net.neoforged:neoforge:21.0.106-beta" implementation project(":Xplat") - compileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62" - testCompileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62" + compileOnly "mezz.jei:jei-1.21-common-api:19.5.0.33" + testCompileOnly "mezz.jei:jei-1.21-common-api:19.5.0.33" } tasks.named('test').configure { diff --git a/NeoForge/src/main/java/vazkii/patchouli/neoforge/client/NeoForgeClientInitializer.java b/NeoForge/src/main/java/vazkii/patchouli/neoforge/client/NeoForgeClientInitializer.java index c715e3af..9f8a9007 100644 --- a/NeoForge/src/main/java/vazkii/patchouli/neoforge/client/NeoForgeClientInitializer.java +++ b/NeoForge/src/main/java/vazkii/patchouli/neoforge/client/NeoForgeClientInitializer.java @@ -82,11 +82,11 @@ private static List getBookModels() { public static void modelRegistry(ModelEvent.RegisterAdditional e) { getBookModels() .stream() - .map(model -> new ModelResourceLocation(model, "inventory")) + .map(ModelResourceLocation::standalone) .forEach(e::register); ItemPropertyFunction prop = (stack, world, entity, seed) -> ItemModBook.getCompletion(stack); - ItemProperties.register(PatchouliItems.BOOK, new ResourceLocation(PatchouliAPI.MOD_ID, "completion"), prop); + ItemProperties.register(PatchouliItems.BOOK, ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "completion"), prop); } @SubscribeEvent @@ -105,10 +105,10 @@ public static void registerReloadListeners(RegisterClientReloadListenersEvent e) @SubscribeEvent public static void registerOverlays(RegisterGuiLayersEvent evt) { - evt.registerAbove(VanillaGuiLayers.CROSSHAIR, new ResourceLocation(PatchouliAPI.MOD_ID, "book_overlay"), + evt.registerAbove(VanillaGuiLayers.CROSSHAIR, ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "book_overlay"), BookRightClickHandler::onRenderHUD ); - evt.registerBelow(VanillaGuiLayers.BOSS_OVERLAY, new ResourceLocation(PatchouliAPI.MOD_ID, "multiblock_progress"), + evt.registerBelow(VanillaGuiLayers.BOSS_OVERLAY, ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "multiblock_progress"), MultiblockVisualizationHandler::onRenderHUD ); } @@ -133,7 +133,7 @@ public static void onInitializeClient(FMLClientSetupEvent evt) { }); NeoForge.EVENT_BUS.addListener((RenderFrameEvent.Pre e) -> { - ClientTicker.renderTickStart(e.getPartialTick()); + ClientTicker.renderTickStart(e.getPartialTick().getGameTimeDeltaPartialTick(false)); }); NeoForge.EVENT_BUS.addListener((RenderFrameEvent.Post e) -> { ClientTicker.renderTickEnd(); @@ -150,7 +150,10 @@ public static void onInitializeClient(FMLClientSetupEvent evt) { @SubscribeEvent public static void replaceBookModel(ModelEvent.ModifyBakingResult evt) { - ModelResourceLocation key = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory"); - evt.getModels().computeIfPresent(key, (k, oldModel) -> new BookModel(oldModel, evt.getModelBakery())); + ModelResourceLocation key = ModelResourceLocation.inventory(PatchouliItems.BOOK_ID); + evt.getModels().computeIfPresent(key, (k, oldModel) -> new BookModel(oldModel, evt.getModelBakery(), (model) -> { + ModelResourceLocation modelPath = ModelResourceLocation.standalone(model); + return Minecraft.getInstance().getModelManager().getModel(modelPath); + })); } } diff --git a/NeoForge/src/main/java/vazkii/patchouli/neoforge/common/NeoForgeModInitializer.java b/NeoForge/src/main/java/vazkii/patchouli/neoforge/common/NeoForgeModInitializer.java index 4a8b5c45..502058b0 100644 --- a/NeoForge/src/main/java/vazkii/patchouli/neoforge/common/NeoForgeModInitializer.java +++ b/NeoForge/src/main/java/vazkii/patchouli/neoforge/common/NeoForgeModInitializer.java @@ -59,8 +59,10 @@ public static void processCreativeTabs(BuildCreativeModeTabContentsEvent evt) { BookRegistry.INSTANCE.books.values().forEach(b -> { if (!b.noBook) { ItemStack book = ItemModBook.forBook(b); - if (evt.getTab() == CreativeModeTabs.searchTab()) { - evt.accept(book, CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY); + if (evt.getTabKey() == CreativeModeTabs.SEARCH) { + if (!evt.getSearchEntries().contains(book)) { + evt.accept(book, CreativeModeTab.TabVisibility.SEARCH_TAB_ONLY); + } } else if (b.creativeTab != null) { if (evt.getTab() == CreativeModeTabRegistry.getTab(b.creativeTab)) { evt.accept(book); diff --git a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml index 1fc44950..186d9201 100644 --- a/NeoForge/src/main/resources/META-INF/neoforge.mods.toml +++ b/NeoForge/src/main/resources/META-INF/neoforge.mods.toml @@ -1,6 +1,6 @@ modLoader="javafml" license="CC BY-NC-SA 3.0" -loaderVersion="[3,)" +loaderVersion="[4,)" issueTrackerURL="https://github.com/VazkiiMods/Patchouli" logoFile="logo.png" @@ -16,12 +16,12 @@ Accessible, Data-Driven, Dependency-Free Documentation for Minecraft Modders and [[dependencies.patchouli]] modId="neoforge" type="REQUIRED" -versionRange="[20.6.1-beta,)" +versionRange="[21.0.31-beta,)" [[dependencies.patchouli]] modId="minecraft" type="REQUIRED" -versionRange="[1.20.6,1.21)" +versionRange="[1.21,1.22)" [[mixins]] config="patchouli_xplat.mixins.json" \ No newline at end of file diff --git a/Xplat/build.gradle b/Xplat/build.gradle index b82aac14..28f3fec3 100644 --- a/Xplat/build.gradle +++ b/Xplat/build.gradle @@ -27,7 +27,7 @@ repositories { dependencies { compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5' - compileOnly "mezz.jei:jei-1.20.6-common-api:18.0.0.62" + compileOnly "mezz.jei:jei-1.21-common-api:19.1.1.19" testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.1' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.1' } diff --git a/Xplat/src/main/java/vazkii/patchouli/api/stub/StubMultiblock.java b/Xplat/src/main/java/vazkii/patchouli/api/stub/StubMultiblock.java index 2ecac37c..28dc01ab 100644 --- a/Xplat/src/main/java/vazkii/patchouli/api/stub/StubMultiblock.java +++ b/Xplat/src/main/java/vazkii/patchouli/api/stub/StubMultiblock.java @@ -36,7 +36,7 @@ public IMultiblock setSymmetrical(boolean symmetrical) { @Override public ResourceLocation getID() { - return new ResourceLocation("patchouli", "stub"); + return ResourceLocation.fromNamespaceAndPath("patchouli", "stub"); } @Override diff --git a/Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java b/Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java index 035d35de..78956972 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java @@ -1,6 +1,5 @@ package vazkii.patchouli.client.base; -import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BlockModel; @@ -17,6 +16,7 @@ import vazkii.patchouli.common.book.Book; import vazkii.patchouli.common.item.ItemModBook; +import vazkii.patchouli.mixin.client.AccessorModelBakery; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,21 +29,31 @@ public class BookModel implements BakedModel { private final BakedModel original; private final ItemOverrides itemHandler; - public BookModel(BakedModel original, ModelBakery loader) { + public BookModel(BakedModel original, ModelBakery loader, Function modelGetter) { this.original = original; - BlockModel missing = (BlockModel) loader.getModel(ModelBakery.MISSING_MODEL_LOCATION); + BlockModel missing = (BlockModel) ((AccessorModelBakery) loader).invokeGetModel(ModelBakery.MISSING_MODEL_LOCATION); this.itemHandler = new ItemOverrides(new ModelBaker() { - // soft implement IForgeModelBaker + // soft implement IModelBakerExtension public Function getModelTextureGetter() { return null; } - // soft implement IForgeModelBaker + // soft implement IModelBakerExtension public BakedModel bake(ResourceLocation location, ModelState state, Function sprites) { return null; } + // soft implement IModelBakerExtension + public BakedModel bakeUncached(UnbakedModel model, ModelState state, Function sprites) { + return null; + } + + // soft implement IModelBakerExtension + public UnbakedModel getTopLevelModel(ModelResourceLocation location) { + return null; + } + @Override public UnbakedModel getModel(ResourceLocation resourceLocation) { return null; @@ -60,8 +70,7 @@ public BakedModel resolve(@NotNull BakedModel original, @NotNull ItemStack stack @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed) { Book book = ItemModBook.getBook(stack); if (book != null) { - ModelResourceLocation modelPath = new ModelResourceLocation(book.model, "inventory"); - return Minecraft.getInstance().getModelManager().getModel(modelPath); + return modelGetter.apply(book.model); } return original; } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java b/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java index 7a3f3c58..8434c6ea 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/base/ClientAdvancements.java @@ -65,7 +65,7 @@ public static void sendBookToast(Book book) { } public static class LexiconToast implements Toast { - private static final ResourceLocation BACKGROUND_SPRITE = new ResourceLocation("toast/advancement"); + private static final ResourceLocation BACKGROUND_SPRITE = ResourceLocation.withDefaultNamespace("toast/advancement"); private final Book book; public LexiconToast(Book book) { diff --git a/Xplat/src/main/java/vazkii/patchouli/client/base/PersistentData.java b/Xplat/src/main/java/vazkii/patchouli/client/base/PersistentData.java index 026eead1..b5f751bc 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/base/PersistentData.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/base/PersistentData.java @@ -66,7 +66,7 @@ public DataHolder(JsonObject root) { var obj = GsonHelper.getAsJsonObject(root, "bookData", new JsonObject()); for (var e : obj.entrySet()) { - this.bookData.put(new ResourceLocation(e.getKey()), new BookData(e.getValue().getAsJsonObject())); + this.bookData.put(ResourceLocation.tryParse(e.getKey()), new BookData(e.getValue().getAsJsonObject())); } } @@ -98,7 +98,7 @@ public Bookmark(ResourceLocation entry, int spread) { } public Bookmark(JsonObject root) { - this.entry = new ResourceLocation(GsonHelper.getAsString(root, "entry")); + this.entry = ResourceLocation.tryParse(GsonHelper.getAsString(root, "entry")); this.spread = GsonHelper.getAsInt(root, "page"); // Serialized as page for legacy reasons } @@ -123,16 +123,16 @@ public static final class BookData { public BookData(JsonObject root) { var emptyArray = new JsonArray(); for (var e : GsonHelper.getAsJsonArray(root, "viewedEntries", emptyArray)) { - viewedEntries.add(new ResourceLocation(e.getAsString())); + viewedEntries.add(ResourceLocation.tryParse(e.getAsString())); } for (var e : GsonHelper.getAsJsonArray(root, "bookmarks", emptyArray)) { bookmarks.add(new Bookmark(e.getAsJsonObject())); } for (var e : GsonHelper.getAsJsonArray(root, "history", emptyArray)) { - history.add(new ResourceLocation(e.getAsString())); + history.add(ResourceLocation.tryParse(e.getAsString())); } for (var e : GsonHelper.getAsJsonArray(root, "completedManualQuests", emptyArray)) { - completedManualQuests.add(new ResourceLocation(e.getAsString())); + completedManualQuests.add(ResourceLocation.tryParse(e.getAsString())); } } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookCategory.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookCategory.java index 53ca4e4f..7ae22421 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookCategory.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookCategory.java @@ -155,7 +155,7 @@ public void build(BookContentsBuilder builder) { if (!isRootCategory()) { if (parent.contains(":")) { - var parentCat = builder.getCategory(new ResourceLocation(parent)); + var parentCat = builder.getCategory(ResourceLocation.tryParse(parent)); if (parentCat == null) { var msg = String.format("Category %s specifies parent %s, but it could not be found", id, parent); throw new RuntimeException(msg); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentExternalLoader.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentExternalLoader.java index 161ac126..b0d7be49 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentExternalLoader.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentExternalLoader.java @@ -49,7 +49,7 @@ private ResourceLocation relativize(File root, File f) { String filePath = f.getAbsolutePath().substring(rootPath.length() + 1); String cleanPath = FilenameUtils.removeExtension(FilenameUtils.separatorsToUnix(filePath)); - return new ResourceLocation(PatchouliAPI.MOD_ID, cleanPath); + return ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, cleanPath); } @Override diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceDirectLoader.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceDirectLoader.java index 97e5b759..daa6360a 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceDirectLoader.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceDirectLoader.java @@ -45,7 +45,7 @@ public void findFiles(Book book, String dir, List list) { if (newPath.startsWith("/")) { newPath = newPath.substring(1); } - return new ResourceLocation(file.getNamespace(), newPath); + return ResourceLocation.fromNamespaceAndPath(file.getNamespace(), newPath); }) .forEach(list::add); } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceListenerLoader.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceListenerLoader.java index 8438470b..67000998 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceListenerLoader.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentResourceListenerLoader.java @@ -50,7 +50,7 @@ protected void apply(Map map, ResourceManager man PatchouliAPI.LOGGER.trace("Ignored file {}", key); continue; } - var bookId = new ResourceLocation(key.getNamespace(), matcher.group("bookId")); + var bookId = ResourceLocation.fromNamespaceAndPath(key.getNamespace(), matcher.group("bookId")); data.computeIfAbsent(bookId, id -> new HashMap<>()).put(entry.getKey(), entry.getValue()); } @@ -75,7 +75,7 @@ public void findFiles(Book book, String dir, List list) { } if (dir.equals(matcher.group("folder")) && BookContentsBuilder.DEFAULT_LANG.equals(matcher.group("lang"))) { - list.add(new ResourceLocation(id.getNamespace(), matcher.group("entryId"))); + list.add(ResourceLocation.fromNamespaceAndPath(id.getNamespace(), matcher.group("entryId"))); } } @@ -94,7 +94,7 @@ public LoadResult loadJson(Book book, ResourceLocation file) { // Drop patchouli_books/ and json suffix String relativizedPath = path.substring(0, path.length() - 5).split("/", 2)[1]; - JsonElement json = map.get(new ResourceLocation(file.getNamespace(), relativizedPath)); + JsonElement json = map.get(ResourceLocation.fromNamespaceAndPath(file.getNamespace(), relativizedPath)); if (json != null) { return new LoadResult( json, diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentsBuilder.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentsBuilder.java index a63fcd66..203829b0 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentsBuilder.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookContentsBuilder.java @@ -124,7 +124,7 @@ private void load(String thing, LoadFunc loader, Map for (ResourceLocation id : foundIds) { String filePath = String.format("%s/%s/%s/%s/%s.json", BookRegistry.BOOKS_LOCATION, book.id.getPath(), DEFAULT_LANG, thing, id.getPath()); - T value = loader.load(book, contentLoader, id, new ResourceLocation(id.getNamespace(), filePath)); + T value = loader.load(book, contentLoader, id, ResourceLocation.fromNamespaceAndPath(id.getNamespace(), filePath)); if (value != null) { builder.put(id, value); } @@ -180,7 +180,7 @@ private static Supplier loadTemplate(Book book, BookContentLoader } private static BookContentLoader.LoadResult loadLocalizedJson(Book book, BookContentLoader loader, ResourceLocation file) { - ResourceLocation localizedFile = new ResourceLocation(file.getNamespace(), + ResourceLocation localizedFile = ResourceLocation.fromNamespaceAndPath(file.getNamespace(), file.getPath().replaceAll(DEFAULT_LANG, ClientBookRegistry.INSTANCE.currentLang)); BookContentLoader.LoadResult input = loader.loadJson(book, localizedFile); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookEntry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookEntry.java index 09a2eda8..fef8c41a 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookEntry.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookEntry.java @@ -69,7 +69,7 @@ public BookEntry(JsonObject root, ResourceLocation id, Book book, @Nullable Stri var categoryId = GsonHelper.getAsString(root, "category"); if (categoryId.contains(":")) { // full category ID - this.categoryId = new ResourceLocation(categoryId); + this.categoryId = ResourceLocation.tryParse(categoryId); } else { String hint = String.format("`%s:%s`", book.id.getNamespace(), categoryId); throw new IllegalArgumentException("`category` must be fully qualified (domain:name). Hint: Try " + hint); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java index 1501bc54..6c77c3a5 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookIcon.java @@ -31,7 +31,7 @@ public void render(GuiGraphics graphics, int x, int y) { static BookIcon from(String str) { if (str.endsWith(".png")) { - return new TextureIcon(new ResourceLocation(str)); + return new TextureIcon(ResourceLocation.tryParse(str)); } else { try { ItemStack stack = ItemStackUtil.loadStackFromString(str, RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY)); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java index 155abb1f..a12db56e 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/ClientBookRegistry.java @@ -41,22 +41,22 @@ public void init() { } private void addPageTypes() { - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "text"), PageText.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "crafting"), PageCrafting.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "smelting"), PageSmelting.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "blasting"), PageBlasting.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "smoking"), PageSmoking.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "campfire"), PageCampfireCooking.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "smithing"), PageSmithing.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "stonecutting"), PageStonecutting.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "image"), PageImage.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "spotlight"), PageSpotlight.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "empty"), PageEmpty.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "multiblock"), PageMultiblock.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "link"), PageLink.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "relations"), PageRelations.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "entity"), PageEntity.class); - pageTypes.put(new ResourceLocation(PatchouliAPI.MOD_ID, "quest"), PageQuest.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "text"), PageText.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "crafting"), PageCrafting.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "smelting"), PageSmelting.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "blasting"), PageBlasting.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "smoking"), PageSmoking.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "campfire"), PageCampfireCooking.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "smithing"), PageSmithing.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "stonecutting"), PageStonecutting.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "image"), PageImage.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "spotlight"), PageSpotlight.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "empty"), PageEmpty.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "multiblock"), PageMultiblock.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "link"), PageLink.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "relations"), PageRelations.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "entity"), PageEntity.class); + pageTypes.put(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "quest"), PageQuest.class); } public void reload() { @@ -110,7 +110,7 @@ public BookPage deserialize(JsonElement json, Type typeOfT, JsonDeserializationC if (string.indexOf(':') < 0) { string = PatchouliAPI.MOD_ID + ":" + string; } - ResourceLocation type = new ResourceLocation(string); + ResourceLocation type = ResourceLocation.tryParse(string); Class clazz = ClientBookRegistry.INSTANCE.pageTypes.get(type); if (clazz == null) { clazz = PageTemplate.class; @@ -130,7 +130,7 @@ public static class TemplateComponentAdapter implements JsonDeserializer clazz = BookTemplate.componentTypes.get(type); if (clazz == null) { diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/LiquidBlockVertexConsumer.java b/Xplat/src/main/java/vazkii/patchouli/client/book/LiquidBlockVertexConsumer.java index 8b255dbb..f742ba93 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/LiquidBlockVertexConsumer.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/LiquidBlockVertexConsumer.java @@ -12,50 +12,41 @@ public record LiquidBlockVertexConsumer(VertexConsumer prior, PoseStack pose, BlockPos pos) implements VertexConsumer { @Override - public VertexConsumer vertex(double x, double y, double z) { + public VertexConsumer addVertex(float x, float y, float z) { final float dx = pos.getX() & 15; final float dy = pos.getY() & 15; final float dz = pos.getZ() & 15; - return prior.vertex(pose.last().pose(), (float) x - dx, (float) y - dy, (float) z - dz); + return prior.addVertex(pose.last().pose(), x - dx, y - dy, z - dz); } @Override - public VertexConsumer color(int r, int g, int b, int a) { - return prior.color(r, g, b, a); + public VertexConsumer setColor(int r, int g, int b, int a) { + return prior.setColor(r, g, b, a); } @Override - public VertexConsumer uv(float u, float v) { - return prior.uv(u, v); + public VertexConsumer setUv(float u, float v) { + return prior.setUv(u, v); } @Override - public VertexConsumer overlayCoords(int u, int v) { - return prior.overlayCoords(u, v); + public VertexConsumer setUv1(int u, int v) { + return prior.setUv1(u, v); } @Override - public VertexConsumer uv2(int u, int v) { - return prior.uv2(u, v); + public VertexConsumer setOverlay(int uv) { + return prior.setUv1(uv & 65535, uv >> 16 & 65535); } @Override - public VertexConsumer normal(float x, float y, float z) { - return prior.normal(pose.last(), x, y, z); + public VertexConsumer setUv2(int u, int v) { + return prior.setUv2(u, v); } @Override - public void endVertex() { - prior.endVertex(); + public VertexConsumer setNormal(float x, float y, float z) { + return prior.setNormal(pose.last(), x, y, z); } - @Override - public void defaultColor(int r, int g, int b, int a) { - prior.defaultColor(r, g, b, a); - } - - @Override - public void unsetDefaultColor() { - prior.unsetDefaultColor(); - } } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageRelations.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageRelations.java index 386c72fe..e7cbaec4 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageRelations.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageRelations.java @@ -30,7 +30,7 @@ public void build(Level level, BookEntry entry, BookContentsBuilder builder, int this.entryObjs = new ArrayList<>(); for (String s : this.entries) { - ResourceLocation targetId = new ResourceLocation(s); + ResourceLocation targetId = ResourceLocation.tryParse(s); BookEntry targetEntry = builder.getEntry(targetId); if (targetEntry == null) { throw new IllegalArgumentException("Could not find entry " + targetId); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java index 76516fa5..aa134654 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/abstr/PageDoubleRecipeRegistry.java @@ -35,7 +35,7 @@ protected T loadRecipe(Level level, BookContentsBuilder builder, BookEntry entry T tempRecipe = getRecipe(level, res); if (tempRecipe == null) { // this is hacky but it works around Forge requiring custom recipes to have the prefix of the adding mod - tempRecipe = getRecipe(level, new ResourceLocation("crafttweaker", res.getPath())); + tempRecipe = getRecipe(level, ResourceLocation.fromNamespaceAndPath("crafttweaker", res.getPath())); } if (tempRecipe != null) { diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/template/BookTemplate.java b/Xplat/src/main/java/vazkii/patchouli/client/book/template/BookTemplate.java index 6c108f48..2de4a3a5 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/template/BookTemplate.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/template/BookTemplate.java @@ -29,15 +29,15 @@ public class BookTemplate { public static final HashMap> componentTypes = new HashMap<>(); static { - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "text"), ComponentText.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "item"), ComponentItemStack.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "image"), ComponentImage.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "header"), ComponentHeader.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "separator"), ComponentSeparator.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "frame"), ComponentFrame.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "entity"), ComponentEntity.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "tooltip"), ComponentTooltip.class); - registerComponent(new ResourceLocation(PatchouliAPI.MOD_ID, "custom"), ComponentCustom.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "text"), ComponentText.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "item"), ComponentItemStack.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "image"), ComponentImage.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "header"), ComponentHeader.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "separator"), ComponentSeparator.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "frame"), ComponentFrame.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "entity"), ComponentEntity.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "tooltip"), ComponentTooltip.class); + registerComponent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "custom"), ComponentCustom.class); } @SerializedName("include") List inclusions = new ArrayList<>(); @@ -60,9 +60,9 @@ public class BookTemplate { public static BookTemplate createTemplate(Book book, BookContentsBuilder builder, String type, @Nullable TemplateInclusion inclusion) { ResourceLocation key; if (type.contains(":")) { - key = new ResourceLocation(type); + key = ResourceLocation.tryParse(type); } else { - key = new ResourceLocation(book.id.getNamespace(), type); + key = ResourceLocation.fromNamespaceAndPath(book.id.getNamespace(), type); } Supplier supplier = builder.getTemplate(key); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/template/component/ComponentImage.java b/Xplat/src/main/java/vazkii/patchouli/client/book/template/component/ComponentImage.java index a01a0937..934d676f 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/template/component/ComponentImage.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/template/component/ComponentImage.java @@ -29,7 +29,7 @@ public class ComponentImage extends TemplateComponent { @Override public void build(BookContentsBuilder builder, BookPage page, BookEntry entry, int pageNum) { - resource = new ResourceLocation(image); + resource = ResourceLocation.tryParse(image); } @Override diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/EntityTestProcessor.java b/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/EntityTestProcessor.java index e8e3c144..63403dfb 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/EntityTestProcessor.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/EntityTestProcessor.java @@ -21,7 +21,7 @@ public void setup(Level level, IVariableProvider variables) { entityType = entityType.substring(0, entityType.indexOf("{")); } - ResourceLocation key = new ResourceLocation(entityType); + ResourceLocation key = ResourceLocation.tryParse(entityType); entityName = BuiltInRegistries.ENTITY_TYPE.getOptional(key) .map(EntityType::getDescription).map(Component::getString) .orElse(null); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java b/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java index 9da52d1c..7474a202 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/template/test/RecipeTestProcessor.java @@ -20,7 +20,7 @@ public void setup(Level level, IVariableProvider variables) { // TODO probably add a recipe serializer? String recipeId = variables.get("recipe", level.registryAccess()).asString(); RecipeManager manager = level.getRecipeManager(); - recipe = manager.byKey(new ResourceLocation(recipeId)).orElseThrow(IllegalArgumentException::new).value(); + recipe = manager.byKey(ResourceLocation.tryParse(recipeId)).orElseThrow(IllegalArgumentException::new).value(); } @Override diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/text/BookTextParser.java b/Xplat/src/main/java/vazkii/patchouli/client/book/text/BookTextParser.java index e95576df..7bc4a245 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/text/BookTextParser.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/text/BookTextParser.java @@ -139,7 +139,7 @@ public static void register(FunctionProcessor function, String... names) { } ResourceLocation href; - href = parameter.contains(":") ? new ResourceLocation(parameter) : new ResourceLocation(state.book.id.getNamespace(), parameter); + href = parameter.contains(":") ? ResourceLocation.tryParse(parameter) : ResourceLocation.fromNamespaceAndPath(state.book.id.getNamespace(), parameter); GuiBook gui = state.gui; Book book = state.book; BookEntry entry = book.getContents().entries.get(href); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java b/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java index 71ac9e75..5d349a81 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java @@ -30,7 +30,7 @@ public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float pti graphics.setColor(1F, 1F, 1F, 1F); boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height; - graphics.blit(new ResourceLocation(PatchouliAPI.MOD_ID, "textures/gui/inventory_button.png"), getX(), getY(), (hovered ? 20 : 0), 0, width, height, 64, 64); + graphics.blit(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "textures/gui/inventory_button.png"), getX(), getY(), (hovered ? 20 : 0), 0, width, height, 64, 64); ItemStack stack = book.getBookItem(); graphics.renderItem(stack, getX() + 2, getY() + 2); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java b/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java index 1cecad33..a10b9b0a 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/BookRightClickHandler.java @@ -4,6 +4,7 @@ import com.mojang.datafixers.util.Pair; import net.minecraft.ChatFormatting; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.core.BlockPos; @@ -26,7 +27,7 @@ public class BookRightClickHandler { - public static void onRenderHUD(GuiGraphics graphics, float partialTicks) { + public static void onRenderHUD(GuiGraphics graphics, DeltaTracker deltaTracker) { Minecraft mc = Minecraft.getInstance(); Player player = mc.player; ItemStack bookStack = player.getMainHandItem(); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java b/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java index 30bb8de7..55397c81 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.renderer.MultiBufferSource; @@ -46,6 +47,7 @@ import java.util.Collection; import java.util.IdentityHashMap; import java.util.Map; +import java.util.SequencedMap; import java.util.function.Function; public class MultiblockVisualizationHandler { @@ -83,12 +85,12 @@ public static void setMultiblock(IMultiblock multiblock, Component name, Bookmar } } - public static void onRenderHUD(GuiGraphics graphics, float partialTicks) { + public static void onRenderHUD(GuiGraphics graphics, DeltaTracker deltaTracker) { if (hasMultiblock) { int waitTime = 40; int fadeOutSpeed = 4; int fullAnimTime = waitTime + 10; - float animTime = timeComplete + (timeComplete == 0 ? 0 : partialTicks); + float animTime = timeComplete + (timeComplete == 0 ? 0 : deltaTracker.getGameTimeDeltaPartialTick(false)); if (animTime > fullAnimTime) { hasMultiblock = false; @@ -320,14 +322,13 @@ private static void drawGradientRect(GuiGraphics graphics, int left, int top, in RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder bufferbuilder = tessellator.getBuilder(); - bufferbuilder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); + BufferBuilder bufferbuilder = tessellator.begin(Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); Matrix4f mat = graphics.pose().last().pose(); - bufferbuilder.vertex(mat, right, top, 0).color(f1, f2, f3, f).endVertex(); - bufferbuilder.vertex(mat, left, top, 0).color(f1, f2, f3, f).endVertex(); - bufferbuilder.vertex(mat, left, bottom, 0).color(f5, f6, f7, f4).endVertex(); - bufferbuilder.vertex(mat, right, bottom, 0).color(f5, f6, f7, f4).endVertex(); - tessellator.end(); + bufferbuilder.addVertex(mat, right, top, 0).setColor(f1, f2, f3, f); + bufferbuilder.addVertex(mat, left, top, 0).setColor(f1, f2, f3, f); + bufferbuilder.addVertex(mat, left, bottom, 0).setColor(f5, f6, f7, f4); + bufferbuilder.addVertex(mat, right, bottom, 0).setColor(f5, f6, f7, f4); + BufferUploader.drawWithShader(bufferbuilder.buildOrThrow()); RenderSystem.disableBlend(); } @@ -339,17 +340,17 @@ private static Rotation getRotation(Entity entity) { } private static MultiBufferSource.BufferSource initBuffers(MultiBufferSource.BufferSource original) { - BufferBuilder fallback = ((AccessorMultiBufferSource) original).getFallbackBuffer(); - Map layerBuffers = ((AccessorMultiBufferSource) original).getFixedBuffers(); - Map remapped = new Object2ObjectLinkedOpenHashMap<>(); - for (Map.Entry e : layerBuffers.entrySet()) { + ByteBufferBuilder fallback = ((AccessorMultiBufferSource) original).getFallbackBuffer(); + SequencedMap layerBuffers = ((AccessorMultiBufferSource) original).getFixedBuffers(); + SequencedMap remapped = new Object2ObjectLinkedOpenHashMap<>(); + for (Map.Entry e : layerBuffers.entrySet()) { remapped.put(GhostRenderLayer.remap(e.getKey()), e.getValue()); } return new GhostBuffers(fallback, remapped); } private static class GhostBuffers extends MultiBufferSource.BufferSource { - protected GhostBuffers(BufferBuilder fallback, Map layerBuffers) { + protected GhostBuffers(ByteBufferBuilder fallback, SequencedMap layerBuffers) { super(fallback, layerBuffers); } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java b/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java index d4e1fa7c..a6a9d569 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/TooltipHandler.java @@ -2,6 +2,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.BufferUploader; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.Tesselator; import com.mojang.blaze3d.vertex.VertexFormat.Mode; @@ -74,19 +75,18 @@ public static void onTooltip(GuiGraphics graphics, ItemStack stack, int mouseX, RenderSystem.enableBlend(); RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - BufferBuilder buf = Tesselator.getInstance().getBuilder(); - buf.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); + BufferBuilder buf = Tesselator.getInstance().begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR); float a = 0.5F + 0.2F * ((float) Math.cos(ClientTicker.total / 10) * 0.5F + 0.5F); - buf.vertex(cx, cy, 0).color(0F, 0.5F, 0F, a).endVertex(); + buf.addVertex(cx, cy, 0).setColor(0F, 0.5F, 0F, a); for (float i = angles; i > 0; i--) { double rad = (i - 90) / 180F * Math.PI; - buf.vertex(cx + Math.cos(rad) * r, cy + Math.sin(rad) * r, 0).color(0F, 1F, 0F, 1F).endVertex(); + buf.addVertex((float) (cx + Math.cos(rad) * r), (float) (cy + Math.sin(rad) * r), 0).setColor(0F, 1F, 0F, 1F); } - buf.vertex(cx, cy, 0).color(0F, 1F, 0F, 0F).endVertex(); - Tesselator.getInstance().end(); + buf.addVertex(cx, cy, 0).setColor(0F, 1F, 0F, 0F); + BufferUploader.drawWithShader(buf.buildOrThrow()); RenderSystem.disableBlend(); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/jei/PatchouliJeiPlugin.java b/Xplat/src/main/java/vazkii/patchouli/client/jei/PatchouliJeiPlugin.java index 38c7aa92..6fc51496 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/jei/PatchouliJeiPlugin.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/jei/PatchouliJeiPlugin.java @@ -22,7 +22,7 @@ @JeiPlugin public class PatchouliJeiPlugin implements IModPlugin { - private static final ResourceLocation UID = new ResourceLocation(PatchouliAPI.MOD_ID, PatchouliAPI.MOD_ID); + private static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, PatchouliAPI.MOD_ID); private static final KeyMapping showRecipe, showUses; diff --git a/Xplat/src/main/java/vazkii/patchouli/common/advancement/BookOpenTrigger.java b/Xplat/src/main/java/vazkii/patchouli/common/advancement/BookOpenTrigger.java index e2fcda37..667b4ca9 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/advancement/BookOpenTrigger.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/advancement/BookOpenTrigger.java @@ -18,7 +18,7 @@ * An advancement trigger for opening Patchouli books. */ public class BookOpenTrigger extends SimpleCriterionTrigger { - public static final ResourceLocation ID = new ResourceLocation(PatchouliAPI.MOD_ID, "open_book"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "open_book"); public static final BookOpenTrigger INSTANCE = new BookOpenTrigger(); @NotNull diff --git a/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliSounds.java b/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliSounds.java index d27e8172..da517fe0 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliSounds.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliSounds.java @@ -10,8 +10,8 @@ public class PatchouliSounds { - public static final SoundEvent BOOK_OPEN = SoundEvent.createVariableRangeEvent(new ResourceLocation(PatchouliAPI.MOD_ID, "book_open")); - public static final SoundEvent BOOK_FLIP = SoundEvent.createVariableRangeEvent(new ResourceLocation(PatchouliAPI.MOD_ID, "book_flip")); + public static final SoundEvent BOOK_OPEN = SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "book_open")); + public static final SoundEvent BOOK_FLIP = SoundEvent.createVariableRangeEvent(ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "book_flip")); public static void submitRegistrations(BiConsumer e) { e.accept(BOOK_OPEN.getLocation(), BOOK_OPEN); diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java index b37ee6ca..1674f9c8 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/Book.java @@ -34,10 +34,10 @@ public class Book { private static final String[] ORDINAL_SUFFIXES = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; - private static final ResourceLocation DEFAULT_MODEL = new ResourceLocation(PatchouliAPI.MOD_ID, "book_brown"); - private static final ResourceLocation DEFAULT_BOOK_TEXTURE = new ResourceLocation(PatchouliAPI.MOD_ID, "textures/gui/book_brown.png"); - private static final ResourceLocation DEFAULT_FILLER_TEXTURE = new ResourceLocation(PatchouliAPI.MOD_ID, "textures/gui/page_filler.png"); - private static final ResourceLocation DEFAULT_CRAFTING_TEXTURE = new ResourceLocation(PatchouliAPI.MOD_ID, "textures/gui/crafting.png"); + private static final ResourceLocation DEFAULT_MODEL = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "book_brown"); + private static final ResourceLocation DEFAULT_BOOK_TEXTURE = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "textures/gui/book_brown.png"); + private static final ResourceLocation DEFAULT_FILLER_TEXTURE = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "textures/gui/page_filler.png"); + private static final ResourceLocation DEFAULT_CRAFTING_TEXTURE = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "textures/gui/crafting.png"); private static final Map DEFAULT_MACROS = Util.make(() -> { Map ret = new HashMap<>(); @@ -109,7 +109,7 @@ public Book(JsonObject root, XplatModContainer owner, ResourceLocation id, boole this.bookTexture = SerializationUtil.getAsResourceLocation(root, "book_texture", DEFAULT_BOOK_TEXTURE); this.fillerTexture = SerializationUtil.getAsResourceLocation(root, "filler_texture", DEFAULT_FILLER_TEXTURE); this.craftingTexture = SerializationUtil.getAsResourceLocation(root, "crafting_texture", DEFAULT_CRAFTING_TEXTURE); - this.model = SerializationUtil.getAsResourceLocation(root, "model", DEFAULT_MODEL); + this.model = SerializationUtil.getAsResourceLocation(root, "model", DEFAULT_MODEL).withPrefix("item/"); this.useBlockyFont = GsonHelper.getAsBoolean(root, "use_blocky_font", false); this.owner = owner; diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/BookFolderLoader.java b/Xplat/src/main/java/vazkii/patchouli/common/book/BookFolderLoader.java index 9ad3ff68..b739d55b 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/BookFolderLoader.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/BookFolderLoader.java @@ -39,7 +39,7 @@ public static void findBooks() { for (File dir : subdirs) { ResourceLocation res; try { - res = new ResourceLocation(PatchouliAPI.MOD_ID, dir.getName()); + res = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, dir.getName()); } catch (ResourceLocationException ex) { PatchouliAPI.LOGGER.error("Invalid external book folder name {}, skipping", dir.getName(), ex); continue; diff --git a/Xplat/src/main/java/vazkii/patchouli/common/book/BookRegistry.java b/Xplat/src/main/java/vazkii/patchouli/common/book/BookRegistry.java index b2c86121..ef362d5f 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/book/BookRegistry.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/book/BookRegistry.java @@ -59,7 +59,7 @@ public void init() { } String assetPath = fileStr.substring(fileStr.indexOf("data/")); - ResourceLocation bookId = new ResourceLocation(id, bookName); + ResourceLocation bookId = ResourceLocation.fromNamespaceAndPath(id, bookName); foundBooks.put(Pair.of(mod, bookId), assetPath); } diff --git a/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliDataComponents.java b/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliDataComponents.java index 9236eff7..8d50b9c8 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliDataComponents.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliDataComponents.java @@ -9,7 +9,7 @@ public class PatchouliDataComponents { - public static final ResourceLocation COMPONENT_ID = new ResourceLocation(PatchouliAPI.MOD_ID, "book"); + public static final ResourceLocation COMPONENT_ID = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "book"); public static final DataComponentType BOOK = DataComponentType.builder() .persistent(ResourceLocation.CODEC) .networkSynchronized(ResourceLocation.STREAM_CODEC) diff --git a/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliItems.java b/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliItems.java index a469d6a5..f4061f8b 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliItems.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/item/PatchouliItems.java @@ -9,7 +9,7 @@ public class PatchouliItems { - public static final ResourceLocation BOOK_ID = new ResourceLocation(PatchouliAPI.MOD_ID, "guide_book"); + public static final ResourceLocation BOOK_ID = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "guide_book"); public static final Item BOOK = new ItemModBook(); public static void submitItemRegistrations(BiConsumer consumer) { diff --git a/Xplat/src/main/java/vazkii/patchouli/common/util/EntityUtil.java b/Xplat/src/main/java/vazkii/patchouli/common/util/EntityUtil.java index 190299e8..1a9b3482 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/util/EntityUtil.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/util/EntityUtil.java @@ -23,7 +23,7 @@ private EntityUtil() {} public static String getEntityName(String entityId) { Pair nameAndNbt = splitNameAndNBT(entityId); - EntityType type = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(nameAndNbt.getLeft())); + EntityType type = BuiltInRegistries.ENTITY_TYPE.get(ResourceLocation.tryParse(nameAndNbt.getLeft())); return type.getDescriptionId(); } @@ -42,7 +42,7 @@ public static Function loadEntity(String entityId) { } } - ResourceLocation key = new ResourceLocation(entityId); + ResourceLocation key = ResourceLocation.tryParse(entityId); Optional> maybeType = BuiltInRegistries.ENTITY_TYPE.getOptional(key); if (maybeType.isEmpty()) { throw new RuntimeException("Unknown entity id: " + entityId); diff --git a/Xplat/src/main/java/vazkii/patchouli/common/util/ItemStackUtil.java b/Xplat/src/main/java/vazkii/patchouli/common/util/ItemStackUtil.java index 907f4179..d3011276 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/util/ItemStackUtil.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/util/ItemStackUtil.java @@ -9,6 +9,7 @@ import net.minecraft.core.Holder; import net.minecraft.core.HolderLookup; import net.minecraft.core.component.DataComponentMap; +import net.minecraft.core.component.DataComponentPatch; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; @@ -33,7 +34,7 @@ public final class ItemStackUtil { private ItemStackUtil() {} - public static Triple, DataComponentMap, Integer> deserializeStack(String string, HolderLookup.Provider registries) { + public static Triple, DataComponentPatch, Integer> deserializeStack(String string, HolderLookup.Provider registries) { StringReader reader = new StringReader(string.trim()); ItemParser itemParser = new ItemParser(registries); try { @@ -49,7 +50,7 @@ public static Triple, DataComponentMap, Integer> deserializeStack(S } } - public static ItemStack loadFromParsed(Triple, DataComponentMap, Integer> parsed) { + public static ItemStack loadFromParsed(Triple, DataComponentPatch, Integer> parsed) { var holder = parsed.getLeft(); var components = parsed.getMiddle(); var count = parsed.getRight(); @@ -78,7 +79,7 @@ public static List loadStackListFromString(String ingredientString, H List stacks = new ArrayList<>(); for (String s : stacksSerialized) { if (s.startsWith("tag:")) { - var key = TagKey.create(Registries.ITEM, new ResourceLocation(s.substring(4))); + var key = TagKey.create(Registries.ITEM, ResourceLocation.tryParse(s.substring(4))); BuiltInRegistries.ITEM.getTag(key).ifPresent(tag -> tag.stream().forEach(item -> stacks.add(new ItemStack(item)))); } else { stacks.add(loadStackFromString(s, registries)); @@ -175,15 +176,14 @@ private static String[] splitStacksFromSerializedIngredient(String ingredientSer public static ItemStack loadStackFromJson(JsonObject json, HolderLookup.Provider registries) { String itemName = json.get("item").getAsString(); - Item item = BuiltInRegistries.ITEM.getOptional(new ResourceLocation(itemName)).orElseThrow(() -> new IllegalArgumentException("Unknown item '" + itemName + "'") + Item item = BuiltInRegistries.ITEM.getOptional(ResourceLocation.tryParse(itemName)).orElseThrow(() -> new IllegalArgumentException("Unknown item '" + itemName + "'") ); ItemStack stack = new ItemStack(item, GsonHelper.getAsInt(json, "count", 1)); if (json.has("components")) { - DataComponentMap.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json.get("components")).resultOrPartial(e -> { - throw new IllegalArgumentException("Failed to parse components: " + e); - }).ifPresent(stack::applyComponents); + DataComponentMap.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json.get("components")).result() + .ifPresent(stack::applyComponents); } return stack; diff --git a/Xplat/src/main/java/vazkii/patchouli/common/util/SerializationUtil.java b/Xplat/src/main/java/vazkii/patchouli/common/util/SerializationUtil.java index fbb7cd5e..602c4613 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/util/SerializationUtil.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/util/SerializationUtil.java @@ -25,7 +25,7 @@ private SerializationUtil() {} public static ResourceLocation getAsResourceLocation(JsonObject object, String key, @Nullable ResourceLocation fallback) { if (object.has(key)) { - return new ResourceLocation(GsonHelper.convertToString(object.get(key), key)); + return ResourceLocation.tryParse(GsonHelper.convertToString(object.get(key), key)); } else { return fallback; } diff --git a/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorModelBakery.java b/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorModelBakery.java new file mode 100644 index 00000000..6a1eb110 --- /dev/null +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorModelBakery.java @@ -0,0 +1,14 @@ +package vazkii.patchouli.mixin.client; + +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ModelBakery.class) +public interface AccessorModelBakery { + @Invoker("getModel") + UnbakedModel invokeGetModel(ResourceLocation location); +} diff --git a/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorMultiBufferSource.java b/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorMultiBufferSource.java index e8465544..70f3ea57 100644 --- a/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorMultiBufferSource.java +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorMultiBufferSource.java @@ -1,6 +1,6 @@ package vazkii.patchouli.mixin.client; -import com.mojang.blaze3d.vertex.BufferBuilder; +import com.mojang.blaze3d.vertex.ByteBufferBuilder; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; @@ -8,13 +8,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import java.util.Map; +import java.util.SequencedMap; @Mixin(MultiBufferSource.BufferSource.class) public interface AccessorMultiBufferSource { - @Accessor("builder") - BufferBuilder getFallbackBuffer(); + @Accessor("sharedBuffer") + ByteBufferBuilder getFallbackBuffer(); @Accessor("fixedBuffers") - Map getFixedBuffers(); + SequencedMap getFixedBuffers(); } diff --git a/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinInventoryScreen.java b/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinInventoryScreen.java index 12432048..b7869b14 100644 --- a/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinInventoryScreen.java +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinInventoryScreen.java @@ -31,7 +31,7 @@ public MixinInventoryScreen(InventoryMenu container, Inventory playerInventory, @Inject(at = @At("RETURN"), method = "init()V") public void onGuiInitPost(CallbackInfo info) { - var bookID = new ResourceLocation(PatchouliConfig.get().inventoryButtonBook()); + var bookID = ResourceLocation.tryParse(PatchouliConfig.get().inventoryButtonBook()); Book book = BookRegistry.INSTANCE.books.get(bookID); if (book == null) { return; diff --git a/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinLevelRenderer.java b/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinLevelRenderer.java index cad79f02..83f5ddee 100644 --- a/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinLevelRenderer.java +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinLevelRenderer.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Camera; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; @@ -18,7 +19,7 @@ @Mixin(LevelRenderer.class) public class MixinLevelRenderer { @Inject(at = @At("RETURN"), method = "renderLevel") - public void onRender(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f pose, Matrix4f matrix4f, CallbackInfo info) { + public void onRender(DeltaTracker deltaTracker, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f pose, Matrix4f matrix4f, CallbackInfo info) { MultiblockVisualizationHandler.onWorldRenderLast(new PoseStack(), pose); } } diff --git a/Xplat/src/main/java/vazkii/patchouli/network/MessageOpenBookGui.java b/Xplat/src/main/java/vazkii/patchouli/network/MessageOpenBookGui.java index 6a98edb6..99400926 100644 --- a/Xplat/src/main/java/vazkii/patchouli/network/MessageOpenBookGui.java +++ b/Xplat/src/main/java/vazkii/patchouli/network/MessageOpenBookGui.java @@ -11,11 +11,11 @@ public record MessageOpenBookGui(ResourceLocation book, @Nullable ResourceLocation entry, int page) implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(PatchouliAPI.MOD_ID, "open_book"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "open_book"); public static final StreamCodec CODEC = CustomPacketPayload.codec( MessageOpenBookGui::write, MessageOpenBookGui::new); - public static final Type TYPE = CustomPacketPayload.createType(ID.toString()); + public static final Type TYPE = new Type<>(ID); public MessageOpenBookGui(FriendlyByteBuf buf) { this(buf.readResourceLocation(), getEntry(buf), buf.readVarInt()); @@ -23,7 +23,7 @@ public MessageOpenBookGui(FriendlyByteBuf buf) { private static ResourceLocation getEntry(FriendlyByteBuf buf) { String entry = buf.readUtf(); - return entry.isEmpty() ? null : new ResourceLocation(entry); + return entry.isEmpty() ? null : ResourceLocation.tryParse(entry); } public void write(FriendlyByteBuf buf) { diff --git a/Xplat/src/main/java/vazkii/patchouli/network/MessageReloadBookContents.java b/Xplat/src/main/java/vazkii/patchouli/network/MessageReloadBookContents.java index 582d3202..4149b722 100644 --- a/Xplat/src/main/java/vazkii/patchouli/network/MessageReloadBookContents.java +++ b/Xplat/src/main/java/vazkii/patchouli/network/MessageReloadBookContents.java @@ -8,11 +8,11 @@ import vazkii.patchouli.api.PatchouliAPI; public record MessageReloadBookContents() implements CustomPacketPayload { - public static final ResourceLocation ID = new ResourceLocation(PatchouliAPI.MOD_ID, "reload_books"); + public static final ResourceLocation ID = ResourceLocation.fromNamespaceAndPath(PatchouliAPI.MOD_ID, "reload_books"); public static final StreamCodec CODEC = CustomPacketPayload.codec( MessageReloadBookContents::write, MessageReloadBookContents::new); - public static final Type TYPE = CustomPacketPayload.createType(ID.toString()); + public static final Type TYPE = new Type<>(ID); public MessageReloadBookContents(final FriendlyByteBuf packetBuffer) { this(); diff --git a/Xplat/src/main/resources/data/patchouli/patchouli_books/comprehensive_test_book/book.json b/Xplat/src/main/resources/data/patchouli/patchouli_books/comprehensive_test_book/book.json index 97979355..cdd76467 100644 --- a/Xplat/src/main/resources/data/patchouli/patchouli_books/comprehensive_test_book/book.json +++ b/Xplat/src/main/resources/data/patchouli/patchouli_books/comprehensive_test_book/book.json @@ -4,7 +4,7 @@ "model": "minecraft:nether_star", "version": "50", "subtitle": "Comprehensive Test Book Subtitle", - "creative_tab": "minecraft:tools", + "creative_tab": "minecraft:tools_and_utilities", "use_resource_pack": true, "text_overflow_mode": "resize", "pause_game": true diff --git a/Xplat/src/main/resources/patchouli_xplat.mixins.json b/Xplat/src/main/resources/patchouli_xplat.mixins.json index 869b4465..0ebe4417 100644 --- a/Xplat/src/main/resources/patchouli_xplat.mixins.json +++ b/Xplat/src/main/resources/patchouli_xplat.mixins.json @@ -10,6 +10,7 @@ "client": [ "client.AccessorClientAdvancements", "client.AccessorKeyMapping", + "client.AccessorModelBakery", "client.AccessorMultiBufferSource", "client.AccessorScreen", "client.MixinClientAdvancements", diff --git a/gradle.properties b/gradle.properties index a2a3d543..2a9dd778 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.jvmargs=-Xmx1G \ --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \ --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -mc_version=1.20.6 +mc_version=1.21 build_number=87 group=vazkii.patchouli mod_name=Patchouli diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd491..e6441136 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b82aa23a..a4413138 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 1aa94a42..b740cf13 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. diff --git a/settings.gradle b/settings.gradle index a0a9afaa..b1e6cfe0 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,9 +1,9 @@ pluginManagement { plugins { - id 'net.neoforged.gradle.userdev' version '7.0.142' apply false + id 'net.neoforged.gradle.userdev' version '7.0.150' apply false id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply false - id 'fabric-loom' version '1.6-SNAPSHOT' apply false + id 'fabric-loom' version '1.7-SNAPSHOT' apply false } repositories { maven {