From f9f8c3aa30975671c6dcdc5d9585bba3f4b22aaa Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Mon, 25 Nov 2024 20:31:58 +0100 Subject: [PATCH] feat: Update Forge to 1.21.3 --- .../mods/balm/forge/ForgeBalmHooks.java | 6 ++-- .../mods/balm/forge/ForgeBalmRuntime.java | 18 +++++------ .../mods/balm/forge/ForgeLoadContext.java | 7 +++++ .../balm/forge/block/ForgeBalmBlocks.java | 28 +++++++---------- .../block/entity/ForgeBalmBlockEntities.java | 5 ++-- .../forge/client/ForgeBalmClientRuntime.java | 8 ++--- .../client/rendering/ForgeBalmModels.java | 30 +++++++++++-------- .../balm/forge/entity/ForgeBalmEntities.java | 6 ++-- .../forge/event/ForgeBalmClientEvents.java | 8 ----- .../mods/balm/forge/item/ForgeBalmItems.java | 16 ++++------ .../balm/forge/recipe/ForgeBalmRecipes.java | 25 ++++++++++++++++ .../balm/forge/world/ForgeBalmWorldGen.java | 13 ++++++-- gradle.properties | 4 +-- settings.gradle | 2 +- 14 files changed, 102 insertions(+), 74 deletions(-) create mode 100644 forge/src/main/java/net/blay09/mods/balm/forge/ForgeLoadContext.java diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmHooks.java b/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmHooks.java index 743777d9..f7104bed 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmHooks.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmHooks.java @@ -100,7 +100,7 @@ public boolean isFakePlayer(Player player) { @Override public ItemStack getCraftingRemainingItem(ItemStack itemStack) { - return itemStack.getCraftingRemainingItem(); + return itemStack.getCraftingRemainder(); } @Override @@ -114,8 +114,8 @@ public boolean canItemsStack(ItemStack first, ItemStack second) { } @Override - public int getBurnTime(ItemStack itemStack) { - return ForgeHooks.getBurnTime(itemStack, RecipeType.SMELTING); + public int getBurnTime(Level level, ItemStack itemStack) { + return level.fuelValues().burnDuration(itemStack); } @Override diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmRuntime.java b/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmRuntime.java index 06496b1c..d65325ba 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmRuntime.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/ForgeBalmRuntime.java @@ -3,7 +3,6 @@ import net.blay09.mods.balm.api.BalmHooks; import net.blay09.mods.balm.api.BalmRegistries; import net.blay09.mods.balm.api.BalmRuntime; -import net.blay09.mods.balm.api.EmptyLoadContext; import net.blay09.mods.balm.api.block.BalmBlockEntities; import net.blay09.mods.balm.api.block.BalmBlocks; import net.blay09.mods.balm.api.command.BalmCommands; @@ -39,22 +38,22 @@ import net.blay09.mods.balm.forge.sound.ForgeBalmSounds; import net.blay09.mods.balm.forge.stats.ForgeBalmStats; import net.blay09.mods.balm.forge.world.ForgeBalmWorldGen; +import net.minecraft.core.HolderLookup; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.packs.resources.*; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.AddReloadListenerEvent; -import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; +import java.util.function.Function; -public class ForgeBalmRuntime implements BalmRuntime { +public class ForgeBalmRuntime implements BalmRuntime { private final BalmWorldGen worldGen = new ForgeBalmWorldGen(); private final BalmBlocks blocks = new ForgeBalmBlocks(); private final BalmBlockEntities blockEntities = new ForgeBalmBlockEntities(); @@ -176,7 +175,7 @@ public String getModName(String modId) { } @Override - public void initialize(String modId, EmptyLoadContext context, Runnable initializer) { + public void initialize(String modId, ForgeLoadContext context, Runnable initializer) { ((ForgeBalmItems) items).register(); ((ForgeBalmEntities) entities).register(); ((ForgeBalmWorldGen) worldGen).register(); @@ -184,9 +183,8 @@ public void initialize(String modId, EmptyLoadContext context, Runnable initiali initializer.run(); - IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); - modEventBus.addListener((FMLLoadCompleteEvent event) -> initializeAddons()); - DeferredRegisters.register(modId, modEventBus); + context.modBus().addListener((FMLLoadCompleteEvent event) -> initializeAddons()); + DeferredRegisters.register(modId, context.modBus()); } @Override @@ -224,8 +222,8 @@ private void initializeAddons() { } @Override - public void addServerReloadListener(ResourceLocation identifier, PreparableReloadListener reloadListener) { - MinecraftForge.EVENT_BUS.addListener((AddReloadListenerEvent event) -> event.addListener(reloadListener)); + public void addServerReloadListener(ResourceLocation identifier, Function reloadListener) { + MinecraftForge.EVENT_BUS.addListener((AddReloadListenerEvent event) -> event.addListener(reloadListener.apply(event.getRegistryAccess()))); } @Override diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/ForgeLoadContext.java b/forge/src/main/java/net/blay09/mods/balm/forge/ForgeLoadContext.java new file mode 100644 index 00000000..d7aba02e --- /dev/null +++ b/forge/src/main/java/net/blay09/mods/balm/forge/ForgeLoadContext.java @@ -0,0 +1,7 @@ +package net.blay09.mods.balm.forge; + +import net.blay09.mods.balm.api.BalmRuntimeLoadContext; +import net.minecraftforge.eventbus.api.IEventBus; + +public record ForgeLoadContext(IEventBus modBus) implements BalmRuntimeLoadContext { +} \ No newline at end of file diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/block/ForgeBalmBlocks.java b/forge/src/main/java/net/blay09/mods/balm/forge/block/ForgeBalmBlocks.java index 4c8699d4..0a5a05ed 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/block/ForgeBalmBlocks.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/block/ForgeBalmBlocks.java @@ -4,39 +4,33 @@ import net.blay09.mods.balm.forge.DeferredRegisters; import net.blay09.mods.balm.api.DeferredObject; import net.blay09.mods.balm.api.block.BalmBlocks; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockBehaviour; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.ForgeRegistries; -import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.Nullable; -import java.util.function.Supplier; +import java.util.function.BiFunction; +import java.util.function.Function; public class ForgeBalmBlocks implements BalmBlocks { - @Override - public BlockBehaviour.Properties blockProperties() { - return BlockBehaviour.Properties.of(); - } @Override - public DeferredObject registerBlock(Supplier supplier, ResourceLocation identifier) { - DeferredRegister register = DeferredRegisters.get(ForgeRegistries.BLOCKS, identifier.getNamespace()); - RegistryObject registryObject = register.register(identifier.getPath(), supplier); + public DeferredObject registerBlock(Function supplier, ResourceLocation identifier) { + final var register = DeferredRegisters.get(Registries.BLOCK, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), () -> supplier.apply(identifier)); return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); } @Override - public DeferredObject registerBlockItem(Supplier supplier, ResourceLocation identifier, @Nullable ResourceLocation creativeTab) { - return Balm.getItems().registerItem(supplier::get, identifier, creativeTab); + public DeferredObject registerBlockItem(Function supplier, ResourceLocation identifier, @Nullable ResourceLocation creativeTab) { + return Balm.getItems().registerItem(supplier::apply, identifier, creativeTab); } @Override - public void register(Supplier blockSupplier, Supplier blockItemSupplier, ResourceLocation identifier, @Nullable ResourceLocation creativeTab) { - registerBlock(blockSupplier, identifier); - registerBlockItem(blockItemSupplier, identifier, creativeTab); + public void register(Function blockSupplier, BiFunction blockItemSupplier, ResourceLocation identifier, @Nullable ResourceLocation creativeTab) { + final var deferredBlock = registerBlock(blockSupplier, identifier); + registerBlockItem((id) -> blockItemSupplier.apply(deferredBlock.get(), id), identifier, creativeTab); } } diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/block/entity/ForgeBalmBlockEntities.java b/forge/src/main/java/net/blay09/mods/balm/forge/block/entity/ForgeBalmBlockEntities.java index e06a6aca..8018fc65 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/block/entity/ForgeBalmBlockEntities.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/block/entity/ForgeBalmBlockEntities.java @@ -13,6 +13,7 @@ import net.minecraftforge.registries.RegistryObject; import java.util.Arrays; +import java.util.Set; import java.util.function.Supplier; public class ForgeBalmBlockEntities implements BalmBlockEntities { @@ -21,7 +22,7 @@ public DeferredObject> registerBlockE DeferredRegister> register = DeferredRegisters.get(ForgeRegistries.BLOCK_ENTITY_TYPES, identifier.getNamespace()); RegistryObject> registryObject = register.register(identifier.getPath(), () -> { Block[] resolvedBlocks = blocks.get(); - return BlockEntityType.Builder.of(factory::create, resolvedBlocks).build(null); + return new BlockEntityType<>(factory::create, Set.of(resolvedBlocks)); }); return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); } @@ -31,7 +32,7 @@ public DeferredObject> registerBlockE DeferredRegister> register = DeferredRegisters.get(ForgeRegistries.BLOCK_ENTITY_TYPES, identifier.getNamespace()); RegistryObject> registryObject = register.register(identifier.getPath(), () -> { Block[] resolvedBlocks = Arrays.stream(blocks).map(DeferredObject::get).toArray(Block[]::new); - return BlockEntityType.Builder.of(factory::create, resolvedBlocks).build(null); + return new BlockEntityType<>(factory::create, Set.of(resolvedBlocks)); }); return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); } diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/client/ForgeBalmClientRuntime.java b/forge/src/main/java/net/blay09/mods/balm/forge/client/ForgeBalmClientRuntime.java index 3c4f6acd..63045d44 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/client/ForgeBalmClientRuntime.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/client/ForgeBalmClientRuntime.java @@ -1,13 +1,13 @@ package net.blay09.mods.balm.forge.client; import net.blay09.mods.balm.api.Balm; -import net.blay09.mods.balm.api.EmptyLoadContext; import net.blay09.mods.balm.api.client.BalmClientRuntime; import net.blay09.mods.balm.api.client.keymappings.BalmKeyMappings; import net.blay09.mods.balm.api.client.rendering.BalmModels; import net.blay09.mods.balm.api.client.rendering.BalmRenderers; import net.blay09.mods.balm.api.client.rendering.BalmTextures; import net.blay09.mods.balm.api.client.screen.BalmScreens; +import net.blay09.mods.balm.forge.ForgeLoadContext; import net.blay09.mods.balm.forge.event.ForgeBalmEvents; import net.blay09.mods.balm.forge.client.keymappings.ForgeBalmKeyMappings; import net.blay09.mods.balm.forge.client.rendering.ForgeBalmModels; @@ -16,7 +16,7 @@ import net.blay09.mods.balm.forge.client.screen.ForgeBalmScreens; import net.blay09.mods.balm.forge.event.ForgeBalmClientEvents; -public class ForgeBalmClientRuntime implements BalmClientRuntime { +public class ForgeBalmClientRuntime implements BalmClientRuntime { private final BalmRenderers renderers = new ForgeBalmRenderers(); private final BalmTextures textures = new ForgeBalmTextures(); @@ -54,10 +54,10 @@ public BalmKeyMappings getKeyMappings() { } @Override - public void initialize(String modId, EmptyLoadContext context, Runnable initializer) { + public void initialize(String modId, ForgeLoadContext context, Runnable initializer) { ((ForgeBalmRenderers) renderers).register(); ((ForgeBalmScreens) screens).register(); - ((ForgeBalmModels) models).register(); + ((ForgeBalmModels) models).register(modId, context.modBus()); ((ForgeBalmKeyMappings) keyMappings).register(); initializer.run(); diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/client/rendering/ForgeBalmModels.java b/forge/src/main/java/net/blay09/mods/balm/forge/client/rendering/ForgeBalmModels.java index 928e44d8..07163ae1 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/client/rendering/ForgeBalmModels.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/client/rendering/ForgeBalmModels.java @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.client.model.SimpleModelState; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; @@ -46,7 +47,7 @@ public void resolveAndSet(ModelBakery modelBakery, Map event.register(it.getModelResourceLocation())); - } + // TODO @SubscribeEvent + // TODO public void onRegisterAdditionalModels(ModelEvent.RegisterAdditional event) { + // TODO additionalModels.forEach(it -> event.register(it.getModelResourceLocation())); + // TODO } @SubscribeEvent public void onModelBakingCompleted(ModelEvent.ModifyBakingResult event) { @@ -96,6 +97,7 @@ public void onModelBakingCompleted(ModelEvent.BakingCompleted event) { } } + private final Map registrations = new ConcurrentHashMap<>(); private ModelBakery modelBakery; @@ -158,7 +160,7 @@ public DeferredObject loadDynamicModel(ModelResourceLocation identif public BakedModel resolve(ModelBakery bakery, Map modelRegistry, ModelBakery.TextureGetter textureGetter) { final var unbakedModels = new HashMap(); for (final var modelId : models) { - unbakedModels.put(modelId, ((ModelBakeryAccessor) bakery).callGetModel(modelId.id())); + unbakedModels.put(modelId, getUnbakedModelOrMissing(modelId.id())); } return new ForgeCachedDynamicModel(bakery, unbakedModels, @@ -187,20 +189,24 @@ public ModelState getModelState(Transformation transformation) { @Override public UnbakedModel getUnbakedModelOrMissing(ResourceLocation location) { - return ((ModelBakeryAccessor) modelBakery).callGetModel(location); + return ((ModelBakeryAccessor) modelBakery).getUnbakedModels().getOrDefault(location, ((ModelBakeryAccessor) modelBakery).getMissingModel()); } @Override public UnbakedModel getUnbakedMissingModel() { - return ((ModelBakeryAccessor) modelBakery).callGetModel(ModelBakery.MISSING_MODEL_LOCATION); + return ((ModelBakeryAccessor) modelBakery).getMissingModel(); } - public void register() { - FMLJavaModLoadingContext.get().getModEventBus().register(getActiveRegistrations()); + public void register(String modId, IEventBus eventBus) { + eventBus.register(getRegistrations(modId)); } private Registrations getActiveRegistrations() { - return registrations.computeIfAbsent(ModLoadingContext.get().getActiveNamespace(), it -> new Registrations()); + return getRegistrations(ModLoadingContext.get().getActiveNamespace()); + } + + private Registrations getRegistrations(String modId) { + return registrations.computeIfAbsent(modId, it -> new Registrations()); } @Override @@ -214,4 +220,4 @@ public ModelBaker createBaker(ModelResourceLocation location, ModelBakery.Textur throw new RuntimeException("Balm failed to create model baker", e); } } -} +} \ No newline at end of file diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/entity/ForgeBalmEntities.java b/forge/src/main/java/net/blay09/mods/balm/forge/entity/ForgeBalmEntities.java index 0da041f7..ad9ad37e 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/entity/ForgeBalmEntities.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/entity/ForgeBalmEntities.java @@ -3,6 +3,8 @@ import net.blay09.mods.balm.api.DeferredObject; import net.blay09.mods.balm.api.entity.BalmEntities; import net.blay09.mods.balm.forge.DeferredRegisters; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -40,7 +42,7 @@ public void registerAttributes(EntityAttributeCreationEvent event) { @Override public DeferredObject> registerEntity(ResourceLocation identifier, EntityType.Builder typeBuilder) { DeferredRegister> register = DeferredRegisters.get(ForgeRegistries.ENTITY_TYPES, identifier.getNamespace()); - RegistryObject> registryObject = register.register(identifier.getPath(), () -> typeBuilder.build(identifier.toString())); + RegistryObject> registryObject = register.register(identifier.getPath(), () -> typeBuilder.build(ResourceKey.create(Registries.ENTITY_TYPE, identifier))); return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); } @@ -49,7 +51,7 @@ public DeferredObject> registerEntity(Res final DeferredRegister> register = DeferredRegisters.get(ForgeRegistries.ENTITY_TYPES, identifier.getNamespace()); final Registrations registrations = getActiveRegistrations(); final RegistryObject> registryObject = register.register(identifier.getPath(), () -> { - EntityType entityType = typeBuilder.build(identifier.toString()); + EntityType entityType = typeBuilder.build(ResourceKey.create(Registries.ENTITY_TYPE, identifier)); registrations.attributeSuppliers.put(entityType, attributeBuilder.get().build()); return entityType; }); diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/event/ForgeBalmClientEvents.java b/forge/src/main/java/net/blay09/mods/balm/forge/event/ForgeBalmClientEvents.java index c9451212..877182be 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/event/ForgeBalmClientEvents.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/event/ForgeBalmClientEvents.java @@ -273,14 +273,6 @@ public static void registerEvents(ForgeBalmEvents events) { }); }); - events.registerEvent(RecipesUpdatedEvent.class, priority -> { - MinecraftForge.EVENT_BUS.addListener(ForgeBalmEvents.toForge(priority), (net.minecraftforge.client.event.RecipesUpdatedEvent orig) -> { - RegistryAccess registryAccess = Minecraft.getInstance().level.registryAccess(); // same way that Minecraft does it in the packet handler - final RecipesUpdatedEvent event = new RecipesUpdatedEvent(orig.getRecipeManager(), registryAccess); - events.fireEventHandlers(priority, event); - }); - }); - events.registerEvent(ItemTooltipEvent.class, priority -> { MinecraftForge.EVENT_BUS.addListener(ForgeBalmEvents.toForge(priority), (net.minecraftforge.event.entity.player.ItemTooltipEvent orig) -> { final ItemTooltipEvent event = new ItemTooltipEvent(orig.getItemStack(), orig.getEntity(), orig.getToolTip(), orig.getFlags()); diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/item/ForgeBalmItems.java b/forge/src/main/java/net/blay09/mods/balm/forge/item/ForgeBalmItems.java index dc6f260a..41f356d0 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/item/ForgeBalmItems.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/item/ForgeBalmItems.java @@ -22,6 +22,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; import java.util.function.Supplier; public class ForgeBalmItems implements BalmItems { @@ -48,14 +49,9 @@ public void buildCreativeTabContents(ResourceLocation tabIdentifier, CreativeMod private final Map registrations = new ConcurrentHashMap<>(); @Override - public Item.Properties itemProperties() { - return new Item.Properties(); - } - - @Override - public DeferredObject registerItem(Supplier supplier, ResourceLocation identifier, @Nullable ResourceLocation creativeTab) { - DeferredRegister register = DeferredRegisters.get(ForgeRegistries.ITEMS, identifier.getNamespace()); - RegistryObject registryObject = register.register(identifier.getPath(), supplier); + public DeferredObject registerItem(Function supplier, ResourceLocation identifier, @Nullable ResourceLocation creativeTab) { + final var register = DeferredRegisters.get(Registries.ITEM, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), () -> supplier.apply(identifier)); if (creativeTab != null) { getActiveRegistrations().creativeTabContents.put(creativeTab, () -> new ItemLike[]{registryObject.get()}); } @@ -64,8 +60,8 @@ public DeferredObject registerItem(Supplier supplier, ResourceLocati @Override public DeferredObject registerCreativeModeTab(Supplier iconSupplier, ResourceLocation identifier) { - DeferredRegister register = DeferredRegisters.get(Registries.CREATIVE_MODE_TAB, identifier.getNamespace()); - RegistryObject registryObject = register.register(identifier.getPath(), () -> { + final var register = DeferredRegisters.get(Registries.CREATIVE_MODE_TAB, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), () -> { Component displayName = Component.translatable("itemGroup." + identifier.toString().replace(':', '.')); final var registrations = getActiveRegistrations(); return CreativeModeTab.builder() diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java b/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java index 964a7dea..010be1a9 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/recipe/ForgeBalmRecipes.java @@ -3,10 +3,14 @@ import net.blay09.mods.balm.api.DeferredObject; import net.blay09.mods.balm.api.recipe.BalmRecipes; import net.blay09.mods.balm.forge.DeferredRegisters; +import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.crafting.RecipeBookCategory; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.item.crafting.display.RecipeDisplay; +import net.minecraft.world.item.crafting.display.SlotDisplay; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; @@ -25,4 +29,25 @@ public > DeferredObject> registerRecipeType(Su return new DeferredObject<>(identifier, typeObject, () -> typeObject.isPresent() && serializerObject.isPresent()); } + @Override + public > DeferredObject registerRecipeDisplayType(Supplier supplier, ResourceLocation identifier) { + final var register = DeferredRegisters.get(Registries.RECIPE_DISPLAY, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), supplier); + return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); + } + + @Override + public > DeferredObject registerSlotDisplayType(Supplier supplier, ResourceLocation identifier) { + final var register = DeferredRegisters.get(Registries.SLOT_DISPLAY, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), supplier); + return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); + } + + @Override + public DeferredObject registerRecipeBookCategory(Supplier supplier, ResourceLocation identifier) { + final var register = DeferredRegisters.get(Registries.RECIPE_BOOK_CATEGORY, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), supplier); + return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); + } + } diff --git a/forge/src/main/java/net/blay09/mods/balm/forge/world/ForgeBalmWorldGen.java b/forge/src/main/java/net/blay09/mods/balm/forge/world/ForgeBalmWorldGen.java index e50ebfb5..2b006263 100644 --- a/forge/src/main/java/net/blay09/mods/balm/forge/world/ForgeBalmWorldGen.java +++ b/forge/src/main/java/net/blay09/mods/balm/forge/world/ForgeBalmWorldGen.java @@ -1,6 +1,5 @@ package net.blay09.mods.balm.forge.world; -import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import net.blay09.mods.balm.api.DeferredObject; import net.blay09.mods.balm.api.world.BalmWorldGen; @@ -12,6 +11,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.ai.village.poi.PoiType; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.feature.Feature; @@ -77,6 +77,13 @@ public > DeferredObject registerPlacementM return deferredObject; } + @Override + public DeferredObject registerPoiType(ResourceLocation identifier, Supplier supplier) { + final var register = DeferredRegisters.get(Registries.POINT_OF_INTEREST_TYPE, identifier.getNamespace()); + final var registryObject = register.register(identifier.getPath(), supplier); + return new DeferredObject<>(identifier, registryObject, registryObject::isPresent); + } + private static final List biomeModifications = new ArrayList<>(); @Override @@ -92,8 +99,8 @@ public void modifyBiome(Holder biome, BiomeModifier.Phase phase, Modifiab if (location != null && biomeModification.getBiomePredicate().test(location, biome)) { Registry placedFeatures = ServerLifecycleHooks.getCurrentServer() .registryAccess() - .registryOrThrow(Registries.PLACED_FEATURE); - placedFeatures.getHolder(biomeModification.getConfiguredFeatureKey()) + .lookupOrThrow(Registries.PLACED_FEATURE); + placedFeatures.get(biomeModification.getConfiguredFeatureKey()) .ifPresent(placedFeature -> builder.getGenerationSettings().addFeature(biomeModification.getStep(), placedFeature)); } } diff --git a/gradle.properties b/gradle.properties index 7f403dd7..74631c43 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,7 +32,7 @@ parchment_minecraft=1.21 parchment_version=2024.07.28 # Forge -forge_version = 52.0.18 +forge_version = 53.0.25 forge_version_range = [51,) forge_loader_version_range = [51,) @@ -47,7 +47,7 @@ fabric_version = 0.106.1+1.21.3 fabric_loader_version = 0.16.7 # Dependencies -kuma_version = 21.3.1+1.21.3 +kuma_version = 21.3.3+1.21.3 kuma_version_range = [21.2,21.4) jei_minecraft_version = 1.19.2 jei_version = 11.4.0.288 diff --git a/settings.gradle b/settings.gradle index d9e93c35..bce959e8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -46,4 +46,4 @@ plugins { include("common") include("fabric") include("neoforge") -// include("forge") +include("forge")