Skip to content

Commit

Permalink
Fix #4526
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Dec 25, 2023
1 parent fc94acd commit 8f67b8f
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package org.violetmoon.quark.content.building.client.render.be;

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

import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.building.module.VariantChestsModule;

import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.ChestRenderer;
import net.minecraft.client.resources.model.Material;
Expand All @@ -8,16 +16,10 @@
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.properties.ChestType;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.building.module.VariantChestsModule;

import java.util.IdentityHashMap;
import java.util.Map;

public class VariantChestRenderer extends ChestRenderer<ChestBlockEntity> {

private final Map<Block, Material> materialMap = new IdentityHashMap<>();
private final Map<Pair<Block, ChestType>, Material> materialMap = new HashMap<>();
protected final boolean isTrap;

public VariantChestRenderer(BlockEntityRendererProvider.Context context, boolean isTrap) {
Expand All @@ -29,8 +31,9 @@ public VariantChestRenderer(BlockEntityRendererProvider.Context context, boolean
@Override
public Material getMaterial(ChestBlockEntity tile, ChestType type) {
Block block = tile.getBlockState().getBlock();

return materialMap.computeIfAbsent(block, b -> {

Pair<Block, ChestType> pair = Pair.of(block, type);
return materialMap.computeIfAbsent(pair, b -> {
if (!(block instanceof VariantChestsModule.IVariantChest v)) return null;
//apply the texture naming convention
StringBuilder tex = new StringBuilder(v.getTextureFolder())
Expand Down

0 comments on commit 8f67b8f

Please sign in to comment.