generated from neoforged/MDK
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2677a78
commit 44e123d
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/github/minecraftschurlimods/bibliocraft/client/ber/DisplayCaseBER.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.github.minecraftschurlimods.bibliocraft.client.ber; | ||
|
||
import com.github.minecraftschurlimods.bibliocraft.content.displaycase.DisplayCaseBlock; | ||
import com.github.minecraftschurlimods.bibliocraft.content.displaycase.DisplayCaseBlockEntity; | ||
import com.github.minecraftschurlimods.bibliocraft.content.displaycase.WallDisplayCaseBlock; | ||
import com.github.minecraftschurlimods.bibliocraft.util.ClientUtil; | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import com.mojang.math.Axis; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; | ||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider; | ||
import net.minecraft.client.renderer.entity.ItemRenderer; | ||
import net.minecraft.world.item.ItemDisplayContext; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.block.Block; | ||
|
||
public class DisplayCaseBER implements BlockEntityRenderer<DisplayCaseBlockEntity> { | ||
@SuppressWarnings("unused") | ||
public DisplayCaseBER(BlockEntityRendererProvider.Context context) { | ||
} | ||
|
||
@Override | ||
public void render(DisplayCaseBlockEntity blockEntity, float partialTick, PoseStack stack, MultiBufferSource buffer, int light, int overlay) { | ||
stack.pushPose(); | ||
ClientUtil.setupCenteredBER(stack, blockEntity); | ||
Block block = blockEntity.getBlockState().getBlock(); | ||
if (block instanceof WallDisplayCaseBlock) { | ||
stack.mulPose(Axis.YP.rotationDegrees(180)); | ||
} else if (block instanceof DisplayCaseBlock) { | ||
stack.mulPose(Axis.XP.rotationDegrees(90)); | ||
stack.mulPose(Axis.ZP.rotationDegrees(180)); | ||
} | ||
stack.translate(0, 0, 0.25f); | ||
stack.scale(0.5f, 0.5f, 0.5f); | ||
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); | ||
ItemStack item = blockEntity.getItem(0); | ||
renderer.render(item, ItemDisplayContext.FIXED, false, stack, buffer, light, overlay, renderer.getModel(item, blockEntity.getLevel(), null, 0)); | ||
stack.popPose(); | ||
} | ||
} |