Skip to content

Commit

Permalink
Merge branch 'architectury-1.20.2' into architectury-1.20.4
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/src/main/java/com/unlikepaladin/pfm/data/materials/ExtraStoolVariant.java
  • Loading branch information
UnlikePaladin committed Feb 21, 2024
2 parents 0ad6f09 + ec7b3be commit 814282e
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public String asString() {

@Override
public Block getBaseBlock() {
if (baseBlock == null)
return PaladinFurnitureModBlocksItems.RAW_CONCRETE;

return baseBlock;
}

@Override
public Block getSecondaryBlock() {
if (secondaryBlock == null)
return PaladinFurnitureModBlocksItems.RAW_CONCRETE;

return secondaryBlock;
}

Expand Down Expand Up @@ -99,15 +99,15 @@ public void initializeChildrenItems() {

@Override
public Block mainChild() {
return baseBlock;
return getBaseBlock();
}

@Environment(EnvType.CLIENT)
@Override
public Identifier getTexture(BlockType type) {
if (type == BlockType.SECONDARY)
return ModelHelper.getTextureId(getSecondaryBlock());
return ModelHelper.getTextureId(baseBlock);
return ModelHelper.getTextureId(getBaseBlock());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
package com.unlikepaladin.pfm.client.forge;

import com.mojang.datafixers.util.Pair;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.Sprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.util.math.random.Random;

public interface PFMBakedModelGetQuadsExtension {
List<BakedQuad> getQuads(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random);

Map<Pair<ItemStack, Direction>, List<BakedQuad>> cache = new HashMap<>();
default List<BakedQuad> getQuadsCached(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random) {
Pair<ItemStack, Direction> directionPair = new Pair<>(stack, face);
if (cache.containsKey(directionPair))
return cache.get(directionPair);

List<BakedQuad> quads = getQuads(stack, state, face, random);
cache.put(directionPair, quads);
return quads;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ private void renderPFMItem(ItemStack stack, ModelTransformationMode renderMode,
long randomSeed = 42L;
for (Direction direction : Direction.values()) {
random.setSeed(randomSeed);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension) model).getQuads(stack, state, direction, random), stack, light, overlay);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension) model).getQuadsCached(stack, state, direction, random), stack, light, overlay);
}
random.setSeed(randomSeed);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension)model).getQuads(stack, state, null, random), stack, light, overlay);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension)model).getQuadsCached(stack, state, null, random), stack, light, overlay);

// Conditionally pop because of handlePerspective weirdness
if (matrices.peek() != pose) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
package com.unlikepaladin.pfm.client.neoforge;

import com.mojang.datafixers.util.Pair;
import net.minecraft.block.BlockState;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.Sprite;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import net.minecraft.util.math.random.Random;

public interface PFMBakedModelGetQuadsExtension {
List<BakedQuad> getQuads(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random);

Map<Pair<ItemStack, Direction>, List<BakedQuad>> cache = new HashMap<>();
default List<BakedQuad> getQuadsCached(ItemStack stack, @Nullable BlockState state, @Nullable Direction face, Random random) {
Pair<ItemStack, Direction> directionPair = new Pair<>(stack, face);
if (cache.containsKey(directionPair))
return cache.get(directionPair);

List<BakedQuad> quads = getQuads(stack, state, face, random);
cache.put(directionPair, quads);
return quads;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ private void renderPFMItem(ItemStack stack, ModelTransformationMode renderMode,
long randomSeed = 42L;
for (Direction direction : Direction.values()) {
random.setSeed(randomSeed);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension) model).getQuads(stack, state, direction, random), stack, light, overlay);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension) model).getQuadsCached(stack, state, direction, random), stack, light, overlay);
}
random.setSeed(randomSeed);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension)model).getQuads(stack, state, null, random), stack, light, overlay);
this.renderBakedItemQuads(matrices, vertexConsumer, ((PFMBakedModelGetQuadsExtension)model).getQuadsCached(stack, state, null, random), stack, light, overlay);

// Conditionally pop because of handlePerspective weirdness
if (matrices.peek() != pose) {
Expand Down

0 comments on commit 814282e

Please sign in to comment.