Rewrite the SmileyCloud Renderer

This commit is contained in:
canitzp 2016-02-17 23:15:56 +01:00
parent 0600c56355
commit 57c37cb900
7 changed files with 521 additions and 94 deletions

View file

@ -38,7 +38,7 @@ import java.util.Random;
public class BlockSmileyCloud extends BlockContainerBase{
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 3);
private static final PropertyInteger META = PropertyInteger.create("meta", 0, 7);
public BlockSmileyCloud(String name){
super(Material.cloth, name);

View file

@ -10,28 +10,24 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
import de.ellpeck.actuallyadditions.mod.proxy.ClientProxy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
//TODO Fix Smiley Cloud
public class RenderSmileyCloud extends TileEntitySpecialRenderer{
private static final ResourceLocation resLocValentine = new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/blocks/models/modelPinkFluffyUnicloud.png");
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5, int partial){
if(!(tile instanceof TileEntitySmileyCloud)){
return;
}
TileEntitySmileyCloud theCloud = (TileEntitySmileyCloud)tile;
GlStateManager.pushMatrix();
{
if(tile instanceof TileEntitySmileyCloud){
TileEntitySmileyCloud theCloud = (TileEntitySmileyCloud)tile;
if(theCloud.flyHeight == 0){
theCloud.flyHeight = tile.getWorld().rand.nextInt(30)+30;
}
@ -42,6 +38,7 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer{
if(time-bobHeight >= theCloud.lastFlyHeight){
theCloud.lastFlyHeight = time;
}
GlStateManager.pushMatrix();
if(time-(bobHeight/2) >= theCloud.lastFlyHeight){
GlStateManager.translate(0, (time-theCloud.lastFlyHeight)/300, 0);
@ -50,98 +47,55 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer{
GlStateManager.translate(0, -(time-theCloud.lastFlyHeight)/300+(double)bobHeight/300, 0);
}
GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0.0F, -2F, 0.0F);
/*
GlStateManager.pushMatrix();
{
if(theModel.doesRotate()){
int meta = PosUtil.getMetadata(tile.getPos(), tile.getWorld());
if(meta == 0){
GlStateManager.rotate(180F, 0F, 1F, 0F);
}
if(meta == 1){
GlStateManager.rotate(90F, 0F, 1F, 0F);
}
if(meta == 3){
GlStateManager.rotate(270F, 0F, 1F, 0F);
}
}
if(ClientProxy.bulletForMyValentine || (theCloud.name != null && !theCloud.name.isEmpty() && theCloud.name.equals("Pink Fluffy Unicloud"))){
theCloud.setPinkAndFluffy();
} else {
theCloud.setNormalCloud();
}
if(ClientProxy.bulletForMyValentine || (theCloud.name != null && !theCloud.name.isEmpty() && theCloud.name.equals("Pink Fluffy Unicloud"))){
this.bindTexture(resLocValentine);
}
else{
this.bindTexture(resLoc);
}
theModel.render(0.0625F);
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;
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)){
GlStateManager.pushMatrix();
switch (PosUtil.getMetadata(theCloud.getPos(), theCloud.getWorld())){
case 1: {
GlStateManager.rotate(180, 0, 1, 0);
break;
}
case 2: {
GlStateManager.rotate(270, 0, 1, 0);
break;
}
case 3: {
GlStateManager.rotate(90, 0, 1, 0);
break;
}
}
}
if(canBreak){
cloud.renderExtra(0.0625F);
GlStateManager.popMatrix();
canBreak = true;
break;
}
}
if(canBreak){
break;
}
}
}
GlStateManager.popMatrix();
*/
if(theCloud.name != null && !theCloud.name.isEmpty() && !Minecraft.getMinecraft().gameSettings.hideGUI){
GlStateManager.pushMatrix();
{
GlStateManager.translate(0F, 0.1F, 0F);
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(180F, 0F, 1F, 0F);
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
float f = 1.6F;
float f1 = 0.016666668F*f;
GlStateManager.scale(-f1, -f1, f1);
GlStateManager.disableLighting();
GlStateManager.translate(0.0F, 0F/f1, 0.0F);
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
/*
//TODO Fix nameplate with Smiley Cloud
WorldRenderer tessy = Tessellator.getInstance().getWorldRenderer();
//GlStateManager.disable(GlStateManager.GL_TEXTURE_2D);
tessy.st
int i = Minecraft.getMinecraft().fontRendererObj.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();
GlStateManager.glEnable(GlStateManager.GL_TEXTURE_2D);
GlStateManager.depthMask(true);
Minecraft.getMinecraft().fontRendererObj.drawString(theCloud.name, -Minecraft.getMinecraft().fontRendererObj.getStringWidth(theCloud.name)/2, 0, StringUtil.DECIMAL_COLOR_WHITE);
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.color(1F, 1F, 1F, 1F);
GlStateManager.scale(1F/-f1, 1F/-f1, 1F/f1);
*/
}
GlStateManager.popMatrix();
if(theCloud.name != null && !theCloud.name.isEmpty() && !Minecraft.getMinecraft().gameSettings.hideGUI) {
AssetUtil.renderNameTag(theCloud.name, x + 0.5F, y + 1.3F, z + 0.66);
}
}
GlStateManager.popMatrix();
}
}

View file

@ -10,12 +10,14 @@
package de.ellpeck.actuallyadditions.mod.misc.cloud;
import de.ellpeck.actuallyadditions.mod.blocks.BlockSmileyCloud;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@ -378,11 +380,10 @@ public class SmileyCloudEasterEggs{
private static void renderHoldingItem(boolean leftHand, ItemStack stack){
GlStateManager.pushMatrix();
GlStateManager.rotate(180F, 0F, 0F, 1F);
GlStateManager.rotate(270F, 0F, 1F, 0F);
GlStateManager.rotate(90, 0, 1, 0);
GlStateManager.translate(0F, -1.5F, 0F);
GlStateManager.translate(-0.5F, 0.2F, leftHand ? 0.55F : -0.5F);
GlStateManager.translate(0, 0.2F, leftHand ? -0.5F : 0.55F);
GlStateManager.scale(0.75F, 0.75F, 0.75F);
AssetUtil.renderItemInWorld(stack);
@ -398,6 +399,9 @@ public class SmileyCloudEasterEggs{
GlStateManager.rotate(180F, 1F, 0F, 0F);
GlStateManager.rotate(rotation, 0F, 1F, 0F);
double boop = Minecraft.getSystemTime()/1000D;
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
AssetUtil.renderBlockInWorld(block, meta);
GlStateManager.enableLighting();

View file

@ -10,7 +10,9 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.blocks.BlockSmileyCloud;
import de.ellpeck.actuallyadditions.mod.network.gui.IStringReactor;
import de.ellpeck.actuallyadditions.mod.util.PosUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
@ -56,4 +58,15 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac
public void onTextReceived(String text, int textID, EntityPlayer player){
this.name = text;
}
public void setPinkAndFluffy(){
if(PosUtil.getMetadata(this.pos, this.worldObj) <= 3)
PosUtil.setMetadata(this.pos, this.worldObj, PosUtil.getMetadata(this.pos, this.worldObj) + 4, 2);
}
public void setNormalCloud(){
if(PosUtil.getMetadata(this.pos, this.worldObj) >= 4)
PosUtil.setMetadata(this.pos, this.worldObj, PosUtil.getMetadata(this.pos, this.worldObj) - 4, 2);
}
}

View file

@ -114,4 +114,45 @@ public class AssetUtil{
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
}
public static void renderNameTag(String tag, float x, float y, float z){
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
float f = 1.6F;
float f1 = 0.016666668F * f;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(-f1, -f1, f1);
GlStateManager.disableLighting();
GlStateManager.depthMask(false);
GlStateManager.disableDepth();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
int i = 0;
int j = fontrenderer.getStringWidth(tag) / 2;
GlStateManager.disableTexture2D();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
worldrenderer.pos((double) (-j - 1), (double) (-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double) (-j - 1), (double) (8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double) (j + 1), (double) (8 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
worldrenderer.pos((double) (j + 1), (double) (-1 + i), 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
tessellator.draw();
GlStateManager.enableTexture2D();
fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, 553648127);
GlStateManager.enableDepth();
GlStateManager.depthMask(true);
fontrenderer.drawString(tag, -fontrenderer.getStringWidth(tag) / 2, i, -1);
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.popMatrix();
}
public static void renderNameTag(String tag, double x, double y, double z){
renderNameTag(tag, (float) x, (float) y, (float) z);
}
}

View file

@ -3,6 +3,10 @@
"meta=0": { "model": "actuallyadditions:blockSmileyCloud", "y": 0 },
"meta=1": { "model": "actuallyadditions:blockSmileyCloud", "y": 180 },
"meta=2": { "model": "actuallyadditions:blockSmileyCloud", "y": -90 },
"meta=3": { "model": "actuallyadditions:blockSmileyCloud", "y": 90 }
"meta=3": { "model": "actuallyadditions:blockSmileyCloud", "y": 90 },
"meta=4": { "model": "actuallyadditions:blockSmileyCloudFluffy", "y": 0 },
"meta=5": { "model": "actuallyadditions:blockSmileyCloudFluffy", "y": 180 },
"meta=6": { "model": "actuallyadditions:blockSmileyCloudFluffy", "y": -90 },
"meta=7": { "model": "actuallyadditions:blockSmileyCloudFluffy", "y": 90 }
}
}

View file

@ -0,0 +1,411 @@
{
"ambientocclusion": false,
"textures": {
"particle": "actuallyadditions:blocks/models/modelPinkFluffyUnicloud",
"smileycloud": "actuallyadditions:blocks/models/modelPinkFluffyUnicloud"
},
"elements": [
{
"from": [2,0,3],
"to": [14,10,13],
"faces": {
"up": {
"uv": [5,0.75,8,3.25],
"texture": "#smileycloud"
},
"down": {
"uv": [3.5,1.5,6.5,4],
"texture": "#smileycloud"
},
"west": {
"uv": [0,2.5,2.5,5],
"texture": "#smileycloud"
},
"east": {
"uv": [8.5,2.5,11,5],
"texture": "#smileycloud"
},
"north": {
"uv": [2.75,0.25,5.75,2.75],
"texture": "#smileycloud"
},
"south": {
"uv": [5.25,0.25,8.25,2.75],
"texture": "#smileycloud"
}
}
},
{
"from": [1,1,4],
"to": [15,9,12],
"faces": {
"up": {
"uv": [6.5,2,7,4],
"texture": "#smileycloud"
},
"down": {
"uv": [1.25,2.75,1.75,4.75],
"texture": "#smileycloud"
},
"west": {
"uv": [13.75,2,15.75,4],
"texture": "#smileycloud"
},
"east": {
"uv": [11.25,2,13.25,4],
"texture": "#smileycloud"
},
"north": {
"uv": [13.75,2.75,14.25,4.75],
"texture": "#smileycloud"
},
"south": {
"uv": [6.25,1.5,6.75,3.5],
"texture": "#smileycloud"
}
}
},
{
"from": [0,2,5],
"to": [16,8,11],
"faces": {
"up": {
"uv": [12.75,2.25,13.25,3.75],
"texture": "#smileycloud"
},
"down": {
"uv": [13.5,2.5,14,4],
"texture": "#smileycloud"
},
"west": {
"uv": [13.25,4.25,14.75,5.75],
"texture": "#smileycloud"
},
"east": {
"uv": [11.5,4,13,5.5],
"texture": "#smileycloud"
},
"north": {
"uv": [13.75,3,14.25,4.5],
"texture": "#smileycloud"
},
"south": {
"uv": [6.25,1.75,6.75,3.25],
"texture": "#smileycloud"
}
}
},
{
"from": [3,9,4],
"to": [13,11,12],
"faces": {
"up": {
"uv": [0.25,2.75,2.75,4.75],
"texture": "#smileycloud"
},
"west": {
"uv": [4,3,6,3.5],
"texture": "#smileycloud"
},
"east": {
"uv": [0.75,10,2.75,10.5],
"texture": "#smileycloud"
},
"north": {
"uv": [8.75,7.5,11.25,8],
"texture": "#smileycloud"
},
"south": {
"uv": [7,5.75,9.5,6.25],
"texture": "#smileycloud"
}
}
},
{
"from": [4,10,5],
"to": [12,12,11],
"faces": {
"up": {
"uv": [8.75,7,10.75,8.5],
"texture": "#smileycloud"
},
"west": {
"uv": [8,5.5,9.5,6],
"texture": "#smileycloud"
},
"east": {
"uv": [7,5.5,8.5,6],
"texture": "#smileycloud"
},
"north": {
"uv": [12,5,14.25,5.5],
"texture": "#smileycloud"
},
"south": {
"uv": [3,3.25,5,3.75],
"texture": "#smileycloud"
}
}
},
{
"from": [3,1,12],
"to": [13,9,14],
"faces": {
"up": {
"uv": [11.75,3.75,14.25,4.25],
"texture": "#smileycloud"
},
"down": {
"uv": [7.75,3.25,10.25,3.75],
"texture": "#smileycloud"
},
"west": {
"uv": [13.25,2.5,13.75,4.5],
"texture": "#smileycloud"
},
"east": {
"uv": [6.75,2,7.25,4],
"texture": "#smileycloud"
},
"south": {
"uv": [3.75,1,6.25,3],
"texture": "#smileycloud"
}
}
},
{
"from": [4,2,13],
"to": [12,8,15],
"faces": {
"up": {
"uv": [2,6.25,4,6.75],
"texture": "#smileycloud"
},
"down": {
"uv": [9.5,7.75,11.5,8.25],
"texture": "#smileycloud"
},
"west": {
"uv": [14.75,2.25,15.25,3.75],
"texture": "#smileycloud"
},
"east": {
"uv": [13.25,2.5,13.75,4],
"texture": "#smileycloud"
},
"south": {
"uv": [3,5.5,5,7],
"texture": "#smileycloud"
}
}
},
{
"from": [5,3,14],
"to": [11,7,16],
"faces": {
"up": {
"uv": [7.25,5.5,8.75,6],
"texture": "#smileycloud"
},
"down": {
"uv": [12.75,3,14.25,3.5],
"texture": "#smileycloud"
},
"west": {
"uv": [8.25,7.25,8.75,8.25],
"texture": "#smileycloud"
},
"east": {
"uv": [10.75,7,11.25,8],
"texture": "#smileycloud"
},
"south": {
"uv": [12.5,2.75,14,3.75],
"texture": "#smileycloud"
}
}
},
{
"from": [5,3,2.5],
"to": [11,4,4.5],
"faces": {
"up": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"down": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"west": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"east": {
"uv": [4.5,10.25,4.75,10.5],
"texture": "#smileycloud"
},
"north": {
"uv": [4.25,10.25,4.75,10.5],
"texture": "#smileycloud"
}
}
},
{
"from": [11,4,2.5],
"to": [12,5,4.5],
"faces": {
"up": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"down": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"west": {
"uv": [4.5,10.25,4.75,10.5],
"texture": "#smileycloud"
},
"east": {
"uv": [4.5,10.25,4.75,10.5],
"texture": "#smileycloud"
},
"north": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
}
}
},
{
"from": [4,4,2.5],
"to": [5,5,4.5],
"faces": {
"up": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"down": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"west": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"east": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"north": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
}
}
},
{
"from": [9,7,2.75],
"to": [11,9,3.75],
"faces": {
"up": {
"uv": [7.75,9.25,8.25,9.5],
"texture": "#smileycloud"
},
"down": {
"uv": [7.75,9.5,8.25,9.75],
"texture": "#smileycloud"
},
"west": {
"uv": [7.75,9.25,8,9.75],
"texture": "#smileycloud"
},
"east": {
"uv": [7.75,9.25,8,9.75],
"texture": "#smileycloud"
},
"north": {
"uv": [7.75,9.25,8.25,9.75],
"texture": "#smileycloud"
}
}
},
{
"from": [5,7,2.75],
"to": [7,9,3.75],
"faces": {
"up": {
"uv": [7.75,9.5,8.25,9.75],
"texture": "#smileycloud"
},
"down": {
"uv": [7.75,9.5,8.25,9.75],
"texture": "#smileycloud"
},
"west": {
"uv": [8,9.25,8.25,9.75],
"texture": "#smileycloud"
},
"east": {
"uv": [7.75,9.25,8,9.75],
"texture": "#smileycloud"
},
"north": {
"uv": [7.75,9.25,8.25,9.75],
"texture": "#smileycloud"
}
}
},
{
"from": [9.5,7.5,2.5],
"to": [10.5,8.5,3.5],
"faces": {
"up": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"down": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"west": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"east": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"north": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
}
}
},
{
"from": [5.5,7.5,2.5],
"to": [6.5,8.5,3.5],
"faces": {
"up": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"down": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"west": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"east": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
},
"north": {
"uv": [4.25,10.25,4.5,10.5],
"texture": "#smileycloud"
}
}
}
]
}