From 4b0d5e4dfcc09c148d1f5c92f25b623e73f1be82 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 10 Mar 2017 23:21:17 +0100 Subject: [PATCH] make smiley clouds render special stuff --- .../mod/blocks/render/RenderSmileyCloud.java | 29 +++++++++++++++++-- .../mod/misc/special/RenderSpecial.java | 28 ++++++++++++------ 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java index c4b2acc43..44d645b08 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/render/RenderSmileyCloud.java @@ -12,6 +12,8 @@ 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.misc.special.RenderSpecial; +import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit; import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud; import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import net.minecraft.block.state.IBlockState; @@ -20,6 +22,8 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; +import java.util.Locale; + public class RenderSmileyCloud extends TileEntitySpecialRenderer{ @Override @@ -35,6 +39,8 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer{ theCloud.setStatus(theCloud.name != null && !theCloud.name.isEmpty() && theCloud.name.equals("Pink Fluffy Unicloud")); if(theCloud.name != null && !theCloud.name.isEmpty()){ + boolean renderedEaster = false; + easterEggs: for(ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF){ for(String triggerName : cloud.getTriggerNames()){ @@ -55,18 +61,35 @@ public class RenderSmileyCloud extends TileEntitySpecialRenderer{ } cloud.renderExtra(0.0625F); GlStateManager.popMatrix(); + + renderedEaster = true; break easterEggs; } } } } + + String nameLower = theCloud.name.toLowerCase(Locale.ROOT); + if(SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)){ + RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower); + if(render != null){ + GlStateManager.pushMatrix(); + GlStateManager.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F); + GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F); + GlStateManager.scale(0.75F, 0.75F, 0.75F); + render.render(); + GlStateManager.popMatrix(); + } + } } GlStateManager.popMatrix(); - if(theCloud.name != null && !theCloud.name.isEmpty() && !Minecraft.getMinecraft().gameSettings.hideGUI){ - AssetUtil.renderNameTag(theCloud.name, x+0.5F, y+1.5F, z+0.66); + Minecraft mc = Minecraft.getMinecraft(); + if(theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI){ + if(mc.thePlayer.getDistanceSq(tile.getPos()) <= 36){ + AssetUtil.renderNameTag(theCloud.name, x+0.5F, y+1.5F, z+0.5F); + } } - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java index 96a927030..8489edfe4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/special/RenderSpecial.java @@ -29,19 +29,30 @@ public class RenderSpecial{ } public void render(EntityPlayer player, float partialTicks){ + if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){ + return; + } + + GlStateManager.pushMatrix(); + + Vec3d currentPos = Minecraft.getMinecraft().thePlayer.getPositionEyes(partialTicks); + Vec3d playerPos = player.getPositionEyes(partialTicks); + GlStateManager.translate(playerPos.xCoord-currentPos.xCoord, playerPos.yCoord-currentPos.yCoord, playerPos.zCoord-currentPos.zCoord); + GlStateManager.translate(0D, 2.375D-(player.isSneaking() ? 0.125D : 0D), 0D); + + this.render(); + GlStateManager.popMatrix(); + } + + public void render(){ if(StackUtil.isValid(this.theThingToRender)){ - if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){ - return; - } boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock; GlStateManager.pushMatrix(); - Vec3d currentPos = Minecraft.getMinecraft().thePlayer.getPositionEyes(partialTicks); - Vec3d playerPos = player.getPositionEyes(partialTicks); - GlStateManager.translate(playerPos.xCoord-currentPos.xCoord, playerPos.yCoord-currentPos.yCoord, playerPos.zCoord-currentPos.zCoord); - - GlStateManager.translate(0D, 2.375D-(player.isSneaking() ? 0.125D : 0D)+(isBlock ? 0D : 0.1875D), 0D); + if(isBlock){ + GlStateManager.translate(0D, -0.1875D, 0D); + } GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F); float size = isBlock ? 0.5F : 0.4F; @@ -68,5 +79,4 @@ public class RenderSpecial{ GlStateManager.popMatrix(); } } - }