Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.15.2] Custom Rendered Quads Not Layering With Clouds Properly


Recommended Posts

Posted (edited)

2021-05-03_20_59.36_small.thumb.png.2aae2a7eece7b4bcdf20a07d9317342a.png

 

Note the clouds being rendered in front of the beam texture.

I am accomplishing this by extending RenderType to add my own static RenderType provider method:

public static RenderType getBeam(ResourceLocation locationIn) {
        RenderState.TextureState renderstate$texturestate = new RenderState.TextureState(locationIn, false, false);
        return RenderType.makeType("beam", DefaultVertexFormats.ENTITY, 7, 256, false, true,
                RenderType.State
                        .getBuilder()
                        .texture(renderstate$texturestate)
                        .transparency(LIGHTNING_TRANSPARENCY)
                        .writeMask(COLOR_WRITE)
                        .fog(BLACK_FOG)
                        .cull(CULL_DISABLED)
                        .build(false));
}

 

Is there a way to get around this? Or should I just not be rendering translucent things willy nilly?

Edited by Woodside
clarification of issue in title
Link to post
Share on other sites

Actually it does not seem to have to do with the RenderType being transparent as even a fully opaque vanilla one still has clouds on top.

 

Here's the EntityRenderer class:

public class BeamAttackRenderer extends EntityRenderer<BeamAttackEntity>
{
    public static final ResourceLocation BEAM_TEXTURE = new ResourceLocation(CelticShift.MOD_ID, "textures/entity/lightning_beam.png");
    private static final RenderType BEAM_RENDERTYPE = ModRenderType.getEntityNoOutline(BEAM_TEXTURE);

    public BeamAttackRenderer(EntityRendererManager renderManager) {
        super(renderManager);
    }

    @Override
    public ResourceLocation getEntityTexture(BeamAttackEntity entity) {
        return BEAM_TEXTURE;
    }

    @Override
    public void render(BeamAttackEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
        super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);

        if (entityIn.getLifeTicksRemaining() > 0) {
            matrixStackIn.push();
            float f6 = (float)(entityIn.getTo().getX() - entityIn.getPosX());
            float f8 = (float)(entityIn.getTo().getY() - entityIn.getPosY());
            float f9 = (float)(entityIn.getTo().getZ() - entityIn.getPosZ());
            func_229059_a_(f6, f8, f9, partialTicks, entityIn.ticksExisted, matrixStackIn, bufferIn, packedLightIn);
            matrixStackIn.pop();
        }
    }

    public static void func_229059_a_(float X, float Y, float Z, float partialTicks, int lifeTicks, MatrixStack matrixStackIn, IRenderTypeBuffer renderTypeBuffer, int packedLight) {
        float f = MathHelper.sqrt(X * X + Z * Z);
        float length = MathHelper.sqrt(X * X + Y * Y + Z * Z);
        matrixStackIn.push();
        matrixStackIn.translate(0.0D, 2.0D, 0.0D);
        matrixStackIn.rotate(Vector3f.YP.rotation((float)(-Math.atan2(Z, X)) - ((float)Math.PI / 2F)));
        matrixStackIn.rotate(Vector3f.XP.rotation((float)(-Math.atan2(f, Y)) - ((float)Math.PI / 2F)));
        IVertexBuilder ivertexbuilder = renderTypeBuffer.getBuffer(BEAM_RENDERTYPE);
        float texBase = ((float)lifeTicks + partialTicks) * -0.1F;
        float texLength = length / 16.0F + texBase;
        float sqrt2_2 = (float)Math.sqrt(2.d)/2.f;
        MatrixStack.Entry matrixstack$entry = matrixStackIn.getLast();
        Matrix4f matrix4f = matrixstack$entry.getMatrix();
        Matrix3f matrix3f = matrixstack$entry.getNormal();

        ivertexbuilder
                .pos(matrix4f, sqrt2_2, sqrt2_2, 0.0f)
                .color(255, 255, 255, 255)
                .tex(0.0f, texBase)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
        ivertexbuilder
                .pos(matrix4f, sqrt2_2, sqrt2_2, length)
                .color(255, 255, 255, 255)
                .tex(0.0f, texLength)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
        ivertexbuilder
                .pos(matrix4f, -sqrt2_2, -sqrt2_2, length)
                .color(255, 255, 255, 255)
                .tex(1.0f, texLength)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
        ivertexbuilder
                .pos(matrix4f, -sqrt2_2, -sqrt2_2, 0.0f)
                .color(255, 255, 255, 255)
                .tex(1.0f, texBase)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();

        ivertexbuilder
                .pos(matrix4f, -sqrt2_2, sqrt2_2, 0.0f)
                .color(255, 255, 255, 255)
                .tex(0.0f, texBase)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
        ivertexbuilder
                .pos(matrix4f, -sqrt2_2, sqrt2_2, length)
                .color(255, 255, 255, 255)
                .tex(0.0f, texLength)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
        ivertexbuilder
                .pos(matrix4f, sqrt2_2, -sqrt2_2, length)
                .color(255, 255, 255, 255)
                .tex(1.0f, texLength)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();
        ivertexbuilder
                .pos(matrix4f, sqrt2_2, -sqrt2_2, 0.0f)
                .color(255, 255, 255, 255)
                .tex(1.0f, texBase)
                .overlay(OverlayTexture.NO_OVERLAY)
                .lightmap(packedLight)
                .normal(matrix3f, 0.0F, -1.0F, 0.0F).endVertex();

        matrixStackIn.pop();
    }
}

 

