Jump to content

Recommended Posts

Posted

I've got this beam:

 

width=800 height=449https://dl.dropboxusercontent.com/u/184200482/img/beam_bug_ok.png[/img]

 

But if i look up (by the way a lose the view of the block) the beam stop rendering

 

width=800 height=449https://dl.dropboxusercontent.com/u/184200482/img/beam_bug_bad.png[/img]

 

My code

 

Block.class

package com.sackcastellon.treeoflife.block;

import java.util.Random;

import com.sackcastellon.treeoflife.TreeOfLife;
import com.sackcastellon.treeoflife.tileentity.TileEntityRoot;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;

public class BlockRoot extends BlockContainer
{
public BlockRoot()
{
	super(Material.wood);

	this.setCreativeTab(TreeOfLife.tabTol);
}

@Override
public TileEntity createNewTileEntity(World var1, int var2)
{
	return new TileEntityRoot();
}

@Override
public boolean isOpaqueCube()
{
	return false;
}

@Override
public IIcon getIcon(int side, int meta)
{
	return Blocks.glass.getIcon(side, meta);
}

@Override
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_,
		int p_149695_3_, int p_149695_4_, Block p_149695_5_) {
	// TODO Auto-generated method stub
	super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_,
			p_149695_5_);
}

@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_,
		int p_149650_3_) {
	// TODO Auto-generated method stub
	return super.getItemDropped(p_149650_1_, p_149650_2_, p_149650_3_);
}

@Override
public int damageDropped(int p_149692_1_) {
	// TODO Auto-generated method stub
	return super.damageDropped(p_149692_1_);
}

@Override
public void registerBlockIcons(IIconRegister p_149651_1_) {
	// TODO Auto-generated method stub
	super.registerBlockIcons(p_149651_1_);
}

@Override
public int quantityDropped(int meta, int fortune, Random random) {
	// TODO Auto-generated method stub
	return super.quantityDropped(meta, fortune, random);
}

@Override
public boolean canSustainPlant(IBlockAccess world, int x, int y, int z,
		ForgeDirection direction, IPlantable plantable) {
	// TODO Auto-generated method stub
	return super.canSustainPlant(world, x, y, z, direction, plantable);
}

@Override
public void onNeighborChange(IBlockAccess world, int x, int y, int z,
		int tileX, int tileY, int tileZ) {
	// TODO Auto-generated method stub
	super.onNeighborChange(world, x, y, z, tileX, tileY, tileZ);
}

}

 

TileEntity.class

package com.sackcastellon.treeoflife.tileentity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.tileentity.TileEntity;

public class TileEntityRoot extends TileEntity {

    private boolean field_146015_k = true;
    
    @SideOnly(Side.CLIENT)
private long field_146016_i;
    @SideOnly(Side.CLIENT)
    private float field_146014_j;
    
    @SideOnly(Side.CLIENT)
    public double getMaxRenderDistanceSquared()
    {
        return 65536.0D;
    }

@SideOnly(Side.CLIENT)
    public float func_146002_i()
    {
        if (!this.field_146015_k )
        {
            return 0.0F;
        }
        else
        {
            int i = (int)(this.worldObj.getTotalWorldTime() - this.field_146016_i);
            this.field_146016_i = this.worldObj.getTotalWorldTime();

            if (i > 1)
            {
                this.field_146014_j -= (float)i / 40.0F;

                if (this.field_146014_j < 0.0F)
                {
                    this.field_146014_j = 0.0F;
                }
            }

            this.field_146014_j += 0.025F;

            if (this.field_146014_j > 1.0F)
            {
                this.field_146014_j = 1.0F;
            }

            return this.field_146014_j;
        }
    }

}

 

TileEntityRenderer.class

package com.sackcastellon.treeoflife.renderer;

import org.lwjgl.opengl.GL11;

import com.sackcastellon.treeoflife.tileentity.TileEntityRoot;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;

@SideOnly(Side.CLIENT)
public class TileEntityRootRenderer extends TileEntitySpecialRenderer
{
    private static final ResourceLocation field_147523_b = new ResourceLocation("textures/entity/beacon_beam.png");
    public void renderTileEntityAt(TileEntityRoot entity, double x, double y, double z, float p_147522_8_)
    {
        float f1 = entity.func_146002_i();
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);

