2015-11-29 13:17:45 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("RenderReconstructorLens.java") is part of the Actually Additions mod for Minecraft.
|
2015-11-29 13:17:45 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-11-29 13:17:45 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-11-29 13:17:45 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
2024-03-03 01:20:53 +01:00
|
|
|
import com.mojang.math.Axis;
|
2016-02-17 21:45:19 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
2024-03-09 22:35:28 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
2016-02-17 21:45:19 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.client.renderer.LevelRenderer;
|
|
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
|
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
|
|
|
import net.minecraft.core.Direction;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
2024-03-04 20:21:48 +01:00
|
|
|
import net.minecraft.world.phys.AABB;
|
2022-06-24 21:23:43 +02:00
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
public class ReconstructorRenderer implements BlockEntityRenderer<TileEntityAtomicReconstructor> {
|
2021-02-27 21:24:26 +01:00
|
|
|
|
2024-03-02 21:23:08 +01:00
|
|
|
public ReconstructorRenderer(BlockEntityRendererProvider.Context context) {
|
2021-02-27 21:24:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-03-02 21:23:08 +01:00
|
|
|
public void render(TileEntityAtomicReconstructor tile, float partialTicks, @Nonnull PoseStack matrices, @Nonnull MultiBufferSource buffer, int combinedLight, int combinedOverlay) {
|
2024-03-09 22:35:28 +01:00
|
|
|
if(!tile.getLevel().getBlockState(tile.getBlockPos()).is(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.get()))
|
|
|
|
return; //TODO crash bandage
|
2021-02-28 11:35:10 +01:00
|
|
|
ItemStack stack = tile.inv.getStackInSlot(0);
|
2022-06-24 21:23:43 +02:00
|
|
|
Direction direction = tile.getOrientation();
|
|
|
|
float rot = 360.0f - direction.getOpposite().toYRot(); //Sigh...
|
|
|
|
float pitch = 0;
|
|
|
|
if (direction == Direction.UP) {
|
|
|
|
pitch = 90;
|
|
|
|
} else if (direction == Direction.DOWN) {
|
|
|
|
pitch = -90;
|
|
|
|
}
|
2022-08-26 23:19:21 +02:00
|
|
|
|
2022-06-24 21:23:43 +02:00
|
|
|
if (stack.isEmpty() || !(stack.getItem() instanceof ILensItem)) {
|
2021-02-26 22:15:48 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
|
2021-08-22 17:09:06 +02:00
|
|
|
matrices.pushPose();
|
2021-02-28 11:35:10 +01:00
|
|
|
matrices.translate(0.5F, 0.5F, 0.5F);
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2024-03-03 01:20:53 +01:00
|
|
|
matrices.mulPose(Axis.YP.rotationDegrees(rot));
|
|
|
|
matrices.mulPose(Axis.XP.rotationDegrees(pitch));
|
2022-06-24 21:23:43 +02:00
|
|
|
|
|
|
|
matrices.translate(0.0F, 0.0F, -0.5F);
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2021-02-28 11:35:10 +01:00
|
|
|
matrices.scale(0.5F, 0.5F, 0.5F);
|
2024-03-02 21:23:08 +01:00
|
|
|
int lightColor = LevelRenderer.getLightColor(tile.getLevel(), tile.getPosition().relative(direction));
|
2022-06-24 21:23:43 +02:00
|
|
|
AssetUtil.renderItemInWorld(stack, lightColor, combinedOverlay, matrices, buffer);
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2021-08-22 17:09:06 +02:00
|
|
|
matrices.popPose();
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
2022-09-02 01:26:54 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldRenderOffScreen(TileEntityAtomicReconstructor tile) {
|
|
|
|
return tile.getProgress() > 0.0f;
|
|
|
|
}
|
2024-03-04 20:21:48 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public AABB getRenderBoundingBox(TileEntityAtomicReconstructor blockEntity) {
|
2024-03-12 18:49:18 +01:00
|
|
|
return BlockEntityRenderer.super.getRenderBoundingBox(blockEntity);
|
2024-03-04 20:21:48 +01:00
|
|
|
}
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|