Link to post
Share on other sites
  • Woodside changed the title to [1.15.2] Custom Rendered Quads Not Layering With Clouds Properly

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • That is just the modpack, no logs.
    • I created a modpack for me and my friends but we constantly crash after ~5 minutes of playing , Can some one help me please ? Here are the logs and the modpack : https://www.mediafire.com/file/kqnui7c0wzu8t7k/VladPack4-1.16.5.zip/file
    • I wrote a class that stores the BlockPos and BlockState of a specific block that needs to be changed into another block after a certain amount of time. So far I just coded stone bricks being changed into cracked stone bricks. In every worldtickevent I call a method called onTick in which there is a slight chance (1 in 1000) that this change will occur. The class that does this is called DecayHandler.java   DecayHandler.Java :   public class DecayHandler { public BlockState blockState; public BlockPos blockPos; public World world; private Random random; public int decayChance = 1000; private boolean decayed = false; public DecayHandler(BlockState blockState, BlockPos blockPos, World world){ this.blockState = blockState; this.blockPos = blockPos; this.world = world; random = new Random(); } public DecayHandler OnTick(){ //TODO: Refactor in other methods and implement BlockSwapper if(random.nextInt(decayChance) == 0 && !decayed){ System.out.println(this.blockPos + " Decayed"); if(world.setBlockAndUpdate(blockPos, Blocks.CRACKED_STONE_BRICKS.getBlock().defaultBlockState())){ this.blockState = Blocks.CRACKED_STONE_BRICKS.getBlock().defaultBlockState(); decayed = true; return this; } } //WorldDecayData.get(); return null; } }   This code works fine when I load in to a world and place stone bricks down. The stone bricks stay there for a couple of seconds and then they change into cracked stone bricks. The problem occurs when I save and quit to title and rejoin the same world when I placed stone brick that hadn't decayed yet. The game seems to remember what DecayHandlers were running which I guess is logical because I never closed it. So when the world is reloaded again my code stops without error and no longer functions. I can see in the terminal that the last message that was displayed was that a block decayed so I put a breakpoint on it to see what went wrong. By the way, the game keeps running just fine but my code just stops. The part where it seems to go wrong is in this line:  if(world.setBlockAndUpdate(blockPos, Blocks.CRACKED_STONE_BRICKS.getBlock().defaultBlockState())) When I try to step in to every single detail the callstack becomes insanely large and I'm unable to understand what's going on. The only thing I know is that right at the end they put my thread in to parking or something? I really don't understand what was going on. Can someone explain why this is happening? I don't have a clue of what's going on.
    • Thank you @ChampionAsh5357 for your replies and useful feedback! I'll follow your advice and see where it takes me.
    • This statement is a bit incorrect. The methods still exist, they just use a different mapping set (MCP) than what forge ships with the mdk by default (mojmap). You can use forge-bot on the Forge Discord or Linkie on the Linkie Discord to translate from them. I would probably use a chunk capability instead and tick logic on loaded chunks since you'd have to check every block if it's loaded other than checking the loaded chunks. You could also use a world capability to store the chunks that have an active capability for more efficient usage.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.