Skip to content

Commit

Permalink
wip: Update to Minecraft 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jul 10, 2024
1 parent 57e42a2 commit 8eb17be
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Locale;

public enum SortingChestType implements StringRepresentable {
WOOD(27, 9, "sorting_chest", "normal", ResourceLocation.withDefaultNamespace("textures/gui/container/generic_54.png"), 176, 168, 256, 256),
WOOD(27, 9, "sorting_chest", "oak", ResourceLocation.withDefaultNamespace("textures/gui/container/generic_54.png"), 176, 168, 256, 256),
IRON(54, 9, "sorting_iron_chest", "iron", ResourceLocation.withDefaultNamespace("textures/gui/container/generic_54.png"), 176, 222, 256, 256),
GOLD(84, 12, "sorting_gold_chest", "gold", ResourceLocation.fromNamespaceAndPath(RefinedRelocation.MOD_ID, "textures/gui/gold_chest.png"), 230, 240, 230, 240),
DIAMOND(112, 16, "sorting_diamond_chest", "diamond", ResourceLocation.fromNamespaceAndPath(RefinedRelocation.MOD_ID, "textures/gui/diamond_chest.png"), 302, 240, 302, 240);
Expand Down Expand Up @@ -51,7 +51,7 @@ public BlockEntityType<SortingChestBlockEntity> getBlockEntityType() {
}

public ResourceLocation getTextureLocation() {
return ResourceLocation.fromNamespaceAndPath(RefinedRelocation.MOD_ID, "entity/sorting_chest/" + texture);
return ResourceLocation.withDefaultNamespace("entity/sorting_chest/" + texture);
}

public Material getMaterial() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import net.blay09.mods.balm.api.client.rendering.BalmRenderers;
import net.blay09.mods.refinedrelocation.block.entity.ModBlockEntities;
import net.blay09.mods.refinedrelocation.fabric.client.render.SortingChestTileEntityRenderer;
import net.blay09.mods.refinedrelocation.fabric.client.render.SortingChestBlockEntityRenderer;

public class ModRenderers {
public static void initialize(BalmRenderers renderers) {
for (final var sortingChest : ModBlockEntities.sortingChests) {
renderers.registerBlockEntityRenderer(sortingChest::get, SortingChestTileEntityRenderer::new);
renderers.registerBlockEntityRenderer(sortingChest::get, SortingChestBlockEntityRenderer::new);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package net.blay09.mods.refinedrelocation.fabric.client.render;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.blay09.mods.refinedrelocation.block.SortingChestBlock;
import net.blay09.mods.refinedrelocation.block.entity.SortingChestBlockEntity;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.blockentity.ChestRenderer;
import net.minecraft.client.resources.model.Material;

public class SortingChestBlockEntityRenderer extends ChestRenderer<SortingChestBlockEntity> {

private static final String BOTTOM = "bottom";
private static final String LID = "lid";
private static final String LOCK = "lock";

private final ModelPart lid;
private final ModelPart bottom;
private final ModelPart lock;

public SortingChestBlockEntityRenderer(BlockEntityRendererProvider.Context context) {
super(context);

final var modelPart = context.bakeLayer(ModelLayers.CHEST);
bottom = modelPart.getChild(BOTTOM);
lid = modelPart.getChild(LID);
lock = modelPart.getChild(LOCK);
}

@Override
public void render(SortingChestBlockEntity sortingChest, float partialTicks, PoseStack poseStack, MultiBufferSource multiBufferSource, int brightness, int overlay) {
final var state = sortingChest.getBlockState();
poseStack.pushPose();
float yRot = state.getValue(SortingChestBlock.FACING).toYRot();
poseStack.translate(0.5f, 0.5f, 0.5f);
poseStack.mulPose(Axis.YP.rotationDegrees(-yRot));
poseStack.translate(-0.5f, -0.5f, -0.5f);

final var openness = sortingChest.getOpenNess(partialTicks);
final var material = getMaterial(sortingChest);
final var buffer = material.buffer(multiBufferSource, RenderType::entityCutout);

lid.xRot = -(openness * 1.5707964F);
lock.xRot = lid.xRot;
lid.render(poseStack, buffer, brightness, overlay);
lock.render(poseStack, buffer, brightness, overlay);
bottom.render(poseStack, buffer, brightness, overlay);

poseStack.popPose();
}

private Material getMaterial(SortingChestBlockEntity blockEntity) {
return blockEntity.getChestType().getMaterial();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"sources": [
{
"type": "directory",
"source": "sorting_chests",
"prefix": "sorting_chests/"
"source": "entity/sorting_chest",
"prefix": "entity/sorting_chest/"
}
]
}

0 comments on commit 8eb17be

Please sign in to comment.