diff --git a/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java b/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java index b65eabb1b..b9a979070 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java +++ b/common/src/main/java/com/unlikepaladin/pfm/client/screens/MicrowaveScreen.java @@ -88,7 +88,7 @@ protected void handledScreenTick() { this.isActive = handler.isActive; DefaultedList inventory = DefaultedList.ofSize(1,handler.getInventory().getStack(0)); Optional> recipe = getRecipe(handler.microwaveBlockEntity.getWorld(), handler.getInventory()); - if(recipe.isPresent() && microwaveBlockEntity.getWorld() != null && !MicrowaveBlockEntity.canAcceptRecipeOutput(microwaveBlockEntity.getWorld().getRegistryManager(), recipe.get() != null ? recipe.get().value() : null, inventory ,microwaveBlockEntity.getMaxCountPerStack()) && !this.handler.isActive()) { + if(recipe.isEmpty() || !MicrowaveBlockEntity.canAcceptRecipeOutput(microwaveBlockEntity.getWorld().getRegistryManager(), recipe.>map(RecipeEntry::value).orElse(null), inventory, microwaveBlockEntity.getMaxCountPerStack()) && !this.handler.isActive()) { this.startButton.active = false; } else { diff --git a/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java b/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java index c36f028c8..c8c222e16 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java +++ b/common/src/main/java/com/unlikepaladin/pfm/menus/AbstractMicrowaveScreenHandler.java @@ -18,6 +18,8 @@ import net.minecraft.screen.slot.Slot; import net.minecraft.world.World; +import java.util.Optional; + public abstract class AbstractMicrowaveScreenHandler extends AbstractRecipeScreenHandler { private final Inventory inventory; private final PropertyDelegate propertyDelegate; @@ -173,8 +175,8 @@ protected boolean insertItemToSlot(ItemStack stack, int startIndex, int endIndex } protected boolean isCookable(ItemStack itemStack) { - RecipeEntry entry = this.world.getRecipeManager().getFirstMatch(this.recipeType, new SimpleInventory(itemStack), this.world).orElseGet(null); - return entry != null && entry.value() != null; + Optional> optionalRecipeEntry = this.world.getRecipeManager().getFirstMatch(this.recipeType, new SimpleInventory(itemStack), this.world); + return optionalRecipeEntry != null && optionalRecipeEntry.isPresent() && optionalRecipeEntry.get().value() != null; } public int getCookProgress() { diff --git a/common/src/main/resources/pfm.accesswidener b/common/src/main/resources/pfm.accesswidener index e8db06460..82154f44d 100644 --- a/common/src/main/resources/pfm.accesswidener +++ b/common/src/main/resources/pfm.accesswidener @@ -14,4 +14,6 @@ accessible field net/minecraft/resource/featuretoggle/FeatureSet universe Lnet/m accessible field net/minecraft/resource/featuretoggle/FeatureSet featuresMask J mutable field net/minecraft/resource/featuretoggle/FeatureFlag mask J accessible field net/minecraft/resource/featuretoggle/FeatureFlag mask J -accessible class net/minecraft/data/server/tag/TagProvider$ProvidedTagBuilder \ No newline at end of file +accessible class net/minecraft/data/server/tag/TagProvider$ProvidedTagBuilder +accessible field net/minecraft/world/poi/PointOfInterestType blockStates Ljava/util/Set; +mutable field net/minecraft/world/poi/PointOfInterestType blockStates Ljava/util/Set; \ No newline at end of file diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java b/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java index 9b07137b9..a2a9be844 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java @@ -133,13 +133,13 @@ public static void initializeItemGroup() { } public static void replaceHomePOI() { - Set addedBedStates = PaladinFurnitureModBlocksItems.beds.stream().flatMap(block -> block.getStateManager().getStates().stream().filter(state -> state.get(SimpleBedBlock.PART) == BedPart.HEAD)).collect(ImmutableSet.toImmutableSet()); + Set originalBedStates = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME).blockStates(); + Set addedBedStates = Arrays.stream(PaladinFurnitureModBlocksItems.getBeds()).flatMap(block -> block.getStateManager().getStates().stream().filter(state -> state.get(SimpleBedBlock.PART) == BedPart.HEAD)).collect(ImmutableSet.toImmutableSet()); Set newBedStates = new HashSet<>(); - newBedStates.addAll(PaladinFurnitureModBlocksItems.originalHomePOIBedStates); + newBedStates.addAll(originalBedStates); newBedStates.addAll(addedBedStates); - newBedStates = newBedStates.stream().collect(ImmutableSet.toImmutableSet()); - PointOfInterestType pointOfInterestType = new PointOfInterestType(newBedStates, 1, 1); - PointOfInterestTypes.HOME = ((SimpleRegistry)Registries.POINT_OF_INTEREST_TYPE).set(Registries.POINT_OF_INTEREST_TYPE.getRawId(Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME)), PointOfInterestTypes.HOME, pointOfInterestType, Lifecycle.stable()).getKey().get(); + PointOfInterestType homePOI = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME); + homePOI.blockStates = ImmutableSet.copyOf(newBedStates); } @Override public void onInitializeServer() { diff --git a/forge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/forge/LateBlockRegistryImpl.java b/forge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/forge/LateBlockRegistryImpl.java index c748716aa..760cfbdaf 100644 --- a/forge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/forge/LateBlockRegistryImpl.java +++ b/forge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/forge/LateBlockRegistryImpl.java @@ -16,6 +16,7 @@ import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.recipe.RecipeType; +import net.minecraft.registry.Registries; import net.minecraft.util.Pair; import net.minecraft.world.poi.PointOfInterestType; import net.minecraft.world.poi.PointOfInterestTypes; @@ -68,14 +69,13 @@ public static void registerBlocks(IForgeRegistry blockRegisterEvent) { } blocks.forEach(blockRegisterEvent::register); - Set originalBedStates = ForgeRegistries.POI_TYPES.getValue(PointOfInterestTypes.HOME.getValue()).blockStates(); + Set originalBedStates = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME).blockStates(); Set addedBedStates = Arrays.stream(PaladinFurnitureModBlocksItems.getBeds()).flatMap(block -> block.getStateManager().getStates().stream().filter(state -> state.get(SimpleBedBlock.PART) == BedPart.HEAD)).collect(ImmutableSet.toImmutableSet()); Set newBedStates = new HashSet<>(); newBedStates.addAll(originalBedStates); newBedStates.addAll(addedBedStates); - PointOfInterestType pointOfInterestType = new PointOfInterestType(newBedStates, 1, 1); - ForgeRegistries.POI_TYPES.register("minecraft:home", pointOfInterestType); - PointOfInterestTypes.HOME = ForgeRegistries.POI_TYPES.getHolder(pointOfInterestType).get().getKey().get(); + PointOfInterestType homePOI = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME); + homePOI.blockStates = ImmutableSet.copyOf(newBedStates); } public static void registerItems(IForgeRegistry itemIForgeRegistry) { diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 69e6fd344..13ebda183 100755 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -7,6 +7,10 @@ architectury { neoForge() } +loom { + accessWidenerPath = project(":common").loom.accessWidenerPath +} + configurations { common shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this. @@ -78,7 +82,7 @@ if (rootProject.immersive_portals_compatibility_forge == "true"){ if (rootProject.lazy_dfu_enabled == "true"){ dependencies { - modRuntimeOnly ("curse.maven:lazydfu-460819:${rootProject.lazy_dfu_version_forge}") + // modRuntimeOnly ("curse.maven:lazydfu-460819:${rootProject.lazy_dfu_version_forge}") } } @@ -112,7 +116,7 @@ sourceSets.main.resources { } remapJar { - atAccessWideners.add(project(":common").loom.accessWidenerPath.get().asFile.name) + atAccessWideners.add(loom.accessWidenerPath.get().asFile.name) input.set shadowJar.archiveFile dependsOn shadowJar archiveClassifier = "neoforge-mc${rootProject.minecraft_version}" diff --git a/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/forge/NeoForgeClassicTableModel.java b/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/neoforge/NeoForgeClassicTableModel.java similarity index 98% rename from neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/forge/NeoForgeClassicTableModel.java rename to neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/neoforge/NeoForgeClassicTableModel.java index 56ea6540d..ad78e1834 100644 --- a/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/forge/NeoForgeClassicTableModel.java +++ b/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/neoforge/NeoForgeClassicTableModel.java @@ -1,4 +1,4 @@ -package com.unlikepaladin.pfm.blocks.models.classicTable.forge; +package com.unlikepaladin.pfm.blocks.models.classicTable.neoforge; import com.unlikepaladin.pfm.blocks.ClassicTableBlock; import com.unlikepaladin.pfm.blocks.models.neoforge.ModelBitSetProperty; diff --git a/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/forge/UnbakedClassicTableModelImpl.java b/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/neoforge/UnbakedClassicTableModelImpl.java similarity index 90% rename from neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/forge/UnbakedClassicTableModelImpl.java rename to neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/neoforge/UnbakedClassicTableModelImpl.java index f8ace3405..ebb93e7da 100644 --- a/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/forge/UnbakedClassicTableModelImpl.java +++ b/neoforge/src/main/java/com/unlikepaladin/pfm/blocks/models/classicTable/neoforge/UnbakedClassicTableModelImpl.java @@ -1,4 +1,4 @@ -package com.unlikepaladin.pfm.blocks.models.classicTable.forge; +package com.unlikepaladin.pfm.blocks.models.classicTable.neoforge; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.ModelBakeSettings; diff --git a/neoforge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/neoforge/LateBlockRegistryImpl.java b/neoforge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/neoforge/LateBlockRegistryImpl.java index 75e75b723..0661edfb9 100644 --- a/neoforge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/neoforge/LateBlockRegistryImpl.java +++ b/neoforge/src/main/java/com/unlikepaladin/pfm/registry/dynamic/neoforge/LateBlockRegistryImpl.java @@ -1,6 +1,7 @@ package com.unlikepaladin.pfm.registry.dynamic.neoforge; import com.google.common.collect.ImmutableSet; +import com.mojang.serialization.Lifecycle; import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.blocks.AbstractSittableBlock; import com.unlikepaladin.pfm.blocks.SimpleBedBlock; @@ -18,6 +19,7 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.registry.SimpleRegistry; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.Identifier; import net.minecraft.util.Pair; import net.minecraft.world.poi.PointOfInterestType; @@ -69,14 +71,13 @@ public static void registerBlocks(Registry blockRegisterEvent) { } blocks.forEach((blockName, block) -> Registry.register(Registries.BLOCK, new Identifier(PaladinFurnitureMod.MOD_ID, blockName), block)); - Set originalBedStates = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME.getValue()).blockStates(); + Set originalBedStates = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME).blockStates(); Set addedBedStates = Arrays.stream(PaladinFurnitureModBlocksItems.getBeds()).flatMap(block -> block.getStateManager().getStates().stream().filter(state -> state.get(SimpleBedBlock.PART) == BedPart.HEAD)).collect(ImmutableSet.toImmutableSet()); Set newBedStates = new HashSet<>(); newBedStates.addAll(originalBedStates); newBedStates.addAll(addedBedStates); - PointOfInterestType pointOfInterestType = new PointOfInterestType(newBedStates, 1, 1); - Registry.register(Registries.POINT_OF_INTEREST_TYPE, new Identifier("minecraft", "home"), pointOfInterestType); - PointOfInterestTypes.HOME = Registries.POINT_OF_INTEREST_TYPE.getKey(pointOfInterestType).get(); + PointOfInterestType homePOI = Registries.POINT_OF_INTEREST_TYPE.get(PointOfInterestTypes.HOME); + homePOI.blockStates = ImmutableSet.copyOf(newBedStates); } public static void registerItems(Registry itemIForgeRegistry) { diff --git a/neoforge/src/main/java/com/unlikepaladin/pfm/registry/neoforge/NetworkRegistryNeoForge.java b/neoforge/src/main/java/com/unlikepaladin/pfm/registry/neoforge/NetworkRegistryNeoForge.java index 0e1fb972e..9cbec833c 100644 --- a/neoforge/src/main/java/com/unlikepaladin/pfm/registry/neoforge/NetworkRegistryNeoForge.java +++ b/neoforge/src/main/java/com/unlikepaladin/pfm/registry/neoforge/NetworkRegistryNeoForge.java @@ -3,7 +3,6 @@ import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.advancements.PFMCriteria; import com.unlikepaladin.pfm.networking.neoforge.*; -import net.minecraft.server.network.ServerPlayerConfigurationTask; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; import net.neoforged.bus.api.SubscribeEvent; @@ -15,11 +14,13 @@ @Mod.EventBusSubscriber(modid = "pfm", bus = Mod.EventBusSubscriber.Bus.FORGE) public class NetworkRegistryNeoForge { - - public static final SimpleChannel PFM_CHANNEL = NetworkRegistry.ChannelBuilder.named( - new Identifier(PaladinFurnitureMod.MOD_ID, "main_channel") - ).networkProtocolVersion(() -> "1").simpleChannel(); - + private static final String PROTOCOL_VERSION = "1"; + public static final SimpleChannel PFM_CHANNEL = NetworkRegistry.newSimpleChannel( + new Identifier(PaladinFurnitureMod.MOD_ID, "main_channel"), + () -> PROTOCOL_VERSION, + PROTOCOL_VERSION::equals, + PROTOCOL_VERSION::equals + ); public static void registerPackets() { int id = 0;