From ba89c431b15efd89d5740d64917348031ec5ac5e Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 2 Jan 2024 10:37:20 -0600 Subject: [PATCH 1/6] Improved POI type state replacement --- .../pfm/PaladinFurnitureMod.java | 21 ++++++++--- .../mixin/PFMMixinPointOfInterestType.java | 35 ------------------- .../PFMMixinPointOfInterestTypeFactory.java | 17 --------- .../src/main/resources/pfm-common.mixins.json | 2 -- common/src/main/resources/pfm.accesswidener | 4 ++- .../pfm/fabric/PaladinFurnitureModFabric.java | 10 +----- .../dynamic/forge/LateBlockRegistryImpl.java | 3 ++ 7 files changed, 24 insertions(+), 68 deletions(-) delete mode 100644 common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestType.java delete mode 100644 common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestTypeFactory.java diff --git a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java index 15e54de5a..804a62020 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java +++ b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java @@ -1,5 +1,7 @@ package com.unlikepaladin.pfm; +import com.google.common.collect.ImmutableSet; +import com.unlikepaladin.pfm.blocks.SimpleBedBlock; import com.unlikepaladin.pfm.blocks.behavior.BathtubBehavior; import com.unlikepaladin.pfm.blocks.behavior.SinkBehavior; import com.unlikepaladin.pfm.compat.PFMModCompatibility; @@ -11,21 +13,23 @@ import com.unlikepaladin.pfm.data.materials.DynamicBlockRegistry; import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry; import com.unlikepaladin.pfm.registry.BlockEntityRegistry; +import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; import com.unlikepaladin.pfm.utilities.Version; import dev.architectury.injectables.annotations.ExpectPlatform; +import net.minecraft.block.BlockState; +import net.minecraft.block.enums.BedPart; import net.minecraft.item.ItemGroup; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; import net.minecraft.util.StringIdentifiable; +import net.minecraft.world.poi.PointOfInterestType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; public class PaladinFurnitureMod { @@ -35,7 +39,6 @@ public class PaladinFurnitureMod { public static final Logger GENERAL_LOGGER = LogManager.getLogger(); public static ItemGroup FURNITURE_GROUP; - public static ItemGroup DYE_KITS; private static PaladinFurnitureModUpdateChecker updateChecker; public static boolean isClient = false; @@ -71,6 +74,16 @@ public static void registerLateEntries() { } BlockEntityRegistry.registerBlockEntities(); } + + public static void replaceHomePOI() { + Set originalBedStates = PointOfInterestType.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.HOME.blockStates = ImmutableSet.copyOf(newBedStates); + } + @ExpectPlatform public static PaladinFurnitureModConfig getPFMConfig() { throw new AssertionError(); diff --git a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestType.java b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestType.java deleted file mode 100644 index 788e387d4..000000000 --- a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestType.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.unlikepaladin.pfm.mixin; - -import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; -import net.minecraft.block.BlockState; -import net.minecraft.world.poi.PointOfInterestType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.gen.Accessor; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; -import org.spongepowered.asm.mixin.injection.Slice; - -import java.util.HashSet; -import java.util.Set; - -@Mixin(value = PointOfInterestType.class, priority = 3000) -public class PFMMixinPointOfInterestType { - @ModifyArg( - method = "", - slice = @Slice(from = @At( - value = "CONSTANT", - args = "stringValue=home") - ), - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/poi/PointOfInterestType;register(Ljava/lang/String;Ljava/util/Set;II)Lnet/minecraft/world/poi/PointOfInterestType;", - ordinal = 0 - ), - index = 1 - ) - private static Set appendBeds(Set workStationStates) { - PaladinFurnitureModBlocksItems.originalHomePOIBedStates.addAll(workStationStates); - return new HashSet<>(); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestTypeFactory.java b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestTypeFactory.java deleted file mode 100644 index c8864842f..000000000 --- a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMMixinPointOfInterestTypeFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.unlikepaladin.pfm.mixin; - -import net.minecraft.block.BlockState; -import net.minecraft.world.poi.PointOfInterestType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -import java.util.Set; - - -@Mixin(value = PointOfInterestType.class) -public interface PFMMixinPointOfInterestTypeFactory { - @Invoker("") - static PointOfInterestType newPoi(String id, Set blockStates, int ticketCount, int searchDistance) { - throw new AssertionError(); - } -} \ No newline at end of file diff --git a/common/src/main/resources/pfm-common.mixins.json b/common/src/main/resources/pfm-common.mixins.json index 4a3643c84..0c68dd391 100644 --- a/common/src/main/resources/pfm-common.mixins.json +++ b/common/src/main/resources/pfm-common.mixins.json @@ -5,8 +5,6 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "PFMAbstractTagProvider$ObjectBuilderMixin", - "PFMMixinPointOfInterestType", - "PFMMixinPointOfInterestTypeFactory", "PFMPlayerInventoryMixin", "PFMTextureKeyFactory" ], diff --git a/common/src/main/resources/pfm.accesswidener b/common/src/main/resources/pfm.accesswidener index ddf35c6e8..8c82d5954 100644 --- a/common/src/main/resources/pfm.accesswidener +++ b/common/src/main/resources/pfm.accesswidener @@ -8,4 +8,6 @@ mutable field net/minecraft/world/poi/PointOfInterestType HOME Lnet/minecraft/wo accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithProperty (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;)Lnet/minecraft/loot/LootTable$Builder; accessible class net/minecraft/data/server/AbstractTagProvider$ObjectBuilder -accessible method net/minecraft/client/render/item/ItemRenderer renderBakedItemModel (Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/item/ItemStack;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;)V \ No newline at end of file +accessible method net/minecraft/client/render/item/ItemRenderer renderBakedItemModel (Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/item/ItemStack;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;)V +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 87d0bfda7..b22b9783a 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java @@ -10,7 +10,6 @@ import com.unlikepaladin.pfm.config.option.AbstractConfigOption; import com.unlikepaladin.pfm.data.materials.DynamicBlockRegistry; import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry; -import com.unlikepaladin.pfm.mixin.PFMMixinPointOfInterestTypeFactory; import com.unlikepaladin.pfm.registry.*; import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; import com.unlikepaladin.pfm.registry.fabric.*; @@ -39,6 +38,7 @@ import org.apache.logging.log4j.Logger; import java.io.IOException; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -123,14 +123,6 @@ public static void initializeItemGroup() { () -> PaladinFurnitureModBlocksItems.furnitureEntryMap.get(BasicChairBlock.class).getVariantToBlockMap().get(WoodVariantRegistry.OAK).asItem().getDefaultStack()); } - 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 newBedStates = new HashSet<>(); - newBedStates.addAll(PaladinFurnitureModBlocksItems.originalHomePOIBedStates); - newBedStates.addAll(addedBedStates); - newBedStates = newBedStates.stream().collect(ImmutableSet.toImmutableSet()); - PointOfInterestType.HOME = PointOfInterestType.setup(Registry.register(Registry.POINT_OF_INTEREST_TYPE, Registry.POINT_OF_INTEREST_TYPE.getRawId(PointOfInterestType.HOME), "home", PFMMixinPointOfInterestTypeFactory.newPoi("home", newBedStates, 1, 1))); - } @Override public void onInitializeServer() { PaladinFurnitureMod.isClient = false; 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 2a7e8345b..047cd463a 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 @@ -1,6 +1,8 @@ package com.unlikepaladin.pfm.registry.dynamic.forge; +import com.unlikepaladin.pfm.forge.PaladinFurnitureModForge; import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; +import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; import com.unlikepaladin.pfm.registry.forge.BlockItemRegistryImpl; import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; import net.minecraft.block.Block; @@ -56,6 +58,7 @@ public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) public static void registerBlocks(RegistryEvent.Register blockRegisterEvent) { blockRegisterEvent.getRegistry().registerAll(blocks.toArray(new Block[0])); + PaladinFurnitureModForge.replaceHomePOI(); } public static void registerItems(RegistryEvent.Register blockRegisterEvent) { From a3dd30349d42b720b819e80043aad3a9fd743d98 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 2 Jan 2024 10:45:46 -0600 Subject: [PATCH 2/6] Fixed a possible bug with the new POI replacement --- .../main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java | 1 + common/src/main/resources/pfm.accesswidener | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java index 804a62020..43f15f3bb 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java +++ b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java @@ -82,6 +82,7 @@ public static void replaceHomePOI() { newBedStates.addAll(originalBedStates); newBedStates.addAll(addedBedStates); PointOfInterestType.HOME.blockStates = ImmutableSet.copyOf(newBedStates); + addedBedStates.forEach(state -> PointOfInterestType.BLOCK_STATE_TO_POINT_OF_INTEREST_TYPE.put(state, PointOfInterestType.HOME)); } @ExpectPlatform diff --git a/common/src/main/resources/pfm.accesswidener b/common/src/main/resources/pfm.accesswidener index 8c82d5954..74e444c2f 100644 --- a/common/src/main/resources/pfm.accesswidener +++ b/common/src/main/resources/pfm.accesswidener @@ -10,4 +10,5 @@ accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithPro accessible class net/minecraft/data/server/AbstractTagProvider$ObjectBuilder accessible method net/minecraft/client/render/item/ItemRenderer renderBakedItemModel (Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/item/ItemStack;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;)V 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 +mutable field net/minecraft/world/poi/PointOfInterestType blockStates Ljava/util/Set; +accessible field net/minecraft/world/poi/PointOfInterestType BLOCK_STATE_TO_POINT_OF_INTEREST_TYPE Ljava/util/Map; \ No newline at end of file From 1c14c2c1177131e96a0e82562163ca50477c1655 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 2 Jan 2024 11:17:20 -0600 Subject: [PATCH 3/6] Improved POI further --- .../pfm/PaladinFurnitureMod.java | 5 +++- .../mixin/PFMPointOfInterestTypeAccessor.java | 24 +++++++++++++++++++ .../src/main/resources/pfm-common.mixins.json | 1 + common/src/main/resources/pfm.accesswidener | 8 +++---- 4 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java diff --git a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java index 43f15f3bb..26e198ee3 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java +++ b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java @@ -12,12 +12,14 @@ import com.unlikepaladin.pfm.data.materials.DynamicBlockRegistry; import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry; +import com.unlikepaladin.pfm.mixin.PFMPointOfInterestTypeAccessor; import com.unlikepaladin.pfm.registry.BlockEntityRegistry; import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; import com.unlikepaladin.pfm.utilities.Version; import dev.architectury.injectables.annotations.ExpectPlatform; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.block.BlockState; import net.minecraft.block.enums.BedPart; import net.minecraft.item.ItemGroup; @@ -82,7 +84,8 @@ public static void replaceHomePOI() { newBedStates.addAll(originalBedStates); newBedStates.addAll(addedBedStates); PointOfInterestType.HOME.blockStates = ImmutableSet.copyOf(newBedStates); - addedBedStates.forEach(state -> PointOfInterestType.BLOCK_STATE_TO_POINT_OF_INTEREST_TYPE.put(state, PointOfInterestType.HOME)); + addedBedStates.forEach(state -> PFMPointOfInterestTypeAccessor.getBlockStateToPointOfInterestType().put(state, PointOfInterestType.HOME)); + PFMPointOfInterestTypeAccessor.setRegisteredStates(new ObjectOpenHashSet<>(PFMPointOfInterestTypeAccessor.getBlockStateToPointOfInterestType().keySet())); } @ExpectPlatform diff --git a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java new file mode 100644 index 000000000..72503ed7f --- /dev/null +++ b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java @@ -0,0 +1,24 @@ +package com.unlikepaladin.pfm.mixin; + +import net.minecraft.block.BlockState; +import net.minecraft.world.poi.PointOfInterestType; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Map; +import java.util.Set; + +@Mixin(PointOfInterestType.class) +public interface PFMPointOfInterestTypeAccessor { + @Accessor("BLOCK_STATE_TO_POINT_OF_INTEREST_TYPE") + static Map getBlockStateToPointOfInterestType() { + throw new AssertionError(); + } + + @Mutable + @Accessor("REGISTERED_STATES") + static void setRegisteredStates(Set states) { + throw new AssertionError(); + } +} diff --git a/common/src/main/resources/pfm-common.mixins.json b/common/src/main/resources/pfm-common.mixins.json index 0c68dd391..713eaa5e8 100644 --- a/common/src/main/resources/pfm-common.mixins.json +++ b/common/src/main/resources/pfm-common.mixins.json @@ -6,6 +6,7 @@ "mixins": [ "PFMAbstractTagProvider$ObjectBuilderMixin", "PFMPlayerInventoryMixin", + "PFMPointOfInterestTypeAccessor", "PFMTextureKeyFactory" ], "server": [ diff --git a/common/src/main/resources/pfm.accesswidener b/common/src/main/resources/pfm.accesswidener index 74e444c2f..7f0aba7bc 100644 --- a/common/src/main/resources/pfm.accesswidener +++ b/common/src/main/resources/pfm.accesswidener @@ -2,13 +2,11 @@ accessWidener v1 named accessible class net/minecraft/recipe/CookingRecipeSerializer$RecipeFactory accessible class net/minecraft/block/entity/BlockEntityType$BlockEntityFactory -accessible field net/minecraft/world/poi/PointOfInterestType BED_STATES Ljava/util/Set; -accessible method net/minecraft/world/poi/PointOfInterestType setup (Lnet/minecraft/world/poi/PointOfInterestType;)Lnet/minecraft/world/poi/PointOfInterestType; -mutable field net/minecraft/world/poi/PointOfInterestType HOME Lnet/minecraft/world/poi/PointOfInterestType; accessible method net/minecraft/data/server/BlockLootTableGenerator drops (Lnet/minecraft/item/ItemConvertible;)Lnet/minecraft/loot/LootTable$Builder; accessible method net/minecraft/data/server/BlockLootTableGenerator dropsWithProperty (Lnet/minecraft/block/Block;Lnet/minecraft/state/property/Property;Ljava/lang/Comparable;)Lnet/minecraft/loot/LootTable$Builder; accessible class net/minecraft/data/server/AbstractTagProvider$ObjectBuilder accessible method net/minecraft/client/render/item/ItemRenderer renderBakedItemModel (Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/item/ItemStack;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;)V +accessible field net/minecraft/client/resource/language/LanguageManager field_25291 Lnet/minecraft/client/resource/language/LanguageDefinition; +accessible field net/minecraft/block/AbstractBlock$Settings material Lnet/minecraft/block/Material; accessible field net/minecraft/world/poi/PointOfInterestType blockStates Ljava/util/Set; -mutable field net/minecraft/world/poi/PointOfInterestType blockStates Ljava/util/Set; -accessible field net/minecraft/world/poi/PointOfInterestType BLOCK_STATE_TO_POINT_OF_INTEREST_TYPE Ljava/util/Map; \ No newline at end of file +mutable field net/minecraft/world/poi/PointOfInterestType blockStates Ljava/util/Set; \ No newline at end of file From c9084b225692cac448a35d1e2cda49f7b1fb9648 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 2 Jan 2024 11:34:31 -0600 Subject: [PATCH 4/6] No more access widener for the POI --- .../unlikepaladin/pfm/PaladinFurnitureMod.java | 8 +++----- .../mixin/PFMPointOfInterestTypeAccessor.java | 7 +++++++ common/src/main/resources/pfm.accesswidener | 2 -- .../fabric/PaladinFurnitureModClientFabric.java | 2 +- .../pfm/fabric/PaladinFurnitureModFabric.java | 17 +---------------- .../dynamic/forge/LateBlockRegistryImpl.java | 5 +---- 6 files changed, 13 insertions(+), 28 deletions(-) diff --git a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java index 26e198ee3..63004b23c 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java +++ b/common/src/main/java/com/unlikepaladin/pfm/PaladinFurnitureMod.java @@ -16,8 +16,6 @@ import com.unlikepaladin.pfm.registry.BlockEntityRegistry; import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; -import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; -import com.unlikepaladin.pfm.utilities.Version; import dev.architectury.injectables.annotations.ExpectPlatform; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import net.minecraft.block.BlockState; @@ -77,13 +75,13 @@ public static void registerLateEntries() { BlockEntityRegistry.registerBlockEntities(); } - public static void replaceHomePOI() { - Set originalBedStates = PointOfInterestType.HOME.blockStates; + public static void replaceHomePOIStates() { + Set originalBedStates = ((PFMPointOfInterestTypeAccessor)PointOfInterestType.HOME).getBlockStates(); 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.HOME.blockStates = ImmutableSet.copyOf(newBedStates); + ((PFMPointOfInterestTypeAccessor)PointOfInterestType.HOME).setBlockStates(ImmutableSet.copyOf(newBedStates)); addedBedStates.forEach(state -> PFMPointOfInterestTypeAccessor.getBlockStateToPointOfInterestType().put(state, PointOfInterestType.HOME)); PFMPointOfInterestTypeAccessor.setRegisteredStates(new ObjectOpenHashSet<>(PFMPointOfInterestTypeAccessor.getBlockStateToPointOfInterestType().keySet())); } diff --git a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java index 72503ed7f..fd74acb5d 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java +++ b/common/src/main/java/com/unlikepaladin/pfm/mixin/PFMPointOfInterestTypeAccessor.java @@ -21,4 +21,11 @@ static Map getBlockStateToPointOfInterestType() static void setRegisteredStates(Set states) { throw new AssertionError(); } + + @Accessor("blockStates") + Set getBlockStates(); + + @Mutable + @Accessor("blockStates") + void setBlockStates(Set states); } diff --git a/common/src/main/resources/pfm.accesswidener b/common/src/main/resources/pfm.accesswidener index 7f0aba7bc..0c0f749cd 100644 --- a/common/src/main/resources/pfm.accesswidener +++ b/common/src/main/resources/pfm.accesswidener @@ -8,5 +8,3 @@ accessible class net/minecraft/data/server/AbstractTagProvider$ObjectBuilder accessible method net/minecraft/client/render/item/ItemRenderer renderBakedItemModel (Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/item/ItemStack;IILnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;)V accessible field net/minecraft/client/resource/language/LanguageManager field_25291 Lnet/minecraft/client/resource/language/LanguageDefinition; accessible field net/minecraft/block/AbstractBlock$Settings material Lnet/minecraft/block/Material; -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/client/fabric/PaladinFurnitureModClientFabric.java b/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/PaladinFurnitureModClientFabric.java index ae0600c19..fe5699185 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/PaladinFurnitureModClientFabric.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/client/fabric/PaladinFurnitureModClientFabric.java @@ -26,7 +26,7 @@ public class PaladinFurnitureModClientFabric implements ClientModInitializer { public void onInitializeClient() { PaladinFurnitureMod.isClient = true; PaladinFurnitureMod.registerLateEntries(); - PaladinFurnitureModFabric.replaceHomePOI(); + PaladinFurnitureModFabric.replaceHomePOIStates(); ColorRegistryFabric.registerAll(); NetworkRegistryFabric.registerClientPackets(); 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 b22b9783a..d1ee6b213 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/fabric/PaladinFurnitureModFabric.java @@ -1,47 +1,32 @@ package com.unlikepaladin.pfm.fabric; -import com.google.common.collect.ImmutableSet; import com.unlikepaladin.pfm.PaladinFurnitureMod; import com.unlikepaladin.pfm.advancements.PFMCriteria; import com.unlikepaladin.pfm.advancements.fabric.CriteriaRegistryFabric; import com.unlikepaladin.pfm.blocks.BasicChairBlock; -import com.unlikepaladin.pfm.blocks.SimpleBedBlock; import com.unlikepaladin.pfm.config.PaladinFurnitureModConfig; import com.unlikepaladin.pfm.config.option.AbstractConfigOption; -import com.unlikepaladin.pfm.data.materials.DynamicBlockRegistry; import com.unlikepaladin.pfm.data.materials.WoodVariantRegistry; import com.unlikepaladin.pfm.registry.*; -import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; import com.unlikepaladin.pfm.registry.fabric.*; -import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; import io.netty.buffer.Unpooled; import net.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.networking.v1.PacketSender; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.block.BlockState; -import net.minecraft.block.enums.BedPart; -import net.minecraft.entity.vehicle.BoatEntity; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketByteBuf; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; -import net.minecraft.util.Pair; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.poi.PointOfInterestType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; -import java.util.Arrays; import java.util.Collection; -import java.util.HashSet; -import java.util.Set; public class PaladinFurnitureModFabric extends PaladinFurnitureMod implements ModInitializer, DedicatedServerModInitializer { @@ -127,6 +112,6 @@ public static void initializeItemGroup() { public void onInitializeServer() { PaladinFurnitureMod.isClient = false; registerLateEntries(); - replaceHomePOI(); + replaceHomePOIStates(); } } 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 047cd463a..e736879a1 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 @@ -2,9 +2,6 @@ import com.unlikepaladin.pfm.forge.PaladinFurnitureModForge; import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems; -import com.unlikepaladin.pfm.registry.dynamic.LateBlockRegistry; -import com.unlikepaladin.pfm.registry.forge.BlockItemRegistryImpl; -import com.unlikepaladin.pfm.runtime.PFMRuntimeResources; import net.minecraft.block.Block; import net.minecraft.block.Material; import net.minecraft.item.BlockItem; @@ -58,7 +55,7 @@ public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) public static void registerBlocks(RegistryEvent.Register blockRegisterEvent) { blockRegisterEvent.getRegistry().registerAll(blocks.toArray(new Block[0])); - PaladinFurnitureModForge.replaceHomePOI(); + PaladinFurnitureModForge.replaceHomePOIStates(); } public static void registerItems(RegistryEvent.Register blockRegisterEvent) { From ed52e7b7623aad3a2de2f53d9a4fa7c19bc6e898 Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 2 Jan 2024 13:15:06 -0600 Subject: [PATCH 5/6] oops --- fabric/src/main/resources/pfm.mixins.json | 1 - 1 file changed, 1 deletion(-) diff --git a/fabric/src/main/resources/pfm.mixins.json b/fabric/src/main/resources/pfm.mixins.json index d1b660711..7851f6ee2 100755 --- a/fabric/src/main/resources/pfm.mixins.json +++ b/fabric/src/main/resources/pfm.mixins.json @@ -10,7 +10,6 @@ "mixins": [ "PFMCookingPotBlockEntityMixin", "PFMMinecraftServerMixin", - "PFMMixinPointOfInterestType", "PFMReloadableResourceManagerImplMixin", "PFMSaveLoaderMixin", "PFMModResourcePackCreatorMixin" From bc99cdcc92ffeb6c53e3656e44de19a1067f72ef Mon Sep 17 00:00:00 2001 From: UnlikePaladin <36827970+UnlikePaladin@users.noreply.github.com> Date: Tue, 2 Jan 2024 13:15:27 -0600 Subject: [PATCH 6/6] fix a model error on Fabric --- .../blocks/models/basicTable/fabric/FabricBasicTableModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/fabric/FabricBasicTableModel.java b/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/fabric/FabricBasicTableModel.java index fecb6879f..3e83184b1 100644 --- a/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/fabric/FabricBasicTableModel.java +++ b/fabric/src/main/java/com/unlikepaladin/pfm/blocks/models/basicTable/fabric/FabricBasicTableModel.java @@ -142,7 +142,7 @@ public void emitBlockQuads(BlockRenderView world, BlockState state, BlockPos pos } if (north && south && !east) { - ((FabricBakedModel) getTemplateBakedModels().get(2)).emitBlockQuads(world, state, pos, randomSupplier, context); + ((FabricBakedModel) getTemplateBakedModels().get(12)).emitBlockQuads(world, state, pos, randomSupplier, context); } if (north && south && !west) { ((FabricBakedModel) getTemplateBakedModels().get(11)).emitBlockQuads(world, state, pos, randomSupplier, context);