2015-08-23 23:41:46 +02:00
|
|
|
package ellpeck.actuallyadditions.blocks.render;
|
|
|
|
|
|
|
|
import ellpeck.actuallyadditions.gadget.cloud.ISmileyCloudEasterEgg;
|
|
|
|
import ellpeck.actuallyadditions.gadget.cloud.SmileyCloudEasterEggs;
|
|
|
|
import ellpeck.actuallyadditions.tile.TileEntitySmileyCloud;
|
2015-08-24 17:57:11 +02:00
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-08-24 20:08:14 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.OpenGlHelper;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
2015-08-23 23:41:46 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
public class RenderSmileyCloud extends RenderTileEntity{
|
|
|
|
|
|
|
|
public RenderSmileyCloud(ModelBaseAA model){
|
|
|
|
super(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5){
|
2015-08-24 20:08:14 +02:00
|
|
|
if(!(tile instanceof TileEntitySmileyCloud)) return;
|
|
|
|
TileEntitySmileyCloud theCloud = (TileEntitySmileyCloud)tile;
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
{
|
|
|
|
GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glTranslatef(0.0F, -2.0F, 0.0F);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
{
|
|
|
|
if(theModel.doesRotate()){
|
|
|
|
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
|
|
|
if(meta == 0) GL11.glRotatef(180F, 0F, 1F, 0F);
|
|
|
|
if(meta == 1) GL11.glRotatef(90F, 0F, 1F, 0F);
|
|
|
|
if(meta == 3) GL11.glRotatef(270F, 0F, 1F, 0F);
|
|
|
|
}
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
this.bindTexture(resLoc);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
theModel.render(0.0625F);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
if(theCloud.name != null && !theCloud.name.isEmpty()){
|
|
|
|
for(ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.cloudStuff){
|
|
|
|
boolean canBreak = false;
|
|
|
|
for(String triggerName : cloud.getTriggerNames()){
|
|
|
|
if(StringUtil.equalsToLowerCase(triggerName, theCloud.name)){
|
|
|
|
cloud.renderExtra(0.0625F);
|
|
|
|
canBreak = true;
|
|
|
|
break;
|
2015-08-24 17:57:11 +02:00
|
|
|
}
|
2015-08-24 20:08:14 +02:00
|
|
|
}
|
|
|
|
if(canBreak) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GL11.glPopMatrix();
|
2015-08-24 17:57:11 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
if(theCloud.name != null && !theCloud.name.isEmpty() && !Minecraft.getMinecraft().gameSettings.hideGUI){
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
{
|
|
|
|
GL11.glTranslatef(0F, 0.1F, 0F);
|
|
|
|
GL11.glRotatef(180F, 1F, 0F, 0F);
|
|
|
|
GL11.glRotatef(180F, 0F, 1F, 0F);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:08:14 +02:00
|
|
|
GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
|
|
|
|
GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
|
|
|
|
float f = 1.6F;
|
|
|
|
float f1 = 0.016666668F*f;
|
|
|
|
GL11.glScalef(-f1, -f1, f1);
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glTranslatef(0.0F, 0F/f1, 0.0F);
|
|
|
|
GL11.glDepthMask(false);
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
int i = Minecraft.getMinecraft().fontRenderer.getStringWidth(theCloud.name)/2;
|
|
|
|
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
|
|
|
|
tessellator.addVertex(-i-1, -1.0D, 0.0D);
|
|
|
|
tessellator.addVertex(-i-1, 8.0D, 0.0D);
|
|
|
|
tessellator.addVertex(i+1, 8.0D, 0.0D);
|
|
|
|
tessellator.addVertex(i+1, -1.0D, 0.0D);
|
|
|
|
tessellator.draw();
|
|
|
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
|
|
|
GL11.glDepthMask(true);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2015-08-24 20:15:24 +02:00
|
|
|
Minecraft.getMinecraft().fontRenderer.drawString(theCloud.name, -Minecraft.getMinecraft().fontRenderer.getStringWidth(theCloud.name)/2, 0, StringUtil.DECIMAL_COLOR_WHITE);
|
2015-08-24 20:08:14 +02:00
|
|
|
|
|
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glDisable(GL11.GL_BLEND);
|
|
|
|
GL11.glColor4f(1F, 1F, 1F, 1F);
|
|
|
|
GL11.glScalef(1F/-f1, 1F/-f1, 1F/f1);
|
2015-08-23 23:41:46 +02:00
|
|
|
}
|
2015-08-24 20:08:14 +02:00
|
|
|
GL11.glPopMatrix();
|
2015-08-23 23:41:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|