Jump to content

Recommended Posts

Posted (edited)

Good days 
i dont speak english soo i  gonna try to explain the idea 
i need help whit this i cannot figure out by myself 
the target i wanna reach is to create a bullet hole entity and this entity can hold explosives inside if the entity hole has explosives it has to glow a red light 
well i alredy create that in a mod i was making for 1.12 but never release i fond the assets part of the code and some youtube videos from that age 
 

Spoiler

package mercenarymod.entidades.entidadAgujero;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)


//public class RenderParachute extends Render<EntityParachute>
//public class renderAgujero<T extends entidadAgujero> extends Render<T>
public class renderAgujero<T extends entidadAgujero> extends Render<T>
{
    
    // boolean renderOutlines = false;
    
    public renderAgujero()
    {
          super( Minecraft.getMinecraft().getRenderManager() );
    }
    
    public renderAgujero(RenderManager renderManagerIn)
    {
        super( Minecraft.getMinecraft().getRenderManager() );
        //super(renderManagerIn);
    }

    //public static final ResourceLocation RES_SPECTRAL_ARROW = new ResourceLocation("textures/entity/projectiles/spectral_arrow.png");
    public static final ResourceLocation RES_AGUJERO = new ResourceLocation("modmercenario:textures/entity/agujeros.png"); //agujeros
                                                                             
                                                                            
    
    @Override
    protected ResourceLocation getEntityTexture(T entity) {
        
        return  RES_AGUJERO;//RES_SPECTRAL_ARROW;//RES_AGUJERO;
    }
    
    
    /**
     * Renders the desired {@code T} type Entity.
     */
    @Override
    public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks)
    {
        
        this.bindEntityTexture(entity);
        
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableLighting();
        GlStateManager.pushMatrix();
        
        GlStateManager.translate((float)x, (float)y, (float)z);
        GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);
        Tessellator tessellator = Tessellator.getInstance();
        VertexBuffer vertexbuffer = tessellator.getBuffer();
        int i = 0;
        float f = 0.0F;
        float f1 = 0.5F;
        float f2 = (float)(0 + i * 10) / 32.0F;
        float f3 = (float)(5 + i * 10) / 32.0F;
        float f4 = 0.0F;
        float f5 = 0.15625F;
        float f6 = (float)(5 + i * 10) / 32.0F;
        float f7 = (float)(10 + i * 10) / 32.0F;
        float f8 = 0.05625F;
        GlStateManager.enableRescaleNormal();

        int tipo = entity.getTipo();
        
        boolean glow = (tipo > 6)? true: false;
        
        float rot = 0.0F;
                
        //if (glow)
        {
        rot = (entity.getEntityId() % 360) + 0.0F;
        }
    
        GlStateManager.rotate(rot, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(f8, f8, f8);
        GlStateManager.translate(-4.0F, 0.0F, 0.0F);

        
        

        int tipoA = ( tipo > 6 && tipo < 13 )? 1 : ( (tipo > 12)? 6:tipo) ;
        
        tipoA = ( tipoA < 0  )?  0:tipoA;
        tipoA = ( tipoA > 15 )? 15:tipoA;
                
        int dx = (tipoA % 4);
        int dy = (tipoA / 4);
        
        double xi = 0.25D * dx;
        double xo = 0.25D * (dx + 1);
        
        double yi = 0.25D * dy;
        double yo = 0.25D * (dy + 1);

        double f9 = 3.9D;
        //anterior
        GlStateManager.glNormal3f(f8, 0.0F, 0.0F);
        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
        vertexbuffer.pos(f9, -2.0D, -2.0D).tex(    xi, yo).endVertex();
        vertexbuffer.pos(f9, -2.0D, 2.0D).tex(    xo, yo).endVertex();
        vertexbuffer.pos(f9, 2.0D, 2.0D).tex(    xo, yi).endVertex();
        vertexbuffer.pos(f9, 2.0D, -2.0D).tex(    xi, yi).endVertex();
        tessellator.draw();
        
        
        f9 = 4.1D;
        
        //posterior
        GlStateManager.glNormal3f(-f8, 0.0F, 0.0F);
        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
        vertexbuffer.pos(f9, -2.0D, 2.0D).tex(    xo, yo).endVertex();
        vertexbuffer.pos(f9, -2.0D, -2.0D).tex(    xi, yo).endVertex();
        vertexbuffer.pos(f9, 2.0D, -2.0D).tex(    xi, yi).endVertex();
        vertexbuffer.pos(f9, 2.0D, 2.0D).tex(    xo, yi).endVertex();
        tessellator.draw();

        
        GlStateManager.disableRescaleNormal();
        GlStateManager.enableLighting();
        //GlStateManager.popMatrix();

        
        
        //·······························································································
        if (glow)
        {
        
            //GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            
            GlStateManager.enableBlend();
            GlStateManager.disableAlpha();
            GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE);

            GlStateManager.depthMask(true);
            
           // GlStateManager.pushMatrix();

            int ii = 61680;
            int j = ii % 65536;
            int k = ii / 65536;
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
            
            int tipoB = tipo;
            
            if ( tipo > 6 && tipo < 10 )
            {
            int t = ( entity.getUpdateTick() % 20 ) / 5;
            
            switch (t)
            {
            default     :tipoB = 1    ;break;
            case 1         :tipoB = 7    ;break;
            case 2        :tipoB = 8    ;break;
            case 3         :tipoB = 9    ;break;
            }
            
            }
                    
            if ( tipo > 9 && tipo < 13 )
            {
            int t = ( entity.getUpdateTick() % 20 ) / 5;
            
            switch (t)
            {
            default     :tipoB = 1    ;break;
            case 1         :tipoB = 10    ;break;
            case 2        :tipoB = 11    ;break;
            case 3         :tipoB = 12    ;break;
            }
            
            }
            
            if ( tipo > 12 )
            {
                tipoB = tipo    ;
            }
                      
            
            tipoB = ( tipoB < 0  )?  0:tipoB;
            tipoB = ( tipoB > 15 )? 15:tipoB;
                    
            dx = (tipoB % 4);
            dy = (tipoB / 4);
            
            xi = 0.25D * dx;
            xo = 0.25D * (dx + 1);
            
            yi = 0.25D * dy;
            yo = 0.25D * (dy + 1);
            
            f9 = 3.8D;
            //anterior
            GlStateManager.glNormal3f(f8, 0.0F, 0.0F);
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
            vertexbuffer.pos(f9, -2.0D, -2.0D).tex(    xi, yo).endVertex();
            vertexbuffer.pos(f9, -2.0D, 2.0D).tex(    xo, yo).endVertex();
            vertexbuffer.pos(f9, 2.0D, 2.0D).tex(    xo, yi).endVertex();
            vertexbuffer.pos(f9, 2.0D, -2.0D).tex(    xi, yi).endVertex();
            tessellator.draw();
            
            
            f9 = 4.2D;
            //posterior
            GlStateManager.glNormal3f(-f8, 0.0F, 0.0F);
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
            vertexbuffer.pos(f9, -2.0D, 2.0D).tex(    xo, yo).endVertex();
            vertexbuffer.pos(f9, -2.0D, -2.0D).tex(    xi, yo).endVertex();
            vertexbuffer.pos(f9, 2.0D, -2.0D).tex(    xi, yi).endVertex();
            vertexbuffer.pos(f9, 2.0D, 2.0D).tex(    xo, yi).endVertex();
            tessellator.draw();
            
            i = 64000;
            j = i % 65536;
            k = i / 65536;
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
            
            GlStateManager.disableBlend();
            GlStateManager.enableAlpha();
           // GlStateManager.popMatrix();
        }
        
        
        GlStateManager.popMatrix();
        super.doRender(entity, x, y, z, entityYaw, partialTicks);
    }

}


