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 Mar 1, 2024
2 parents 62ce5d4 + 29ce061 commit 5725fe9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,30 @@
import java.util.concurrent.atomic.AtomicBoolean;

public class ModelHelper {
private static final List<Sprite> OAK_SPRITES_PLANKS_TO_REPLACE = new ArrayList<>();
private static List<Sprite> OAK_SPRITES_PLANKS_TO_REPLACE = null;
public static List<Sprite> 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<Sprite> OAK_SPRITES_BED_TO_REPLACE = new ArrayList<>();
private static List<Sprite> OAK_SPRITES_BED_TO_REPLACE = null;
public static List<Sprite> 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<Sprite> OAK_SPRITES_LOG_TOP_TO_REPLACE = new ArrayList<>();
private static List<Sprite> OAK_SPRITES_LOG_TOP_TO_REPLACE = null;
public static List<Sprite> 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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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<LootPoolEntry> entries;

@Shadow public abstract LootPool.Builder name(String name);

@Inject(method = "build", at = @At("HEAD"))
private void setPFMName(CallbackInfoReturnable<LootTable> 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());
}
}
}
2 changes: 2 additions & 0 deletions forge/src/main/resources/pfm.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
],
"mixins": [
"PFMCookingPotBlockEntityMixin",
"PFMItemEntryAccessor",
"PFMLootPool$BuilderMixin",
"PFMReloadableResourceManagerImplMixin"
],
"injectors": {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5725fe9

Please sign in to comment.