2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2016-02-17 21:45:19 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
2016-11-16 20:31:16 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
2016-07-04 20:15:41 +02:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-02-17 21:45:19 +01:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-11-29 13:17:45 +01:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
2016-02-17 21:45:19 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-12-18 17:28:29 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2016-12-18 17:28:29 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2019-05-02 09:10:29 +02:00
|
|
|
public class RenderReconstructorLens extends TileEntitySpecialRenderer<TileEntityAtomicReconstructor> {
|
2015-11-29 13:17:45 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void render(TileEntityAtomicReconstructor tile, double x, double y, double z, float par5, int par6, float f) {
|
|
|
|
if (tile == null) return;
|
2019-02-27 19:53:05 +01:00
|
|
|
|
|
|
|
ItemStack stack = tile.inv.getStackInSlot(0);
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.pushMatrix();
|
2019-05-02 09:10:29 +02:00
|
|
|
GlStateManager.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2016-07-04 20:15:41 +02:00
|
|
|
IBlockState state = tile.getWorld().getBlockState(tile.getPos());
|
|
|
|
int meta = state.getBlock().getMetaFromState(state);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (meta == 0) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.translate(0F, -0.5F, 0F);
|
|
|
|
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (meta == 1) {
|
|
|
|
GlStateManager.translate(0F, -1.5F - 0.5F / 16F, 0F);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.rotate(90F, 1F, 0F, 0F);
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (meta == 2) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.translate(0F, -1F, 0F);
|
|
|
|
GlStateManager.translate(0F, 0F, -0.5F);
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (meta == 3) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.translate(0F, -1F, 0F);
|
2019-05-02 09:10:29 +02:00
|
|
|
GlStateManager.translate(0F, 0F, 0.5F + 0.5F / 16F);
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (meta == 4) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.translate(0F, -1F, 0F);
|
2019-05-02 09:10:29 +02:00
|
|
|
GlStateManager.translate(0.5F + 0.5F / 16F, 0F, 0F);
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
if (meta == 5) {
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.translate(0F, -1F, 0F);
|
|
|
|
GlStateManager.translate(-0.5F, 0F, 0F);
|
|
|
|
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
|
|
|
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.scale(0.5F, 0.5F, 0.5F);
|
2016-01-08 23:36:35 +01:00
|
|
|
AssetUtil.renderItemInWorld(stack);
|
2015-11-29 13:17:45 +01:00
|
|
|
|
2016-01-08 15:21:05 +01:00
|
|
|
GlStateManager.popMatrix();
|
2016-02-17 21:45:19 +01:00
|
|
|
}
|
2015-11-29 13:17:45 +01:00
|
|
|
}
|
|
|
|
}
|