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) {