mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
115 lines
4.3 KiB
Java
115 lines
4.3 KiB
Java
/**
|
|
* This class was created by <Vazkii>. It's distributed as
|
|
* part of the Botania Mod. Get the Source Code in github:
|
|
* https://github.com/Vazkii/Botania
|
|
*
|
|
* Botania is Open Source and distributed under the
|
|
* Botania License: http://botaniamod.net/license.php
|
|
*
|
|
* File Created @ [Oct 24, 2015, 3:51:35 PM (GMT)]
|
|
*/
|
|
package vazkii.botania.client.render.tile;
|
|
|
|
import java.awt.Color;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
import net.minecraft.client.renderer.ItemRenderer;
|
|
import net.minecraft.client.renderer.OpenGlHelper;
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
import net.minecraft.client.renderer.texture.TextureMap;
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
import vazkii.botania.api.item.IAvatarWieldable;
|
|
import vazkii.botania.client.core.handler.ClientTickHandler;
|
|
import vazkii.botania.client.lib.LibResources;
|
|
import vazkii.botania.client.model.ModelAvatar;
|
|
import vazkii.botania.common.block.tile.TileAvatar;
|
|
|
|
public class RenderTileAvatar extends TileEntitySpecialRenderer {
|
|
|
|
private static final float[] ROTATIONS = new float[] {
|
|
180F, 0F, 90F, 270F
|
|
};
|
|
|
|
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_AVATAR);
|
|
private static final ModelAvatar model = new ModelAvatar();
|
|
|
|
@Override
|
|
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks, int digProgress) {
|
|
TileAvatar avatar = (TileAvatar) tileentity;
|
|
|
|
GlStateManager.pushMatrix();
|
|
GlStateManager.enableRescaleNormal();
|
|
GlStateManager.color(1F, 1F, 1F, 1F);
|
|
GlStateManager.translate(d0, d1, d2);
|
|
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
|
|
int meta = avatar.getWorld() != null ? avatar.getBlockMetadata() : 0;
|
|
|
|
GlStateManager.translate(0.5F, 1.6F, 0.5F);
|
|
GlStateManager.scale(1F, -1F, -1F);
|
|
GlStateManager.rotate(ROTATIONS[Math.max(Math.min(ROTATIONS.length - 1, meta - 2), 0)], 0F, 1F, 0F);
|
|
model.render();
|
|
|
|
ItemStack stack = avatar.getStackInSlot(0);
|
|
if(stack != null) {
|
|
GlStateManager.pushMatrix();
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
|
float s = 0.4F;
|
|
GlStateManager.scale(s, s, s);
|
|
GlStateManager.rotate(90F, 0F, 1F, 0F);
|
|
GlStateManager.rotate(180F, 0F, 0F, 1F);
|
|
GlStateManager.translate(-1.2F, -3.5F, -0.65F);
|
|
GlStateManager.rotate(20F, 0F, 0F, 1F);
|
|
|
|
// Minecraft.getMinecraft().getRenderItem().renderItemModel(stack); // todo 1.8
|
|
// int renderPass = 0;
|
|
// do {
|
|
// IIcon icon = stack.getItem().getIcon(stack, renderPass);
|
|
// if(icon != null) {
|
|
// Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
|
|
// GlStateManager.color((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
|
|
// float f = icon.getMinU();
|
|
// float f1 = icon.getMaxU();
|
|
// float f2 = icon.getMinV();
|
|
// float f3 = icon.getMaxV();
|
|
// ItemRenderer.renderItemIn2D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F);
|
|
// GlStateManager.color(1F, 1F, 1F);
|
|
// }
|
|
// renderPass++;
|
|
// } while(renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
|
|
GlStateManager.popMatrix();
|
|
|
|
IAvatarWieldable wieldable = (IAvatarWieldable) stack.getItem();
|
|
Minecraft.getMinecraft().renderEngine.bindTexture(wieldable.getOverlayResource(avatar, stack));
|
|
s = 1.01F;
|
|
|
|
GlStateManager.pushMatrix();
|
|
GlStateManager.enableBlend();
|
|
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
GlStateManager.scale(s, s, s);
|
|
GlStateManager.translate(0F, -0.01F, 0F);
|
|
int light = 15728880;
|
|
int lightmapX = light % 65536;
|
|
int lightmapY = light / 65536;
|
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
|
|
float alpha = (float) Math.sin(ClientTickHandler.ticksInGame / 20D) / 2F + 0.5F;
|
|
GlStateManager.color(1F, 1F, 1F, alpha + 0.183F);
|
|
model.render();
|
|
GlStateManager.popMatrix();
|
|
}
|
|
GlStateManager.color(1F, 1F, 1F);
|
|
GlStateManager.scale(1F, -1F, -1F);
|
|
GlStateManager.enableRescaleNormal();
|
|
GlStateManager.popMatrix();
|
|
}
|
|
|
|
}
|