this old renderer dotn works anymore as minecraft code has change soo mutch 

old youtube video  notice that it sets a hole entity in the world and some hole entityes has that glowing red circles inside 



 

based on the arrow tutorial  i made a entity and a renderer  whit the shape of a full cube and make it soo it matches the size and position of the on ground block 
this is 1.16.5 code

rendercube-edit.gif


X (first step done)
know i need to render a small glowing red square  on the back side of the cube the south face but 
 OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);    just trow errors 
soo iwas looking into spidy and enderman renderers to understand how the eyes glow  is a second renderer and get lost on that 


###############################################################################

i hope you could understand what im trying to say 
agujero.png

i gona try again i want to create a renderer using this tree holes texture but i want the red parts to glow in the dark only the red parts 

but just declaring the red parts as dedicated vertex face  
        // el que se ve desde adelante x
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, -10, 0.00F, 0.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, 10, 1.00F, 0.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, 10, 1.00F, 1.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, -10, 0.00F, 1.00F, -1, 0, 0, p_225623_6_);

and conjure over it the moderm equivalent of 
           OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
            
            GlStateManager.disableBlend();
            GlStateManager.enableAlpha();
to make it glow 
 

Spoiler

package baseMmod.entity;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.layers.SpiderEyesLayer;
import net.minecraft.client.renderer.model.ModelHelper;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Matrix3f;
import net.minecraft.util.math.vector.Matrix4f;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public abstract class panel_model<T extends Entity> extends EntityRenderer<T> {
    public panel_model(EntityRendererManager p_i46193_1_) {
        super(p_i46193_1_);
        
        //this.addLayer(new SpiderEyesLayer<>(this));
        
        
    }

    // public void doRender(T entity, double x, double y, double z, float entityYaw,
    // float partialTicks)

    /*
       public void render(MatrixStack p_225628_1_, IRenderTypeBuffer p_225628_2_, int p_225628_3_, T p_225628_4_, float p_225628_5_, float p_225628_6_, float p_225628_7_, float p_225628_8_, float p_225628_9_, float p_225628_10_) {
              IVertexBuilder ivertexbuilder = irendertypebuffer.getBuffer(this.renderType());
              this.getParentModel().renderToBuffer(p_225628_1_, ivertexbuilder, 15728640, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, 1.0F);
           }
    */
       
    public void render(T entity, float p_225623_2_, float p_225623_3_, MatrixStack matrixstack, IRenderTypeBuffer irendertypebuffer, int p_225623_6_) {

        // System.out.println( String.format("[entity] [%1$s] [%2$s] [matrix] [Buffer]
        // [%3$s]", p_225623_2_, p_225623_3_ , p_225623_6_) );

        int tick = entity.tickCount;
        
        matrixstack.pushPose();
        matrixstack.mulPose(Vector3f.YP.rotationDegrees(MathHelper.lerp(p_225623_3_, entity.yRotO, entity.yRot) - 90.0F));
        matrixstack.mulPose(Vector3f.ZP.rotationDegrees(MathHelper.lerp(p_225623_3_, entity.xRotO, entity.xRot)));
        int i = 0;
        float f = 0.0F;
        float f1 = 0.5F;
        float f2 = 0.0F;
        float f3 = 0.15625F;
        float f4 = 0.0F;
        float f5 = 0.15625F;
        float f6 = 0.15625F;
        float f7 = 0.3125F;
        float f8 = 0.05625F;
        float f9 = 0.0F;// (float)entity.shakeTime - p_225623_3_;
        if (f9 > 0.0F) {
            float f10 = -MathHelper.sin(f9 * 3.0F) * f9;
            matrixstack.mulPose(Vector3f.ZP.rotationDegrees(f10));
        }

        matrixstack.mulPose(Vector3f.XP.rotationDegrees(0.0F));// rotation del modelo

        float scale = 0.05F;
        matrixstack.scale(scale, scale, scale);
        matrixstack.translate(0.0D, 0.0D, 0.0D);
        IVertexBuilder ivertexbuilder = irendertypebuffer
                .getBuffer(RenderType.entityCutout(this.getTextureLocation(entity)));
        MatrixStack.Entry matrixstack$entry = matrixstack.last();
        Matrix4f matrix4f = matrixstack$entry.pose();
        Matrix3f matrix3f = matrixstack$entry.normal();

        // el que se desde atraz x

        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, -10, -10, 0.00F, 1.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, -10, 10, 1.00F, 1.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, 10, 10, 1.00F, 0.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, 10, -10, 0.00F, 0.00F, -1, 0, 0, p_225623_6_);

        // el que se ve desde adelante x
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, -10, 0.00F, 0.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, 10, 1.00F, 0.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, 10, 1.00F, 1.00F, -1, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, -10, 0.00F, 1.00F, -1, 0, 0, p_225623_6_);

        // el que se ve desde arriba y
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, 10, 1.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, -10, 0.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, 10, -10, 0.00F, 1.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, 10, 10, 1.00F, 1.00F, 0, 0, 0, p_225623_6_);

        // el que se ve desde abajo y
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, -10, 0.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, 10, 1.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, -10, 10, 1.00F, 1.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, -10, -10, 0.00F, 1.00F, 0, 0, 0, p_225623_6_);

        // el que se ve desde izquierda east z
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, -10, -10, 1.00F, 1.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, 10, -10, 1.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, -10, 0.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, -10, 0.00F, 1.00F, 0, 0, 0, p_225623_6_);

        // el que se ve desde derecha west z
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, -10, 10, 1.00F, 1.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, 10, 10, 10, 1.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, 10, 10, 0.00F, 0.00F, 0, 0, 0, p_225623_6_);
        this.vertex(matrix4f, matrix3f, ivertexbuilder, -10, -10, 10, 0.00F, 1.00F, 0, 0, 0, p_225623_6_);
        
        ModelHelper.setLightmapTextureCoords(ModelHelper.lightmapTexUnit, (float)j, (float)k);
        
        

        matrixstack.popPose();
        super.render(entity, p_225623_2_, p_225623_3_, matrixstack, irendertypebuffer, p_225623_6_);
    }

    public void vertex(Matrix4f p_229039_1_, Matrix3f p_229039_2_, IVertexBuilder p_229039_3_, int p_229039_4_,
            int p_229039_5_, int p_229039_6_, float p_229039_7_, float p_229039_8_, int p_229039_9_, int p_229039_10_,
            int p_229039_11_, int p_229039_12_) {
        p_229039_3_.vertex(p_229039_1_, (float) p_229039_4_, (float) p_229039_5_, (float) p_229039_6_)
                .color(255, 255, 255, 255).uv(p_229039_7_, p_229039_8_).overlayCoords(OverlayTexture.NO_OVERLAY)
                .uv2(p_229039_12_).normal(p_229039_2_, (float) p_229039_9_, (float) p_229039_11_, (float) p_229039_10_)
                .endVertex();
    }
}


Thanks for your time 
 









 

Edited by perromercenary00
Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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