Skip to content

Commit

Permalink
Merge branch 'architectury-1.19.4' into architectury-1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Mar 1, 2024
2 parents a1a0f47 + 28fe498 commit b699211
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,30 @@
import net.minecraft.util.math.random.Random;

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());
}
}
}
6 changes: 4 additions & 2 deletions forge/src/main/resources/pfm.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
"mixins": [
"PFMCookingPotBlockEntityMixin",
"PFMMinecraftServerMixin",
"PFMReloadableResourceManagerImplMixin",
"PFMSaveLoaderMixin"
"PFMSaveLoaderMixin",
"PFMItemEntryAccessor",
"PFMLootPool$BuilderMixin",
"PFMReloadableResourceManagerImplMixin"
],
"injectors": {
"defaultRequire": 1
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.20.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=9.1.12
Expand Down

0 comments on commit b699211

Please sign in to comment.