        if (f1 > 0.0F)
        {
            Tessellator tessellator = Tessellator.instance;
            this.bindTexture(field_147523_b);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            OpenGlHelper.glBlendFunc(770, 1, 1, 0);
            float f2 = (float)entity.getWorldObj().getTotalWorldTime() + p_147522_8_;
            float f3 = -f2 * 0.2F - (float)MathHelper.floor_float(-f2 * 0.1F);
            byte b0 = 1;
            double d3 = (double)f2 * 0.025D * (1.0D - (double)(b0 & 1) * 2.5D);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA(255, 60, 200, 32);
            double d5 = (double)b0 * 0.2D;
            double d7 = 0.5D + Math.cos(d3 + 2.356194490192345D) * d5;
            double d9 = 0.5D + Math.sin(d3 + 2.356194490192345D) * d5;
            double d11 = 0.5D + Math.cos(d3 + (Math.PI / 4D)) * d5;
            double d13 = 0.5D + Math.sin(d3 + (Math.PI / 4D)) * d5;
            double d15 = 0.5D + Math.cos(d3 + 3.9269908169872414D) * d5;
            double d17 = 0.5D + Math.sin(d3 + 3.9269908169872414D) * d5;
            double d19 = 0.5D + Math.cos(d3 + 5.497787143782138D) * d5;
            double d21 = 0.5D + Math.sin(d3 + 5.497787143782138D) * d5;
            double d23 = (double)(256.0F * f1);
            double d25 = 0.0D;
            double d27 = 1.0D;
            double d28 = (double)(-1.0F + f3);
            double d29 = (double)(256.0F * f1) * (0.5D / d5) + d28;
            double bottom = 1.0D;
            tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d27, d29);
		tessellator.addVertexWithUV(x + d7, y + bottom, z + d9, d27, d28);
            tessellator.addVertexWithUV(x + d11, y + bottom, z + d13, d25, d28);
            tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d25, d29);
            tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d27, d29);
            tessellator.addVertexWithUV(x + d19, y + bottom, z + d21, d27, d28);
            tessellator.addVertexWithUV(x + d15, y + bottom, z + d17, d25, d28);
            tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d25, d29);
            tessellator.addVertexWithUV(x + d11, y + d23, z + d13, d27, d29);
            tessellator.addVertexWithUV(x + d11, y + bottom, z + d13, d27, d28);
            tessellator.addVertexWithUV(x + d19, y + bottom, z + d21, d25, d28);
            tessellator.addVertexWithUV(x + d19, y + d23, z + d21, d25, d29);
            tessellator.addVertexWithUV(x + d15, y + d23, z + d17, d27, d29);
            tessellator.addVertexWithUV(x + d15, y + bottom, z + d17, d27, d28);
            tessellator.addVertexWithUV(x + d7, y + bottom, z + d9, d25, d28);
            tessellator.addVertexWithUV(x + d7, y + d23, z + d9, d25, d29);
            tessellator.draw();
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
            GL11.glDepthMask(false);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA(255, 255, 255, 32);
            double d30 = 0.2D;
            double d4 = 0.2D;
            double d6 = 0.8D;
            double d8 = 0.2D;
            double d10 = 0.2D;
            double d12 = 0.8D;
            double d14 = 0.8D;
            double d16 = 0.8D;
            double d18 = (double)(256.0F * f1);
            double d20 = 0.0D;
            double d22 = 1.0D;
            double d24 = (double)(-1.0F + f3);
            double d26 = (double)(256.0F * f1) + d24;
            tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d22, d26);
            tessellator.addVertexWithUV(x + d30, y + bottom, z + d4, d22, d24);
            tessellator.addVertexWithUV(x + d6, y + bottom, z + d8, d20, d24);
            tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d20, d26);
            tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d22, d26);
            tessellator.addVertexWithUV(x + d14, y + bottom, z + d16, d22, d24);
            tessellator.addVertexWithUV(x + d10, y + bottom, z + d12, d20, d24);
            tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d20, d26);
            tessellator.addVertexWithUV(x + d6, y + d18, z + d8, d22, d26);
            tessellator.addVertexWithUV(x + d6, y + bottom, z + d8, d22, d24);
            tessellator.addVertexWithUV(x + d14, y + bottom, z + d16, d20, d24);
            tessellator.addVertexWithUV(x + d14, y + d18, z + d16, d20, d26);
            tessellator.addVertexWithUV(x + d10, y + d18, z + d12, d22, d26);
            tessellator.addVertexWithUV(x + d10, y + bottom, z + d12, d22, d24);
            tessellator.addVertexWithUV(x + d30, y + bottom, z + d4, d20, d24);
            tessellator.addVertexWithUV(x + d30, y + d18, z + d4, d20, d26);
            tessellator.draw();
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDepthMask(true);
        }

        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);
    }

    public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float par5)
    {
        this.renderTileEntityAt((TileEntityRoot)entity, x, y, z, par5);
    }
}

 

As always thanks for helping  ;)

Posted

Place a beacon next to it, that way you can compare the two to tell if your beacon disappearing is a bug in your code or a bug/issue with beacon beams in general.

Posted

You need to return the proper BoundingBox from getRenderBoundingBox in your TE (look at the method to see what it returns for TileEntityBeacon).

 

Thank you, that was the problem. Just added this, and now it works:

 

@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
	return INFINITE_EXTENT_AABB;
}

 


 

Place a beacon next to it, that way you can compare the two to tell if your beacon disappearing is a bug in your code or a bug/issue with beacon beams in general.

 

That was the first thing i thought, anyway thanks  ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.