Skip to content

Commit

Permalink
Merge branch 'architectury-1.17.1' into architectury-1.18.1
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Jan 2, 2024
2 parents 16672fe + c9084b2 commit 8fe4e36
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,13 +75,13 @@ public static void registerLateEntries() {
BlockEntityRegistry.registerBlockEntities();
}

public static void replaceHomePOI() {
Set<BlockState> originalBedStates = PointOfInterestType.HOME.blockStates;
public static void replaceHomePOIStates() {
Set<BlockState> originalBedStates = ((PFMPointOfInterestTypeAccessor)PointOfInterestType.HOME).getBlockStates();
Set<BlockState> addedBedStates = Arrays.stream(PaladinFurnitureModBlocksItems.getBeds()).flatMap(block -> block.getStateManager().getStates().stream().filter(state -> state.get(SimpleBedBlock.PART) == BedPart.HEAD)).collect(ImmutableSet.toImmutableSet());
Set<BlockState> 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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ static Map<BlockState, PointOfInterestType> getBlockStateToPointOfInterestType()
static void setRegisteredStates(Set<BlockState> states) {
throw new AssertionError();
}

@Accessor("blockStates")
Set<BlockState> getBlockStates();

@Mutable
@Accessor("blockStates")
void setBlockStates(Set<BlockState> states);
}
2 changes: 0 additions & 2 deletions common/src/main/resources/pfm.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -127,6 +112,6 @@ public static void initializeItemGroup() {
public void onInitializeServer() {
PaladinFurnitureMod.isClient = false;
registerLateEntries();
replaceHomePOI();
replaceHomePOIStates();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,7 +55,7 @@ public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType)

public static void registerBlocks(RegistryEvent.Register<Block> blockRegisterEvent) {
blockRegisterEvent.getRegistry().registerAll(blocks.toArray(new Block[0]));
PaladinFurnitureModForge.replaceHomePOI();
PaladinFurnitureModForge.replaceHomePOIStates();
}

public static void registerItems(RegistryEvent.Register<Item> blockRegisterEvent) {
Expand Down

0 comments on commit 8fe4e36

Please sign in to comment.