2018-10-18 13:34:37 +02:00
|
|
|
package de.ellpeck.naturesaura.blocks.tiles.render;
|
|
|
|
|
2021-12-15 14:26:42 +01:00
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
2023-07-08 12:32:27 +02:00
|
|
|
import com.mojang.math.Axis;
|
2021-12-04 15:40:09 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar;
|
2020-01-29 18:18:41 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2021-12-15 14:26:42 +01:00
|
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
2023-07-08 12:32:27 +02:00
|
|
|
import net.minecraft.world.item.ItemDisplayContext;
|
2018-10-18 13:34:37 +02:00
|
|
|
|
2021-12-15 14:26:42 +01:00
|
|
|
public class RenderNatureAltar implements BlockEntityRenderer<BlockEntityNatureAltar> {
|
2020-01-21 21:04:44 +01:00
|
|
|
|
2021-12-15 16:24:53 +01:00
|
|
|
public RenderNatureAltar(BlockEntityRendererProvider.Context context) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-10-18 13:34:37 +02:00
|
|
|
@Override
|
2021-12-15 14:26:42 +01:00
|
|
|
public void render(BlockEntityNatureAltar tileEntityIn, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var stack = tileEntityIn.items.getStackInSlot(0);
|
2018-10-18 13:34:37 +02:00
|
|
|
if (!stack.isEmpty()) {
|
2021-12-15 14:26:42 +01:00
|
|
|
matrixStackIn.pushPose();
|
2021-12-15 16:30:22 +01:00
|
|
|
var time = tileEntityIn.bobTimer + partialTicks;
|
|
|
|
var bob = (float) Math.sin(time / 10F) * 0.1F;
|
2020-01-29 18:18:41 +01:00
|
|
|
matrixStackIn.translate(0.5F, 1.2F + bob, 0.5F);
|
2023-07-08 12:32:27 +02:00
|
|
|
matrixStackIn.mulPose(Axis.YP.rotationDegrees(time * 3 % 360));
|
|
|
|
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ItemDisplayContext.GROUND, combinedLightIn, combinedOverlayIn, matrixStackIn, bufferIn, tileEntityIn.getLevel(), 0);
|
2021-12-15 14:26:42 +01:00
|
|
|
matrixStackIn.popPose();
|
2018-10-18 13:34:37 +02:00
|
|
|
}
|
2020-01-29 18:18:41 +01:00
|
|
|
}
|
2018-10-18 13:34:37 +02:00
|
|
|
}
|