diff --git a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java index 3291b28e1..1ab1c9cf3 100644 --- a/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java +++ b/common/src/main/java/com/unlikepaladin/pfm/blocks/models/ModelHelper.java @@ -30,33 +30,30 @@ import java.util.concurrent.atomic.AtomicBoolean; public class ModelHelper { - private static final List OAK_SPRITES_PLANKS_TO_REPLACE = new ArrayList<>(); + private static List OAK_SPRITES_PLANKS_TO_REPLACE = null; public static List getOakPlankLogSprites() { - if (OAK_SPRITES_PLANKS_TO_REPLACE.isEmpty()) { + if (OAK_SPRITES_PLANKS_TO_REPLACE == null) { SpriteIdentifier planksId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.PLANKS)); SpriteIdentifier logId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.LOG)); - OAK_SPRITES_PLANKS_TO_REPLACE.add(planksId.getSprite()); - OAK_SPRITES_PLANKS_TO_REPLACE.add(logId.getSprite()); + OAK_SPRITES_PLANKS_TO_REPLACE = Arrays.asList(planksId.getSprite(), logId.getSprite()); } return OAK_SPRITES_PLANKS_TO_REPLACE; } - private static final List OAK_SPRITES_BED_TO_REPLACE = new ArrayList<>(); + private static List OAK_SPRITES_BED_TO_REPLACE = null; public static List getOakBedSprites() { - if (OAK_SPRITES_BED_TO_REPLACE.isEmpty()) { + if (OAK_SPRITES_BED_TO_REPLACE == null) { SpriteIdentifier planksId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.PLANKS)); SpriteIdentifier bedId = TexturedRenderLayers.BED_TEXTURES[DyeColor.RED.getId()]; - OAK_SPRITES_BED_TO_REPLACE.add(planksId.getSprite()); - OAK_SPRITES_BED_TO_REPLACE.add(bedId.getSprite()); + OAK_SPRITES_BED_TO_REPLACE = Arrays.asList(planksId.getSprite(), bedId.getSprite()); } return OAK_SPRITES_BED_TO_REPLACE; } - private static final List OAK_SPRITES_LOG_TOP_TO_REPLACE = new ArrayList<>(); + private static List OAK_SPRITES_LOG_TOP_TO_REPLACE = null; public static List getOakLogLogTopSprites() { - if (OAK_SPRITES_LOG_TOP_TO_REPLACE.isEmpty()) { + if (OAK_SPRITES_LOG_TOP_TO_REPLACE == null) { SpriteIdentifier logId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.LOG)); SpriteIdentifier logTopId = new SpriteIdentifier(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, WoodVariantRegistry.OAK.getTexture(BlockType.LOG_TOP)); - OAK_SPRITES_LOG_TOP_TO_REPLACE.add(logId.getSprite()); - OAK_SPRITES_LOG_TOP_TO_REPLACE.add(logTopId.getSprite()); + OAK_SPRITES_LOG_TOP_TO_REPLACE = Arrays.asList(logId.getSprite(), logTopId.getSprite()); } return OAK_SPRITES_LOG_TOP_TO_REPLACE; } diff --git a/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMItemEntryAccessor.java b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMItemEntryAccessor.java new file mode 100644 index 000000000..01196ff9c --- /dev/null +++ b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMItemEntryAccessor.java @@ -0,0 +1,12 @@ +package com.unlikepaladin.pfm.mixin.forge; + +import net.minecraft.item.Item; +import net.minecraft.loot.entry.ItemEntry; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(ItemEntry.class) +public interface PFMItemEntryAccessor { + @Accessor("item") + Item getItem(); +} diff --git a/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMLootPool$BuilderMixin.java b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMLootPool$BuilderMixin.java new file mode 100644 index 000000000..480cac659 --- /dev/null +++ b/forge/src/main/java/com/unlikepaladin/pfm/mixin/forge/PFMLootPool$BuilderMixin.java @@ -0,0 +1,32 @@ +package com.unlikepaladin.pfm.mixin.forge; + +import com.unlikepaladin.pfm.runtime.PFMGenerator; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.LootTable; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.loot.entry.LootPoolEntry; +import net.minecraft.loot.entry.LootPoolEntryTypes; +import net.minecraftforge.registries.ForgeRegistries; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.List; + +@Mixin(LootPool.Builder.class) +public abstract class PFMLootPool$BuilderMixin { + @Shadow @Final private List entries; + + @Shadow public abstract LootPool.Builder name(String name); + + @Inject(method = "build", at = @At("HEAD")) + private void setPFMName(CallbackInfoReturnable cir) { + if ( PFMGenerator.isDataRunning() && !entries.isEmpty() && entries.get(0).getType().equals(LootPoolEntryTypes.ITEM)) { + PFMItemEntryAccessor entry = (PFMItemEntryAccessor) entries.get(0); + name(ForgeRegistries.ITEMS.getKey(entry.getItem()).getPath()); + } + } +} diff --git a/forge/src/main/resources/pfm.mixins.json b/forge/src/main/resources/pfm.mixins.json index fe06e4434..0ba7b8dd2 100755 --- a/forge/src/main/resources/pfm.mixins.json +++ b/forge/src/main/resources/pfm.mixins.json @@ -10,6 +10,8 @@ ], "mixins": [ "PFMCookingPotBlockEntityMixin", + "PFMItemEntryAccessor", + "PFMLootPool$BuilderMixin", "PFMReloadableResourceManagerImplMixin" ], "injectors": { diff --git a/gradle.properties b/gradle.properties index 8b407d76d..1dd1064e7 100755 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.18.1 enabled_platforms=fabric,forge archives_base_name=paladin-furniture-mod -mod_version=1.2.1-rc.3 +mod_version=1.2.1 maven_group=com.unlikepaladin architectury_version=3.9.66