diff --git a/Fabric/build.gradle b/Fabric/build.gradle index eef8912b4..5e375a773 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -61,15 +61,15 @@ dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" mappings loom.officialMojangMappings() - modImplementation "net.fabricmc:fabric-loader:0.14.9" + modImplementation "net.fabricmc:fabric-loader:0.14.11" - modImplementation "net.fabricmc.fabric-api:fabric-api:0.60.0+1.19.2" + modImplementation "net.fabricmc.fabric-api:fabric-api:0.68.1+1.19.3" compileOnly project(":Xplat") modCompileOnly "mezz.jei:jei-1.19.2-common-api:11.2.0.247" - modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:9.1.528") { transitive = false } - modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:7.0.73") { transitive = false } + modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:10.0.578") { transitive = false } + modCompileOnly("me.shedaniel.cloth:cloth-config-fabric:9.0.94") { 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 5e975f78d..3cecba424 100644 --- a/Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java +++ b/Fabric/src/main/java/vazkii/patchouli/fabric/client/FabricClientInitializer.java @@ -18,7 +18,6 @@ import net.minecraft.server.packs.PackType; import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.util.profiling.ProfilerFiller; - import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.base.BookModel; import vazkii.patchouli.client.base.ClientTicker; @@ -33,7 +32,6 @@ import vazkii.patchouli.fabric.network.FabricMessageOpenBookGui; import vazkii.patchouli.fabric.network.FabricMessageReloadBookContents; -import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; @@ -92,11 +90,11 @@ public void onResourceManagerReload(ResourceManager manager) { }); } - public static void replaceBookModel(ModelBakery loader, Map bakedRegistry) { - ModelResourceLocation key = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory"); - BakedModel oldModel = bakedRegistry.get(key); - if (oldModel != null) { - bakedRegistry.put(key, new BookModel(oldModel, loader)); + public static BakedModel replaceBookModel(BakedModel oldModel, ModelBakery bakery, ResourceLocation key) { + ModelResourceLocation location = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory"); + if (oldModel != null && location.equals(key)) { + return new BookModel(oldModel, bakery); } + return oldModel; } } diff --git a/Fabric/src/main/java/vazkii/patchouli/fabric/common/FabricModInitializer.java b/Fabric/src/main/java/vazkii/patchouli/fabric/common/FabricModInitializer.java index df2bf61e5..f700d05cd 100644 --- a/Fabric/src/main/java/vazkii/patchouli/fabric/common/FabricModInitializer.java +++ b/Fabric/src/main/java/vazkii/patchouli/fabric/common/FabricModInitializer.java @@ -4,21 +4,25 @@ import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.player.UseBlockCallback; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.core.Registry; - +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTabs; import vazkii.patchouli.common.base.PatchouliSounds; import vazkii.patchouli.common.book.BookRegistry; import vazkii.patchouli.common.command.OpenBookCommand; import vazkii.patchouli.common.handler.LecternEventHandler; import vazkii.patchouli.common.handler.ReloadContentsHandler; +import vazkii.patchouli.common.item.ItemModBook; import vazkii.patchouli.common.item.PatchouliItems; public class FabricModInitializer implements ModInitializer { @Override public void onInitialize() { - PatchouliSounds.submitRegistrations((id, e) -> Registry.register(Registry.SOUND_EVENT, id, e)); - PatchouliItems.submitItemRegistrations((id, e) -> Registry.register(Registry.ITEM, id, e)); - PatchouliItems.submitRecipeSerializerRegistrations((id, e) -> Registry.register(Registry.RECIPE_SERIALIZER, id, e)); + PatchouliSounds.submitRegistrations((id, e) -> Registry.register(BuiltInRegistries.SOUND_EVENT, id, e)); + PatchouliItems.submitItemRegistrations((id, e) -> Registry.register(BuiltInRegistries.ITEM, id, e)); + PatchouliItems.submitRecipeSerializerRegistrations((id, e) -> Registry.register(BuiltInRegistries.RECIPE_SERIALIZER, id, e)); FiberPatchouliConfig.setup(); CommandRegistrationCallback.EVENT.register((disp, buildCtx, selection) -> OpenBookCommand.register(disp)); UseBlockCallback.EVENT.register(LecternEventHandler::rightClick); @@ -30,5 +34,16 @@ public void onInitialize() { ReloadContentsHandler.dataReloaded(server); } }); + + BookRegistry.INSTANCE.books.values().forEach(b -> { + if (!b.noBook && !b.isExtension) { + ItemGroupEvents.modifyEntriesEvent(ResourceLocation.tryParse(b.creativeTab)).register(entries -> { + entries.accept(ItemModBook.forBook(b)); + }); + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.searchTab()).register(entries -> { + entries.accept(ItemModBook.forBook(b)); + }); + } + }); } } 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 000000000..a765b88f6 --- /dev/null +++ b/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelBakery.java @@ -0,0 +1,18 @@ +package vazkii.patchouli.mixin.client; + +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; +import vazkii.patchouli.fabric.client.FabricClientInitializer; + +@Mixin(targets = "net.minecraft.client.resources.model.ModelBakery.ModelBakerImpl") +public class MixinModelBakery { + + @ModifyArg(method = "bake(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/client/resources/model/ModelState;)Lnet/minecraft/client/resources/model/BakedModel;", at = @At(value = "RETURN")) + public BakedModel insertBookModel(BakedModel model, ResourceLocation id, ModelBakery bakery) { + return FabricClientInitializer.replaceBookModel(model, bakery, id); + } +} diff --git a/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelManager.java b/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelManager.java deleted file mode 100644 index 6816abebd..000000000 --- a/Fabric/src/main/java/vazkii/patchouli/mixin/client/MixinModelManager.java +++ /dev/null @@ -1,30 +0,0 @@ -package vazkii.patchouli.mixin.client; - -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelManager; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.packs.resources.ResourceManager; -import net.minecraft.util.profiling.ProfilerFiller; - -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import vazkii.patchouli.fabric.client.FabricClientInitializer; - -import java.util.Map; - -@Mixin(ModelManager.class) -public class MixinModelManager { - @Shadow - @Final private Map bakedRegistry; - - @Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/resources/model/ModelBakery;getBakedTopLevelModels()Ljava/util/Map;", shift = At.Shift.AFTER), method = "apply(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V") - public void insertBookModel(ModelBakery loader, ResourceManager manager, ProfilerFiller profiler, CallbackInfo info) { - FabricClientInitializer.replaceBookModel(loader, bakedRegistry); - } -} diff --git a/Fabric/src/main/resources/patchouli_fabric.mixins.json b/Fabric/src/main/resources/patchouli_fabric.mixins.json index ebf258b2c..3104b36db 100644 --- a/Fabric/src/main/resources/patchouli_fabric.mixins.json +++ b/Fabric/src/main/resources/patchouli_fabric.mixins.json @@ -8,7 +8,7 @@ "client": [ "client.MixinGameRenderer", "client.MixinMinecraft", - "client.MixinModelManager", + "client.MixinModelBakery", "client.MixinScreen" ], "injectors": { diff --git a/Forge/build.gradle b/Forge/build.gradle index 0728189c5..2115bd77d 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -74,12 +74,12 @@ minecraft { } dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-43.0.11" + minecraft "net.minecraftforge:forge:${minecraft_version}-44.0.36" implementation project(":Xplat") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' compileOnly fg.deobf("mezz.jei:jei-1.19.2-common-api:11.2.0.247") - runtimeOnly(fg.deobf("mezz.jei:jei-1.19.2-forge:11.2.0.247")) + //runtimeOnly(fg.deobf("mezz.jei:jei-1.19.2-forge:11.2.0.247")) } compileJava { diff --git a/Forge/src/main/java/vazkii/patchouli/forge/client/ForgeClientInitializer.java b/Forge/src/main/java/vazkii/patchouli/forge/client/ForgeClientInitializer.java index 24f616b64..31b2e72a9 100644 --- a/Forge/src/main/java/vazkii/patchouli/forge/client/ForgeClientInitializer.java +++ b/Forge/src/main/java/vazkii/patchouli/forge/client/ForgeClientInitializer.java @@ -150,11 +150,8 @@ public static void onInitializeClient(FMLClientSetupEvent evt) { } @SubscribeEvent - public static void replaceBookModel(ModelEvent.BakingCompleted evt) { + public static void replaceBookModel(ModelEvent.ModifyBakingResult evt) { ModelResourceLocation key = new ModelResourceLocation(PatchouliItems.BOOK_ID, "inventory"); - BakedModel oldModel = evt.getModels().get(key); - if (oldModel != null) { - evt.getModels().put(key, new BookModel(oldModel, evt.getModelBakery())); - } + evt.getModels().computeIfPresent(key, (k, oldModel) -> new BookModel(oldModel, evt.getModelBakery())); } } diff --git a/Forge/src/main/java/vazkii/patchouli/forge/common/ForgeModInitializer.java b/Forge/src/main/java/vazkii/patchouli/forge/common/ForgeModInitializer.java index ecf6be544..b6d959225 100644 --- a/Forge/src/main/java/vazkii/patchouli/forge/common/ForgeModInitializer.java +++ b/Forge/src/main/java/vazkii/patchouli/forge/common/ForgeModInitializer.java @@ -1,7 +1,11 @@ package vazkii.patchouli.forge.common; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraftforge.common.CreativeModeTabRegistry; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.CreativeModeTabEvent; import net.minecraftforge.event.RegisterCommandsEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.server.ServerStartedEvent; @@ -9,16 +13,18 @@ import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.registries.RegisterEvent; - import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.common.base.PatchouliSounds; import vazkii.patchouli.common.book.BookRegistry; import vazkii.patchouli.common.command.OpenBookCommand; import vazkii.patchouli.common.handler.LecternEventHandler; import vazkii.patchouli.common.handler.ReloadContentsHandler; +import vazkii.patchouli.common.item.ItemModBook; import vazkii.patchouli.common.item.PatchouliItems; import vazkii.patchouli.forge.network.ForgeNetworkHandler; +import java.util.Objects; + @Mod.EventBusSubscriber(modid = PatchouliAPI.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) @Mod(PatchouliAPI.MOD_ID) public class ForgeModInitializer { @@ -28,17 +34,27 @@ public ForgeModInitializer() { @SubscribeEvent public static void register(RegisterEvent evt) { - evt.register(Registry.SOUND_EVENT_REGISTRY, rh -> { + evt.register(Registries.SOUND_EVENT, rh -> { PatchouliSounds.submitRegistrations(rh::register); }); - evt.register(Registry.ITEM_REGISTRY, rh -> { + evt.register(Registries.ITEM, rh -> { PatchouliItems.submitItemRegistrations(rh::register); }); - evt.register(Registry.RECIPE_SERIALIZER_REGISTRY, rh -> { + evt.register(Registries.RECIPE_SERIALIZER, rh -> { PatchouliItems.submitRecipeSerializerRegistrations(rh::register); }); } + @SubscribeEvent + public static void processCreativeTabs(CreativeModeTabEvent.BuildContents evt) { + ResourceLocation name = CreativeModeTabRegistry.getName(evt.getTab()); + BookRegistry.INSTANCE.books.values().forEach(b -> { + if (!b.noBook && !b.isExtension && (evt.getTab() == CreativeModeTabs.searchTab() || Objects.equals(ResourceLocation.tryParse(b.creativeTab), name))) { + evt.accept(ItemModBook.forBook(b)); + } + }); + } + @SubscribeEvent public static void onInitialize(FMLCommonSetupEvent evt) { MinecraftForge.EVENT_BUS.addListener((RegisterCommandsEvent e) -> OpenBookCommand.register(e.getDispatcher())); 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 e2c346089..7514ca65b 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/base/BookModel.java @@ -7,23 +7,21 @@ import net.minecraft.client.renderer.block.model.ItemOverrides; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.client.resources.model.ModelResourceLocation; +import net.minecraft.client.resources.model.*; import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; - -import vazkii.patchouli.common.book.Book; -import vazkii.patchouli.common.item.ItemModBook; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import vazkii.patchouli.common.book.Book; +import vazkii.patchouli.common.item.ItemModBook; import java.util.Collections; import java.util.List; +import java.util.function.Function; public class BookModel implements BakedModel { private final BakedModel original; @@ -33,7 +31,28 @@ public BookModel(BakedModel original, ModelBakery loader) { this.original = original; BlockModel missing = (BlockModel) loader.getModel(ModelBakery.MISSING_MODEL_LOCATION); - this.itemHandler = new ItemOverrides(loader, missing, id -> missing, Collections.emptyList()) { + this.itemHandler = new ItemOverrides(new ModelBaker() { + // soft implement IForgeModelBaker + public Function getModelTextureGetter() { + return null; + } + + // soft implement IForgeModelBaker + public BakedModel bake(ResourceLocation location, ModelState state, Function sprites) { + return null; + } + + @Override + public UnbakedModel getModel(ResourceLocation resourceLocation) { + return null; + } + + @Nullable + @Override + public BakedModel bake(ResourceLocation resourceLocation, ModelState modelState) { + return null; + } + }, missing, Collections.emptyList()) { @Override public BakedModel resolve(@NotNull BakedModel original, @NotNull ItemStack stack, @Nullable ClientLevel world, @Nullable LivingEntity entity, int seed) { diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/BookPage.java b/Xplat/src/main/java/vazkii/patchouli/client/book/BookPage.java index d607b08a8..af6bd8edd 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/BookPage.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/BookPage.java @@ -2,13 +2,11 @@ import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.components.Button; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; - import vazkii.patchouli.client.base.ClientAdvancements; import vazkii.patchouli.client.book.gui.GuiBookEntry; import vazkii.patchouli.common.base.PatchouliConfig; @@ -57,8 +55,8 @@ public void onHidden(GuiBookEntry parent) { } protected void addButton(Button button) { - button.x += (parent.bookLeft + left); - button.y += (parent.bookTop + top); + button.setX(button.getX() + (parent.bookLeft + left)); + button.setY(button.getY() + (parent.bookTop + top)); buttons.add(button); parent.addRenderableWidget(button); } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBook.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBook.java index 97f9880ec..411a9d704 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBook.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBook.java @@ -4,12 +4,11 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.datafixers.util.Pair; - import net.minecraft.ChatFormatting; import net.minecraft.Util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; -import net.minecraft.client.gui.components.Widget; +import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.ConfirmLinkScreen; @@ -20,14 +19,18 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.item.ItemStack; - +import org.jetbrains.annotations.Nullable; import org.lwjgl.glfw.GLFW; - import vazkii.patchouli.client.base.ClientTicker; import vazkii.patchouli.client.base.PersistentData; import vazkii.patchouli.client.base.PersistentData.Bookmark; -import vazkii.patchouli.client.book.*; -import vazkii.patchouli.client.book.gui.button.*; +import vazkii.patchouli.client.book.BookCategory; +import vazkii.patchouli.client.book.BookEntry; +import vazkii.patchouli.client.book.EntryDisplayState; +import vazkii.patchouli.client.book.gui.button.GuiButtonBook; +import vazkii.patchouli.client.book.gui.button.GuiButtonBookArrow; +import vazkii.patchouli.client.book.gui.button.GuiButtonBookBookmark; +import vazkii.patchouli.client.book.gui.button.GuiButtonBookMarkRead; import vazkii.patchouli.client.handler.MultiblockVisualizationHandler; import vazkii.patchouli.client.jei.PatchouliJeiPlugin; import vazkii.patchouli.common.base.PatchouliSounds; @@ -35,11 +38,9 @@ import vazkii.patchouli.mixin.client.AccessorScreen; import vazkii.patchouli.xplat.IXplatAbstractions; -import org.jetbrains.annotations.Nullable; - import java.awt.*; -import java.util.*; import java.util.List; +import java.util.*; import java.util.function.Predicate; public abstract class GuiBook extends Screen { @@ -169,10 +170,10 @@ public void addBookmarkButtons() { } } - public final void removeDrawablesIf(Predicate pred) { + public final void removeDrawablesIf(Predicate pred) { ((AccessorScreen) (this)).getRenderables().removeIf(pred); - children().removeIf(listener -> listener instanceof Widget w && pred.test(w)); - ((AccessorScreen) (this)).getNarratables().removeIf(listener -> listener instanceof Widget w && pred.test(w)); + children().removeIf(listener -> listener instanceof Renderable w && pred.test(w)); + ((AccessorScreen) (this)).getNarratables().removeIf(listener -> listener instanceof Renderable w && pred.test(w)); } public final void removeDrawablesIn(Collection coll) { @@ -180,7 +181,7 @@ public final void removeDrawablesIn(Collection coll) { } @Override // make public - public T addRenderableWidget(T drawableElement) { + public T addRenderableWidget(T drawableElement) { return super.addRenderableWidget(drawableElement); } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java index e15ee5109..a9015b4ff 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntry.java @@ -1,7 +1,6 @@ package vazkii.patchouli.client.book.gui; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.components.Button; @@ -11,7 +10,8 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; - +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import vazkii.patchouli.api.IComponentRenderContext; import vazkii.patchouli.client.RenderHelper; import vazkii.patchouli.client.base.PersistentData; @@ -21,9 +21,6 @@ import vazkii.patchouli.client.book.BookPage; import vazkii.patchouli.common.book.Book; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -291,8 +288,8 @@ public void registerButton(Button button, int pageNum, Runnable onClick) { @Override public void addWidget(AbstractWidget widget, int pageNum) { - widget.x += bookLeft + ((pageNum % 2) == 0 ? LEFT_PAGE_X : RIGHT_PAGE_X); - widget.y += bookTop; + widget.setX(widget.getX() + (bookLeft + ((pageNum % 2) == 0 ? LEFT_PAGE_X : RIGHT_PAGE_X))); + widget.setY(widget.getY() + bookTop); addRenderableWidget(widget); } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java index 62e5a480d..edad44542 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/GuiBookEntryList.java @@ -2,14 +2,11 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; - import org.lwjgl.glfw.GLFW; - import vazkii.patchouli.client.book.BookEntry; import vazkii.patchouli.client.book.gui.button.GuiButtonCategory; import vazkii.patchouli.client.book.gui.button.GuiButtonEntry; @@ -102,9 +99,9 @@ void drawForegroundElements(PoseStack ms, int mouseX, int mouseY, float partialT if (!searchField.getValue().isEmpty()) { RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - drawFromTexture(ms, book, searchField.x - 8, searchField.y, 140, 183, 99, 14); + drawFromTexture(ms, book, searchField.getX() - 8, searchField.getY(), 140, 183, 99, 14); Component toDraw = Component.literal(searchField.getValue()).setStyle(book.getFontStyle()); - font.draw(ms, toDraw, searchField.x + 7, searchField.y + 1, book.textColor); + font.draw(ms, toDraw, searchField.getX() + 7, searchField.getY() + 1, book.textColor); } if (visibleEntries.isEmpty()) { diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java index 873175a17..72a019584 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBook.java @@ -2,11 +2,9 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.gui.components.Button; import net.minecraft.client.sounds.SoundManager; import net.minecraft.network.chat.Component; - import vazkii.patchouli.client.book.gui.GuiBook; import java.util.Arrays; @@ -25,7 +23,7 @@ public GuiButtonBook(GuiBook parent, int x, int y, int u, int v, int w, int h, O } public GuiButtonBook(GuiBook parent, int x, int y, int u, int v, int w, int h, Supplier displayCondition, OnPress onPress, Component... tooltip) { - super(x, y, w, h, tooltip[0], onPress); + super(x, y, w, h, tooltip[0], onPress, DEFAULT_NARRATION); this.parent = parent; this.u = u; this.v = v; @@ -42,7 +40,7 @@ public final void render(PoseStack ms, int mouseX, int mouseY, float partialTick @Override public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) { RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - GuiBook.drawFromTexture(ms, parent.book, x, y, u + (isHoveredOrFocused() ? width : 0), v, width, height); + GuiBook.drawFromTexture(ms, parent.book, getX(), getY(), u + (isHoveredOrFocused() ? width : 0), v, width, height); if (isHoveredOrFocused()) { parent.setTooltip(getTooltip()); } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java index 5bc98dc72..c862655fb 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookBookmark.java @@ -2,11 +2,9 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.ChatFormatting; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; - import vazkii.patchouli.client.base.PersistentData.Bookmark; import vazkii.patchouli.client.book.BookEntry; import vazkii.patchouli.client.book.gui.GuiBook; @@ -38,8 +36,8 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTick if (bookmark != null && entry != null) { ms.pushPose(); ms.scale(0.5F, 0.5F, 0.5F); - int px = x * 2 + (isHoveredOrFocused() ? 6 : 2); - int py = y * 2 + 2; + int px = getX() * 2 + (isHoveredOrFocused() ? 6 : 2); + int py = getY() * 2 + 2; entry.getIcon().render(ms, px, py); RenderSystem.disableDepthTest(); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java index 8255c6eef..7bc1c008d 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookEye.java @@ -1,11 +1,9 @@ package vazkii.patchouli.client.book.gui.button; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.ChatFormatting; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; - import vazkii.patchouli.client.base.ClientTicker; import vazkii.patchouli.client.base.PersistentData; import vazkii.patchouli.client.book.gui.GuiBook; @@ -23,7 +21,7 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTick super.renderButton(ms, mouseX, mouseY, partialTicks); if (!PersistentData.data.clickedVisualize && (ClientTicker.ticksInGame) % 20 < 10) { - parent.getMinecraft().font.drawShadow(ms, "!", x, y, 0xFF3333); + parent.getMinecraft().font.drawShadow(ms, "!", getX(), getY(), 0xFF3333); } } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java index 14f9e0d85..eb49637a5 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonBookMarkRead.java @@ -1,10 +1,8 @@ package vazkii.patchouli.client.book.gui.button; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; - import vazkii.patchouli.client.base.PersistentData; import vazkii.patchouli.client.book.BookCategory; import vazkii.patchouli.client.book.BookEntry; @@ -23,9 +21,9 @@ public GuiButtonBookMarkRead(GuiBook parent, int x, int y) { @Override public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTicks) { - int px = x + 1; - int py = (int) (y + 0.5); - GuiBook.drawFromTexture(ms, book, x, y, 285, 160, 13, 10); + int px = getX() + 1; + int py = (int) (getY() + 0.5); + GuiBook.drawFromTexture(ms, book, getX(), getY(), 285, 160, 13, 10); GuiBook.drawFromTexture(ms, book, px, py, u, v, width, height); if (isHoveredOrFocused()) { GuiBook.drawFromTexture(ms, book, px, py, u + 11, v, width, height); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java index d745b208b..a4ad6a5b5 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonCategory.java @@ -2,19 +2,16 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.ChatFormatting; import net.minecraft.client.gui.components.Button; import net.minecraft.client.sounds.SoundManager; import net.minecraft.network.chat.Component; - +import org.jetbrains.annotations.Nullable; import vazkii.patchouli.client.base.ClientTicker; import vazkii.patchouli.client.book.BookCategory; import vazkii.patchouli.client.book.BookIcon; import vazkii.patchouli.client.book.gui.GuiBook; -import org.jetbrains.annotations.Nullable; - public class GuiButtonCategory extends Button { private static final int ANIM_TIME = 5; @@ -32,7 +29,7 @@ public GuiButtonCategory(GuiBook parent, int x, int y, BookCategory category, Bu } public GuiButtonCategory(GuiBook parent, int x, int y, BookIcon icon, Component name, Button.OnPress onPress) { - super(parent.bookLeft + x, parent.bookTop + y, 20, 20, name, onPress); + super(parent.bookLeft + x, parent.bookTop + y, 20, 20, name, onPress, DEFAULT_NARRATION); this.parent = parent; this.u = x; this.v = y; @@ -55,20 +52,20 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTick if (locked) { RenderSystem.setShaderColor(1F, 1F, 1F, 0.7F); - GuiBook.drawLock(ms, parent.book, x + 2, y + 2); + GuiBook.drawLock(ms, parent.book, getX() + 2, getY() + 2); } else { - icon.render(ms, x + 2, y + 2); + icon.render(ms, getX() + 2, getY() + 2); } ms.pushPose(); RenderSystem.enableBlend(); RenderSystem.setShaderColor(1F, 1F, 1F, transparency); ms.translate(0, 0, 200); - GuiBook.drawFromTexture(ms, parent.book, x, y, u, v, width, height); + GuiBook.drawFromTexture(ms, parent.book, getX(), getY(), u, v, width, height); RenderSystem.setShaderColor(1F, 1F, 1F, 1F); if (category != null && !category.isLocked()) { - GuiBook.drawMarking(ms, parent.book, x, y, 0, category.getReadState()); + GuiBook.drawMarking(ms, parent.book, getX(), getY(), 0, category.getReadState()); } ms.popPose(); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java index 6d006c843..9df538554 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/gui/button/GuiButtonEntry.java @@ -2,7 +2,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; @@ -10,7 +9,6 @@ import net.minecraft.client.sounds.SoundManager; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; - import vazkii.patchouli.client.base.ClientTicker; import vazkii.patchouli.client.book.BookEntry; import vazkii.patchouli.client.book.gui.GuiBook; @@ -24,7 +22,7 @@ public class GuiButtonEntry extends Button { private float timeHovered; public GuiButtonEntry(GuiBook parent, int x, int y, BookEntry entry, Button.OnPress onPress) { - super(x, y, GuiBook.PAGE_WIDTH, 10, entry.getName(), onPress); + super(x, y, GuiBook.PAGE_WIDTH, 10, entry.getName(), onPress, DEFAULT_NARRATION); this.parent = parent; this.entry = entry; } @@ -43,14 +41,14 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTick boolean locked = entry.isLocked(); ms.scale(0.5F, 0.5F, 0.5F); - GuiComponent.fill(ms, x * 2, y * 2, (x + (int) ((float) width * widthFract)) * 2, (y + height) * 2, 0x22000000); + GuiComponent.fill(ms, getX() * 2, getY() * 2, (getX() + (int) ((float) width * widthFract)) * 2, (getY() + height) * 2, 0x22000000); RenderSystem.enableBlend(); if (locked) { RenderSystem.setShaderColor(1F, 1F, 1F, 0.7F); - GuiBook.drawLock(ms, parent.book, x * 2 + 2, y * 2 + 2); + GuiBook.drawLock(ms, parent.book, getX() * 2 + 2, getY() * 2 + 2); } else { - entry.getIcon().render(ms, x * 2 + 2, y * 2 + 2); + entry.getIcon().render(ms, getX() * 2 + 2, getY() * 2 + 2); } ms.scale(2F, 2F, 2F); @@ -66,10 +64,10 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float partialTick } name = name.withStyle(entry.getBook().getFontStyle()); - Minecraft.getInstance().font.draw(ms, name, x + 12, y, getColor()); + Minecraft.getInstance().font.draw(ms, name, getX() + 12, getY(), getColor()); if (!entry.isLocked()) { - GuiBook.drawMarking(ms, parent.book, x + width - 5, y + 1, entry.hashCode(), entry.getReadState()); + GuiBook.drawMarking(ms, parent.book, getX() + width - 5, getY() + 1, entry.hashCode(), entry.getReadState()); } } } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageEntity.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageEntity.java index 2a89d6942..e862b3ef3 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageEntity.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageEntity.java @@ -3,15 +3,13 @@ import com.google.gson.annotations.SerializedName; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Vector3f; - +import com.mojang.math.Axis; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderDispatcher; import net.minecraft.client.resources.language.I18n; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; - import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.base.ClientTicker; import vazkii.patchouli.client.book.BookContentsBuilder; @@ -93,8 +91,8 @@ public static void renderEntity(PoseStack ms, Entity entity, Level world, float ms.translate(x, y, 50); ms.scale(renderScale, renderScale, renderScale); ms.translate(0, offset, 0); - ms.mulPose(Vector3f.ZP.rotationDegrees(180)); - ms.mulPose(Vector3f.YP.rotationDegrees(rotation)); + ms.mulPose(Axis.ZP.rotationDegrees(180)); + ms.mulPose(Axis.YP.rotationDegrees(rotation)); EntityRenderDispatcher erd = Minecraft.getInstance().getEntityRenderDispatcher(); MultiBufferSource.BufferSource immediate = Minecraft.getInstance().renderBuffers().bufferSource(); erd.setRenderShadow(false); diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageLink.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageLink.java index 4075f90c2..686b3aae3 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageLink.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageLink.java @@ -1,10 +1,8 @@ package vazkii.patchouli.client.book.page; import com.google.gson.annotations.SerializedName; - import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; - import vazkii.patchouli.api.IVariable; import vazkii.patchouli.client.book.BookContentsBuilder; import vazkii.patchouli.client.book.BookEntry; @@ -28,8 +26,7 @@ public void build(BookEntry entry, BookContentsBuilder builder, int pageNum) { public void onDisplayed(GuiBookEntry parent, int left, int top) { super.onDisplayed(parent, left, top); - addButton(new Button(GuiBook.PAGE_WIDTH / 2 - 50, GuiBook.PAGE_HEIGHT - 35, 100, 20, i18nText(realText.getString()), - (b) -> GuiBook.openWebLink(parent, url))); + addButton(Button.builder(i18nText(realText.getString()), (b) -> GuiBook.openWebLink(parent, url)).size(GuiBook.PAGE_WIDTH / 2 - 50, GuiBook.PAGE_HEIGHT - 35).pos(100, 20).build()); } } diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageMultiblock.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageMultiblock.java index 5ef130b99..21a976cab 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageMultiblock.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageMultiblock.java @@ -4,10 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; -import com.mojang.math.Matrix4f; -import com.mojang.math.Vector3f; -import com.mojang.math.Vector4f; - +import com.mojang.math.Axis; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; @@ -24,7 +21,9 @@ import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; - +import org.jetbrains.annotations.NotNull; +import org.joml.Matrix4f; +import org.joml.Vector4f; import vazkii.patchouli.api.IMultiblock; import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.base.ClientTicker; @@ -43,8 +42,6 @@ import vazkii.patchouli.common.multiblock.SerializedMultiblock; import vazkii.patchouli.xplat.IClientXplatAbstractions; -import org.jetbrains.annotations.NotNull; - import java.util.Collections; import java.util.Set; import java.util.WeakHashMap; @@ -148,11 +145,11 @@ private void renderMultiblock(PoseStack ms) { // Initial eye pos somewhere off in the distance in the -Z direction Vector4f eye = new Vector4f(0, 0, -100, 1); Matrix4f rotMat = new Matrix4f(); - rotMat.setIdentity(); + rotMat.identity(); // For each GL rotation done, track the opposite to keep the eye pos accurate - ms.mulPose(Vector3f.XP.rotationDegrees(-30F)); - rotMat.multiply(Vector3f.XP.rotationDegrees(30)); + ms.mulPose(Axis.XP.rotationDegrees(-30F)); + rotMat.rotation(Axis.XP.rotationDegrees(30)); float offX = (float) -sizeX / 2; float offZ = (float) -sizeZ / 2 + 1; @@ -162,15 +159,15 @@ private void renderMultiblock(PoseStack ms) { time += ClientTicker.partialTicks; } ms.translate(-offX, 0, -offZ); - ms.mulPose(Vector3f.YP.rotationDegrees(time)); - rotMat.multiply(Vector3f.YP.rotationDegrees(-time)); - ms.mulPose(Vector3f.YP.rotationDegrees(45)); - rotMat.multiply(Vector3f.YP.rotationDegrees(-45)); + ms.mulPose(Axis.YP.rotationDegrees(time)); + rotMat.rotation(Axis.YP.rotationDegrees(-time)); + ms.mulPose(Axis.YP.rotationDegrees(45)); + rotMat.rotation(Axis.YP.rotationDegrees(-45)); ms.translate(offX, 0, offZ); // Finally apply the rotations - eye.transform(rotMat); - eye.perspectiveDivide(); + eye.mul(rotMat); + //eye.perspectiveDivide();//TODO find what replaces this /* TODO XXX This does not handle visualization of sparse multiblocks correctly. Dense multiblocks store everything in positive X/Z, so this works, but sparse multiblocks store everything from the JSON as-is. Potential solution: Rotate around the offset vars of the multiblock, and add AABB method for extent of the multiblock diff --git a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageQuest.java b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageQuest.java index 5bfd2b66f..f140f33cf 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageQuest.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/page/PageQuest.java @@ -1,12 +1,10 @@ package vazkii.patchouli.client.book.page; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.gui.components.Button; import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; - import vazkii.patchouli.client.base.ClientAdvancements; import vazkii.patchouli.client.base.PersistentData; import vazkii.patchouli.client.base.PersistentData.BookData; @@ -47,7 +45,7 @@ public void onDisplayed(GuiBookEntry parent, int left, int top) { super.onDisplayed(parent, left, top); if (isManual) { - Button button = new Button(GuiBook.PAGE_WIDTH / 2 - 50, GuiBook.PAGE_HEIGHT - 35, 100, 20, Component.empty(), this::questButtonClicked); + Button button = Button.builder(Component.empty(), this::questButtonClicked).size(GuiBook.PAGE_WIDTH / 2 - 50, GuiBook.PAGE_HEIGHT - 35).pos(100, 20).build(); addButton(button); updateButtonText(button); } 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 5b24e691d..fa63132de 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 @@ -1,18 +1,16 @@ package vazkii.patchouli.client.book.page.abstr; import net.minecraft.client.Minecraft; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeManager; import net.minecraft.world.item.crafting.RecipeType; - +import org.jetbrains.annotations.Nullable; import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.book.BookContentsBuilder; import vazkii.patchouli.client.book.BookEntry; -import org.jetbrains.annotations.Nullable; - public abstract class PageDoubleRecipeRegistry> extends PageDoubleRecipe { private final RecipeType recipeType; @@ -45,7 +43,7 @@ protected T loadRecipe(BookContentsBuilder builder, BookEntry entry, ResourceLoc return tempRecipe; } - PatchouliAPI.LOGGER.warn("Recipe {} (of type {}) not found", res, Registry.RECIPE_TYPE.getKey(recipeType)); + PatchouliAPI.LOGGER.warn("Recipe {} (of type {}) not found", res, BuiltInRegistries.RECIPE_TYPE.getKey(recipeType)); return null; } 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 e4287d1f3..0fa576bf4 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 @@ -1,10 +1,9 @@ package vazkii.patchouli.client.book.template.test; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; - import vazkii.patchouli.api.IComponentProcessor; import vazkii.patchouli.api.IVariable; import vazkii.patchouli.api.IVariableProvider; @@ -21,7 +20,7 @@ public void setup(IVariableProvider variables) { } ResourceLocation key = new ResourceLocation(entityType); - entityName = Registry.ENTITY_TYPE.getOptional(key) + 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/variable/ItemStackVariableSerializer.java b/Xplat/src/main/java/vazkii/patchouli/client/book/template/variable/ItemStackVariableSerializer.java index 1150ad182..e730991c5 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/book/template/variable/ItemStackVariableSerializer.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/book/template/variable/ItemStackVariableSerializer.java @@ -2,10 +2,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; - -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.ItemStack; - import vazkii.patchouli.api.IVariableSerializer; import vazkii.patchouli.common.util.ItemStackUtil; @@ -28,7 +26,7 @@ public ItemStack fromJson(JsonElement json) { public JsonElement toJson(ItemStack stack) { // Adapted from net.minecraftforge.common.crafting.StackList::toJson JsonObject ret = new JsonObject(); - ret.addProperty("item", Registry.ITEM.getKey(stack.getItem()).toString()); + ret.addProperty("item", BuiltInRegistries.ITEM.getKey(stack.getItem()).toString()); if (stack.getCount() != 1) { ret.addProperty("count", stack.getCount()); } 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 ea5fd4da0..8ead812f7 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 @@ -7,7 +7,7 @@ import net.minecraft.network.chat.Style; import net.minecraft.network.chat.TextColor; import net.minecraft.resources.ResourceLocation; - +import org.jetbrains.annotations.Nullable; import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.book.BookEntry; import vazkii.patchouli.client.book.gui.GuiBook; @@ -15,11 +15,10 @@ import vazkii.patchouli.client.book.gui.GuiBookEntry; import vazkii.patchouli.common.book.Book; -import org.jetbrains.annotations.Nullable; - import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class BookTextParser { public static final MutableComponent EMPTY_STRING_COMPONENT = Component.literal(""); @@ -193,7 +192,7 @@ public static void register(FunctionProcessor function, String... names) { state.tooltip = Component.literal(parameter.length() < 20 ? parameter : parameter.substring(0, 20) + "..."); } state.onClick = () -> { - state.gui.getMinecraft().player.commandSigned(parameter.substring(1), null); + state.gui.getMinecraft().player.connection.sendCommand(parameter.substring(1)); return true; }; return ""; 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 99284af23..3e9387642 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/gui/GuiButtonInventoryBook.java @@ -2,14 +2,12 @@ import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.PoseStack; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.gui.components.Button; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; - import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.RenderHelper; import vazkii.patchouli.client.book.BookContents; @@ -25,7 +23,7 @@ public GuiButtonInventoryBook(Book book, int x, int y) { super(x, y, 20, 20, Component.empty(), (b) -> { BookContents contents = book.getContents(); contents.openLexiconGui(contents.getCurrentGui(), false); - }); + }, DEFAULT_NARRATION); this.book = book; } @@ -35,15 +33,15 @@ public void renderButton(PoseStack ms, int mouseX, int mouseY, float pticks) { RenderSystem.setShaderTexture(0, new ResourceLocation(PatchouliAPI.MOD_ID, "textures/gui/inventory_button.png")); RenderSystem.setShaderColor(1F, 1F, 1F, 1F); - boolean hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height; - GuiComponent.blit(ms, x, y, (hovered ? 20 : 0), 0, width, height, 64, 64); + boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height; + GuiComponent.blit(ms, getX(), getY(), (hovered ? 20 : 0), 0, width, height, 64, 64); ItemStack stack = book.getBookItem(); - RenderHelper.renderItemStackInGui(ms, stack, x + 2, y + 2); + RenderHelper.renderItemStackInGui(ms, stack, getX() + 2, getY() + 2); EntryDisplayState readState = book.getContents().getReadState(); if (readState.hasIcon && readState.showInInventory) { - GuiBook.drawMarking(ms, book, x, y, 0, readState); + GuiBook.drawMarking(ms, book, getX(), getY(), 0, readState); } } 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 ea3321569..a07d24b04 100644 --- a/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java +++ b/Xplat/src/main/java/vazkii/patchouli/client/handler/MultiblockVisualizationHandler.java @@ -2,17 +2,10 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; -import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.blaze3d.vertex.*; import com.mojang.blaze3d.vertex.VertexFormat.Mode; import com.mojang.datafixers.util.Pair; -import com.mojang.math.Matrix4f; - import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiComponent; import net.minecraft.client.renderer.MultiBufferSource; @@ -36,7 +29,7 @@ import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; - +import org.joml.Matrix4f; import vazkii.patchouli.api.IMultiblock; import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.RenderHelper; @@ -46,7 +39,7 @@ import vazkii.patchouli.common.util.RotationUtil; import vazkii.patchouli.mixin.client.AccessorMultiBufferSource; -import java.awt.Color; +import java.awt.*; import java.util.Collection; import java.util.IdentityHashMap; import java.util.Map; diff --git a/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliAPIImpl.java b/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliAPIImpl.java index 94f5e1948..e28083b8e 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliAPIImpl.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliAPIImpl.java @@ -1,11 +1,10 @@ package vazkii.patchouli.common.base; import com.google.common.base.Preconditions; - import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.core.BlockPos; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; @@ -17,9 +16,8 @@ import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; - import org.apache.commons.io.IOUtils; - +import org.jetbrains.annotations.NotNull; import vazkii.patchouli.api.*; import vazkii.patchouli.api.PatchouliAPI.IPatchouliAPI; import vazkii.patchouli.client.book.BookContents; @@ -37,8 +35,6 @@ import vazkii.patchouli.common.multiblock.StateMatcher; import vazkii.patchouli.xplat.IXplatAbstractions; -import org.jetbrains.annotations.NotNull; - import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; @@ -246,7 +242,7 @@ public IStateMatcher tagMatcher(@NotNull TagKey tag) { @NotNull @Override public BlockState getDisplayedState(long ticks) { - return Registry.BLOCK.getTag(tag).map(n -> { + return BuiltInRegistries.BLOCK.getTag(tag).map(n -> { int idx = (int) ((ticks / 20) % n.size()); return n.get(idx).value().defaultBlockState(); }).orElse(Blocks.BEDROCK.defaultBlockState()); 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 b005dff9c..c5e356a24 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliSounds.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/base/PatchouliSounds.java @@ -1,17 +1,16 @@ package vazkii.patchouli.common.base; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; - import vazkii.patchouli.api.PatchouliAPI; import java.util.function.BiConsumer; public class PatchouliSounds { - public static final SoundEvent BOOK_OPEN = new SoundEvent(new ResourceLocation(PatchouliAPI.MOD_ID, "book_open")); - public static final SoundEvent BOOK_FLIP = new SoundEvent(new ResourceLocation(PatchouliAPI.MOD_ID, "book_flip")); + 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 void submitRegistrations(BiConsumer e) { e.accept(BOOK_OPEN.getLocation(), BOOK_OPEN); @@ -19,7 +18,7 @@ public static void submitRegistrations(BiConsumer } public static SoundEvent getSound(ResourceLocation key, SoundEvent fallback) { - return Registry.SOUND_EVENT.getOptional(key).orElse(fallback); + return BuiltInRegistries.SOUND_EVENT.getOptional(key).orElse(fallback); } } diff --git a/Xplat/src/main/java/vazkii/patchouli/common/item/ItemModBook.java b/Xplat/src/main/java/vazkii/patchouli/common/item/ItemModBook.java index 0378b7c64..7afb7801a 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/item/ItemModBook.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/item/ItemModBook.java @@ -1,8 +1,7 @@ package vazkii.patchouli.common.item; import net.minecraft.ChatFormatting; -import net.minecraft.core.NonNullList; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -12,12 +11,10 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; - import vazkii.patchouli.api.PatchouliAPI; import vazkii.patchouli.client.book.BookEntry; import vazkii.patchouli.common.base.PatchouliSounds; @@ -31,9 +28,7 @@ public class ItemModBook extends Item { public static final String TAG_BOOK = "patchouli:book"; public ItemModBook() { - super(new Item.Properties() - .stacksTo(1) - .tab(CreativeModeTab.TAB_MISC)); + super(new Item.Properties().stacksTo(1)); } public static float getCompletion(ItemStack stack) { @@ -73,23 +68,13 @@ public static ItemStack forBook(ResourceLocation book) { return stack; } - @Override - public void fillItemCategory(CreativeModeTab tab, NonNullList items) { - String tabName = tab.getRecipeFolderName(); - BookRegistry.INSTANCE.books.values().forEach(b -> { - if (!b.noBook && !b.isExtension && (tab == CreativeModeTab.TAB_SEARCH || b.creativeTab.equals(tabName))) { - items.add(forBook(b)); - } - }); - } - // SoftImplement IForgeItem public String getCreatorModId(ItemStack stack) { var book = getBook(stack); if (book != null) { return book.owner.getId(); } - return Registry.ITEM.getKey(this).getNamespace(); + return BuiltInRegistries.ITEM.getKey(this).getNamespace(); } public static Book getBook(ItemStack stack) { @@ -116,7 +101,7 @@ public String getCreatorModId(ItemStack itemStack) { if (book != null) { return book.owner.getModId(); } - + return super.getCreatorModId(itemStack); } */ diff --git a/Xplat/src/main/java/vazkii/patchouli/common/multiblock/AbstractMultiblock.java b/Xplat/src/main/java/vazkii/patchouli/common/multiblock/AbstractMultiblock.java index d4f2e4375..3855660fb 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/multiblock/AbstractMultiblock.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/multiblock/AbstractMultiblock.java @@ -1,17 +1,12 @@ package vazkii.patchouli.common.multiblock; import com.mojang.datafixers.util.Pair; - import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.core.Registry; import net.minecraft.core.Vec3i; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.ColorResolver; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.LightLayer; +import net.minecraft.world.level.*; import net.minecraft.world.level.biome.Biomes; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.Rotation; @@ -20,13 +15,11 @@ import net.minecraft.world.level.lighting.LevelLightEngine; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; - +import org.jetbrains.annotations.Nullable; import vazkii.patchouli.api.IMultiblock; import vazkii.patchouli.api.TriPredicate; import vazkii.patchouli.common.util.RotationUtil; -import org.jetbrains.annotations.Nullable; - import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -165,7 +158,7 @@ public LevelLightEngine getLightEngine() { @Override public int getBlockTint(BlockPos pos, ColorResolver color) { - var plains = world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY) + var plains = world.registryAccess().registryOrThrow(Registries.BIOME) .getOrThrow(Biomes.PLAINS); return color.getColor(plains, pos.getX(), pos.getZ()); } diff --git a/Xplat/src/main/java/vazkii/patchouli/common/multiblock/StringStateMatcher.java b/Xplat/src/main/java/vazkii/patchouli/common/multiblock/StringStateMatcher.java index feb18bf91..de1021b0e 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/multiblock/StringStateMatcher.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/multiblock/StringStateMatcher.java @@ -1,17 +1,15 @@ package vazkii.patchouli.common.multiblock; import com.mojang.brigadier.exceptions.CommandSyntaxException; - import net.minecraft.commands.arguments.blocks.BlockStateParser; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderSet; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.Property; - import vazkii.patchouli.api.IStateMatcher; import vazkii.patchouli.api.TriPredicate; @@ -30,7 +28,7 @@ public static IStateMatcher fromString(String s) throws CommandSyntaxException { } // c.f. BlockPredicateArgument. Similar, but doesn't use vanilla's weird caching class. - return BlockStateParser.parseForTesting(Registry.BLOCK, s, true).map( + return BlockStateParser.parseForTesting(BuiltInRegistries.BLOCK.asLookup(), s, true).map( blockResult -> new ExactMatcher(blockResult.blockState(), blockResult.properties()), tagResult -> new TagMatcher(tagResult.tag(), tagResult.vagueProperties()) ); diff --git a/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java b/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java index 2e1599225..8651d1645 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapedBookRecipe.java @@ -2,10 +2,10 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.ShapedRecipe; - import vazkii.patchouli.api.PatchouliAPI; /** @@ -17,7 +17,7 @@ public class ShapedBookRecipe extends ShapedRecipe { public static final RecipeSerializer SERIALIZER = new BookRecipeSerializer<>(RecipeSerializer.SHAPED_RECIPE, ShapedBookRecipe::new); public ShapedBookRecipe(ShapedRecipe compose, ResourceLocation outputBook) { - super(compose.getId(), compose.getGroup(), compose.getWidth(), compose.getHeight(), compose.getIngredients(), getOutputBook(compose, outputBook)); + super(compose.getId(), compose.getGroup(), CraftingBookCategory.MISC, compose.getWidth(), compose.getHeight(), compose.getIngredients(), getOutputBook(compose, outputBook)); } static ItemStack getOutputBook(Recipe compose, ResourceLocation outputBook) { diff --git a/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapelessBookRecipe.java b/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapelessBookRecipe.java index 89041e824..0ce583d3a 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapelessBookRecipe.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/recipe/ShapelessBookRecipe.java @@ -1,6 +1,7 @@ package vazkii.patchouli.common.recipe; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.ShapelessRecipe; @@ -13,7 +14,7 @@ public class ShapelessBookRecipe extends ShapelessRecipe { public static final RecipeSerializer SERIALIZER = new BookRecipeSerializer<>(RecipeSerializer.SHAPELESS_RECIPE, ShapelessBookRecipe::new); public ShapelessBookRecipe(ShapelessRecipe compose, ResourceLocation outputBook) { - super(compose.getId(), compose.getGroup(), ShapedBookRecipe.getOutputBook(compose, outputBook), compose.getIngredients()); + super(compose.getId(), compose.getGroup(), CraftingBookCategory.MISC, ShapedBookRecipe.getOutputBook(compose, outputBook), compose.getIngredients()); } @Override 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 dfcbb2086..4fb199e5c 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/util/EntityUtil.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/util/EntityUtil.java @@ -1,17 +1,14 @@ package vazkii.patchouli.common.util; import com.mojang.brigadier.exceptions.CommandSyntaxException; - -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.TagParser; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; - import org.apache.commons.lang3.tuple.Pair; - import vazkii.patchouli.api.PatchouliAPI; import java.util.Optional; @@ -23,7 +20,7 @@ private EntityUtil() {} public static String getEntityName(String entityId) { Pair nameAndNbt = splitNameAndNBT(entityId); - EntityType type = Registry.ENTITY_TYPE.get(new ResourceLocation(nameAndNbt.getLeft())); + EntityType type = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(nameAndNbt.getLeft())); return type.getDescriptionId(); } @@ -43,7 +40,7 @@ public static Function loadEntity(String entityId) { } ResourceLocation key = new ResourceLocation(entityId); - Optional> maybeType = Registry.ENTITY_TYPE.getOptional(key); + 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 e7e245029..40803ef0d 100644 --- a/Xplat/src/main/java/vazkii/patchouli/common/util/ItemStackUtil.java +++ b/Xplat/src/main/java/vazkii/patchouli/common/util/ItemStackUtil.java @@ -7,8 +7,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.serialization.Dynamic; import com.mojang.serialization.JsonOps; - -import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.TagParser; @@ -18,21 +18,14 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; - import org.apache.commons.lang3.tuple.ImmutableTriple; import org.apache.commons.lang3.tuple.Triple; - +import org.jetbrains.annotations.Nullable; import vazkii.patchouli.common.book.Book; import vazkii.patchouli.common.book.BookRegistry; import vazkii.patchouli.common.item.ItemModBook; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; -import java.util.StringJoiner; +import java.util.*; public final class ItemStackUtil { private static final Gson GSON = new GsonBuilder().create(); @@ -41,7 +34,7 @@ private ItemStackUtil() {} public static String serializeStack(ItemStack stack) { StringBuilder builder = new StringBuilder(); - builder.append(Registry.ITEM.getKey(stack.getItem())); + builder.append(BuiltInRegistries.ITEM.getKey(stack.getItem())); int count = stack.getCount(); if (count > 1) { @@ -97,7 +90,7 @@ public static ItemStack loadFromParsed(Triple maybeItem = Registry.ITEM.getOptional(key); + Optional maybeItem = BuiltInRegistries.ITEM.getOptional(key); if (maybeItem.isEmpty()) { throw new RuntimeException("Unknown item ID: " + key); } @@ -141,8 +134,8 @@ public static List loadStackListFromString(String ingredientString) { List stacks = new ArrayList<>(); for (String s : stacksSerialized) { if (s.startsWith("tag:")) { - var key = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(s.substring(4))); - Registry.ITEM.getTag(key).ifPresent(tag -> tag.stream().forEach(item -> stacks.add(new ItemStack(item)))); + var key = TagKey.create(Registries.ITEM, new ResourceLocation(s.substring(4))); + BuiltInRegistries.ITEM.getTag(key).ifPresent(tag -> tag.stream().forEach(item -> stacks.add(new ItemStack(item)))); } else { stacks.add(loadStackFromString(s)); } @@ -162,7 +155,7 @@ public static Book getBookFromStack(ItemStack stack) { Collection books = BookRegistry.INSTANCE.books.values(); for (Book b : books) { - if (b.getBookItem().sameItemStackIgnoreDurability(stack)) { + if (b.getBookItem().sameItem(stack)) { return b; } } @@ -182,7 +175,7 @@ public StackWrapper(ItemStack stack) { @Override public boolean equals(Object obj) { - return obj == this || (obj instanceof StackWrapper && ItemStack.isSameIgnoreDurability(stack, ((StackWrapper) obj).stack)); + return obj == this || (obj instanceof StackWrapper && ItemStack.isSame(stack, ((StackWrapper) obj).stack)); } @Override @@ -239,7 +232,7 @@ public static ItemStack loadStackFromJson(JsonObject json) { // Adapted from net.minecraftforge.common.crafting.CraftingHelper::getItemStack String itemName = json.get("item").getAsString(); - Item item = Registry.ITEM.getOptional(new ResourceLocation(itemName)).orElseThrow(() -> new IllegalArgumentException("Unknown item '" + itemName + "'") + Item item = BuiltInRegistries.ITEM.getOptional(new ResourceLocation(itemName)).orElseThrow(() -> new IllegalArgumentException("Unknown item '" + itemName + "'") ); ItemStack stack = new ItemStack(item, GsonHelper.getAsInt(json, "count", 1)); diff --git a/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorScreen.java b/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorScreen.java index b3708c26a..d0187573e 100644 --- a/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorScreen.java +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/AccessorScreen.java @@ -1,9 +1,8 @@ package vazkii.patchouli.mixin.client; -import net.minecraft.client.gui.components.Widget; +import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.narration.NarratableEntry; import net.minecraft.client.gui.screens.Screen; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -13,7 +12,7 @@ public interface AccessorScreen { @Accessor("renderables") - List getRenderables(); + List getRenderables(); @Accessor("narratables") List getNarratables(); 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 cf33e4c75..0cb6fc65a 100644 --- a/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinInventoryScreen.java +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinInventoryScreen.java @@ -2,7 +2,7 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.ImageButton; -import net.minecraft.client.gui.components.Widget; +import net.minecraft.client.gui.components.Renderable; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.screens.inventory.EffectRenderingInventoryScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen; @@ -10,12 +10,10 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.InventoryMenu; - import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import vazkii.patchouli.client.gui.GuiButtonInventoryBook; import vazkii.patchouli.common.base.PatchouliConfig; import vazkii.patchouli.common.book.Book; @@ -37,13 +35,13 @@ public void onGuiInitPost(CallbackInfo info) { return; } - Widget replaced = null; + Renderable replaced = null; Button replacement = null; for (int i = 0; i < ((AccessorScreen) this).getRenderables().size(); i++) { - Widget button = ((AccessorScreen) this).getRenderables().get(i); + Renderable button = ((AccessorScreen) this).getRenderables().get(i); if (button instanceof ImageButton tex) { replaced = button; - replacement = new GuiButtonInventoryBook(book, tex.x, tex.y - 1); + replacement = new GuiButtonInventoryBook(book, tex.getX(), tex.getY() - 1); ((AccessorScreen) this).getRenderables().set(i, replacement); break; } 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 71e45aa51..8f5a09301 100644 --- a/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinLevelRenderer.java +++ b/Xplat/src/main/java/vazkii/patchouli/mixin/client/MixinLevelRenderer.java @@ -1,18 +1,15 @@ package vazkii.patchouli.mixin.client; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; - import net.minecraft.client.Camera; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.LevelRenderer; import net.minecraft.client.renderer.LightTexture; - +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - import vazkii.patchouli.client.handler.MultiblockVisualizationHandler; @Mixin(LevelRenderer.class) diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_blue.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_blue.json index 33642d84d..f01d6fc03 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_blue.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_blue.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_blue" + "textures": { + "layer0": "patchouli:item/book_blue" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_brown.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_brown.json index 66f7a778a..c1c29e7da 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_brown.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_brown.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_brown" + "textures": { + "layer0": "patchouli:item/book_brown" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_cyan.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_cyan.json index ce9420a20..1b635e64b 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_cyan.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_cyan.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_cyan" + "textures": { + "layer0": "patchouli:item/book_cyan" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_gray.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_gray.json index 1c2e96325..db2c984ba 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_gray.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_gray.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_gray" + "textures": { + "layer0": "patchouli:item/book_gray" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_green.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_green.json index a1f46e46b..53009fe4e 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_green.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_green.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_green" + "textures": { + "layer0": "patchouli:item/book_green" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_purple.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_purple.json index 586a4d593..7fe01293d 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_purple.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_purple.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_purple" + "textures": { + "layer0": "patchouli:item/book_purple" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/book_red.json b/Xplat/src/main/resources/assets/patchouli/models/item/book_red.json index c6ac8971b..1bae29cae 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/book_red.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/book_red.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_red" + "textures": { + "layer0": "patchouli:item/book_red" } } diff --git a/Xplat/src/main/resources/assets/patchouli/models/item/guide_book.json b/Xplat/src/main/resources/assets/patchouli/models/item/guide_book.json index 66f7a778a..c1c29e7da 100644 --- a/Xplat/src/main/resources/assets/patchouli/models/item/guide_book.json +++ b/Xplat/src/main/resources/assets/patchouli/models/item/guide_book.json @@ -1,6 +1,6 @@ { "parent": "item/generated", - "textures": { - "layer0": "patchouli:items/book_brown" + "textures": { + "layer0": "patchouli:item/book_brown" } } diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_blue.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_blue.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_blue.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_blue.png diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_brown.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_brown.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_brown.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_brown.png diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_cyan.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_cyan.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_cyan.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_cyan.png diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_gray.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_gray.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_gray.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_gray.png diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_green.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_green.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_green.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_green.png diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_purple.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_purple.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_purple.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_purple.png diff --git a/Xplat/src/main/resources/assets/patchouli/textures/items/book_red.png b/Xplat/src/main/resources/assets/patchouli/textures/item/book_red.png similarity index 100% rename from Xplat/src/main/resources/assets/patchouli/textures/items/book_red.png rename to Xplat/src/main/resources/assets/patchouli/textures/item/book_red.png 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 c6de98eea..63d5680b8 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": "tools", + "creative_tab": "tools_and_utilities", "use_resource_pack": true, "text_overflow_mode": "resize", "pause_game": true diff --git a/Xplat/src/main/resources/data/patchouli/patchouli_books/intro/book.json b/Xplat/src/main/resources/data/patchouli/patchouli_books/intro/book.json index ea68e2602..4cac6e433 100644 --- a/Xplat/src/main/resources/data/patchouli/patchouli_books/intro/book.json +++ b/Xplat/src/main/resources/data/patchouli/patchouli_books/intro/book.json @@ -2,6 +2,6 @@ "name": "item.patchouli:intro_book.name", "landing_text": "item.patchouli:intro_book.landing", "subtitle": "item.patchouli:intro_book.subtitle", - "creative_tab": "decorations", + "creative_tab": "natural_blocks", "advancements_tab": "patchouli" } diff --git a/Xplat/src/main/resources/data/patchouli/patchouli_books/pamphlet/book.json b/Xplat/src/main/resources/data/patchouli/patchouli_books/pamphlet/book.json index a596ef3b8..31569d9ce 100644 --- a/Xplat/src/main/resources/data/patchouli/patchouli_books/pamphlet/book.json +++ b/Xplat/src/main/resources/data/patchouli/patchouli_books/pamphlet/book.json @@ -1,7 +1,7 @@ { "name": "item.patchouli:pamphlet.name", "landing_text": "item.patchouli:pamphlet.landing", - "creative_tab": "decorations", + "creative_tab": "natural_blocks", "advancements_tab": "patchouli", "pamphlet": true } diff --git a/Xplat/src/main/resources/data/patchouli/patchouli_books/testbook2/book.json b/Xplat/src/main/resources/data/patchouli/patchouli_books/testbook2/book.json index f2bb12db0..b618b505c 100644 --- a/Xplat/src/main/resources/data/patchouli/patchouli_books/testbook2/book.json +++ b/Xplat/src/main/resources/data/patchouli/patchouli_books/testbook2/book.json @@ -11,7 +11,7 @@ "$(potato)": "(POTATO MACRO)" }, "model": "patchouli:book_green", - "creative_tab": "decorations", + "creative_tab": "natural_blocks", "advancements_tab": "patchouli", "i18n": true } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9bfc9078e..64e477acf 100644 --- a/build.gradle +++ b/build.gradle @@ -8,9 +8,6 @@ buildscript { classpath "com.diffplug.spotless:spotless-plugin-gradle:5.12.5" } } -/* TODO someone please fix this I hate gradle so much - I fixed it - Jared -*/ subprojects { apply plugin: 'java' diff --git a/gradle.properties b/gradle.properties index 8b498eca2..0fe67c066 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 -minecraft_version=1.19.2 +minecraft_version=1.19.3 build_number=78 group=vazkii.patchouli mod_name=Patchouli