From e71d6535c7f0b5ae807b91facc2023e776b3e991 Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Sun, 2 Mar 2014 21:23:24 +0000 Subject: [PATCH] Work on getting the pylons to render properly, looking pretty good. --- .../botania/client/model/ModelPylon.java | 4 +- .../client/render/tile/RenderTilePylon.java | 39 +++++++++++++++++-- .../botania/common/block/tile/TilePylon.java | 23 +++++++++++ 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/MODSRC/vazkii/botania/client/model/ModelPylon.java b/MODSRC/vazkii/botania/client/model/ModelPylon.java index fb21a60ec..871064c9a 100644 --- a/MODSRC/vazkii/botania/client/model/ModelPylon.java +++ b/MODSRC/vazkii/botania/client/model/ModelPylon.java @@ -34,8 +34,8 @@ public class ModelPylon extends ModelBase { ModelRenderer outside8; public ModelPylon() { - textureWidth = 256; - textureHeight = 128; + textureWidth = 64; + textureHeight = 32; crystal1 = new ModelRenderer(this, 0, 0); crystal1.addBox(-1.5F, -7F, -1F, 3, 7, 2); diff --git a/MODSRC/vazkii/botania/client/render/tile/RenderTilePylon.java b/MODSRC/vazkii/botania/client/render/tile/RenderTilePylon.java index 88ee51f03..d75f0563e 100644 --- a/MODSRC/vazkii/botania/client/render/tile/RenderTilePylon.java +++ b/MODSRC/vazkii/botania/client/render/tile/RenderTilePylon.java @@ -11,7 +11,10 @@ */ package vazkii.botania.client.render.tile; +import java.util.Random; + import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -24,7 +27,7 @@ import vazkii.botania.client.model.ModelPylon; public class RenderTilePylon extends TileEntitySpecialRenderer { - private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_POOL); + private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_PYLON); ModelPylon model = new ModelPylon(); @Override @@ -35,11 +38,39 @@ public class RenderTilePylon extends TileEntitySpecialRenderer { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); - - GL11.glTranslated(d0 + 0.5, d1 + 2.0, d2 + 0.5); + int worldTime = (int) (tileentity.worldObj == null ? 0 : tileentity.worldObj.getTotalWorldTime()); + + if(tileentity != null) + worldTime += new Random(tileentity.xCoord ^ tileentity.yCoord ^ tileentity.zCoord).nextInt(360); + + GL11.glTranslated(d0 + 0.5, d1 + 2.2, d2 + 0.5); GL11.glScalef(1F, -1.5F, -1F); - model.renderCrystal(); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + + GL11.glPushMatrix(); + GL11.glRotatef(worldTime * 1.5F, 0F, 1F, 0F); model.renderRing(); + GL11.glPopMatrix(); + + GL11.glPushMatrix(); + GL11.glTranslated(0D, Math.sin((double) worldTime / 20D) / 17.5, 0D); + GL11.glRotatef(-worldTime, 0F, 1F, 0F); + GL11.glDisable(GL11.GL_CULL_FACE); + model.renderCrystal(); + + GL11.glColor4f(1F, 1F, 1F, 1F); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + double alpha = Math.sin((double) worldTime / 20D) / 2D + 0.5; + GL11.glColor4d(1D, 1D, 1D, alpha + 0.183F); + GL11.glScalef(1.1F, 1.1F, 1.1F); + GL11.glTranslatef(0F, -0.09F, 0F); + model.renderCrystal(); + + GL11.glPopMatrix(); + GL11.glScalef(1F, -1.5F, -1F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL12.GL_RESCALE_NORMAL); diff --git a/MODSRC/vazkii/botania/common/block/tile/TilePylon.java b/MODSRC/vazkii/botania/common/block/tile/TilePylon.java index 108deaa19..92d663b7e 100644 --- a/MODSRC/vazkii/botania/common/block/tile/TilePylon.java +++ b/MODSRC/vazkii/botania/common/block/tile/TilePylon.java @@ -11,10 +11,33 @@ */ package vazkii.botania.common.block.tile; +import net.minecraft.entity.passive.EntitySheep; import net.minecraft.tileentity.TileEntity; +import vazkii.botania.common.Botania; +import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.core.helper.Vector3; public class TilePylon extends TileEntity { + boolean activated = true; // TODO + @Override + public void updateEntity() { + if(activated && worldObj.isRemote) { + Vector3 centerBlock = new Vector3(-500.5, 4.75 + (Math.random() - 0.5 * 0.25), -411.5); + + int id = worldObj.getBlockId(xCoord, yCoord - 1, zCoord); + if(id == ModBlocks.flower.blockID) { + int meta = worldObj.getBlockMetadata(xCoord, yCoord - 1, zCoord); + float[] color = EntitySheep.fleeceColorTable[meta]; + Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.25, yCoord - 0.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.25, color[0], color[1], color[2], (float) Math.random() / 3F, -0.04F); + + Vector3 ourCoords = Vector3.fromTileEntityCenter(this).add(0, 1 + (Math.random() - 0.5 * 0.25), 0); + Vector3 movementVector = centerBlock.sub(ourCoords).normalize().multiply(0.2); + Botania.proxy.wispFX(worldObj, xCoord + 0.5 + (Math.random() - 0.5) * 0.25, yCoord + 1.5, zCoord + 0.5 + (Math.random() - 0.5) * 0.25, color[0], color[1], color[2], (float) Math.random() / 8F, (float) movementVector.x, (float) movementVector.y, (float) movementVector.z); + + } + } + } }