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 257aaac + 1c14c2c commit 16672fe
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 71 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -10,22 +12,26 @@

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

Expand All @@ -35,7 +41,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;
Expand Down Expand Up @@ -71,6 +76,18 @@ public static void registerLateEntries() {
}
BlockEntityRegistry.registerBlockEntities();
}

public static void replaceHomePOI() {
Set<BlockState> originalBedStates = PointOfInterestType.HOME.blockStates;
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);
addedBedStates.forEach(state -> PFMPointOfInterestTypeAccessor.getBlockStateToPointOfInterestType().put(state, PointOfInterestType.HOME));
PFMPointOfInterestTypeAccessor.setRegisteredStates(new ObjectOpenHashSet<>(PFMPointOfInterestTypeAccessor.getBlockStateToPointOfInterestType().keySet()));
}

@ExpectPlatform
public static PaladinFurnitureModConfig getPFMConfig() {
throw new AssertionError();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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<BlockState, PointOfInterestType> getBlockStateToPointOfInterestType() {
throw new AssertionError();
}

@Mutable
@Accessor("REGISTERED_STATES")
static void setRegisteredStates(Set<BlockState> states) {
throw new AssertionError();
}
}
3 changes: 1 addition & 2 deletions common/src/main/resources/pfm-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"PFMAbstractTagProvider$ObjectBuilderMixin",
"PFMMixinPointOfInterestType",
"PFMMixinPointOfInterestTypeFactory",
"PFMPlayerInventoryMixin",
"PFMPointOfInterestTypeAccessor",
"PFMTextureKeyFactory"
],
"server": [
Expand Down
9 changes: 5 additions & 4 deletions common/src/main/resources/pfm.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +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 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 @@ -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.*;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -123,14 +123,6 @@ public static void initializeItemGroup() {
() -> PaladinFurnitureModBlocksItems.furnitureEntryMap.get(BasicChairBlock.class).getVariantToBlockMap().get(WoodVariantRegistry.OAK).asItem().getDefaultStack());
}

public static void replaceHomePOI() {
Set<BlockState> addedBedStates = PaladinFurnitureModBlocksItems.beds.stream().flatMap(block -> block.getStateManager().getStates().stream().filter(state -> state.get(SimpleBedBlock.PART) == BedPart.HEAD)).collect(ImmutableSet.toImmutableSet());
Set<BlockState> 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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -56,6 +58,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();
}

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

0 comments on commit 16672fe

Please sign in to comment.