Jump to content

[1.15.2] TileEntityRenderer Issues


Tikaji

Recommended Posts

I'm getting the following error when I go to create a TER: 

java.lang.IllegalStateException: Not filled all elements of the vertex

Here is the stack trace that follows:

Spoiler

java.lang.IllegalStateException: Not filled all elements of the vertex
	at net.minecraft.client.renderer.BufferBuilder.endVertex(BufferBuilder.java:225) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at com.novamachina.ens.client.render.SieveRender.render(SieveRender.java:41) ~[main/:?] {re:classloading}
	at com.novamachina.ens.client.render.SieveRender.render(SieveRender.java:14) ~[main/:?] {re:classloading}
	at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.render(TileEntityRendererDispatcher.java:100) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.lambda$renderTileEntity$0(TileEntityRendererDispatcher.java:84) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.runCrashReportable(TileEntityRendererDispatcher.java:120) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntity(TileEntityRendererDispatcher.java:83) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.WorldRenderer.updateCameraAndRender(WorldRenderer.java:1002) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.renderWorld(GameRenderer.java:612) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.renderer.GameRenderer.updateCameraAndRender(GameRenderer.java:434) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:961) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:558) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241] {}
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.0.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.0.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.0.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.0.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.0.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.61_mapped_snapshot_20200427-1.15.1-recomp.jar:?] {}

 

I'm following McJty's tutorial (at least pretty closely) and I'm not entirely sure what I'm missing.

 

Here's the TER: 

Spoiler

public class SieveRender extends TileEntityRenderer<SieveTile> {

    public SieveRender(
        TileEntityRendererDispatcher rendererDispatcherIn) {
        super(rendererDispatcherIn);
    }

    @Override
    public void render(SieveTile tileEntityIn, float partialTicks, MatrixStack matrixStackIn,
        IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
        IVertexBuilder builder = bufferIn.getBuffer(RenderType.getSolid());

        matrixStackIn.push();
        matrixStackIn.translate(tileEntityIn.getPos().getX(), tileEntityIn.getPos().getY(), tileEntityIn.getPos().getZ());

        if(tileEntityIn.getTexture() != null && !tileEntityIn.getBlockStack().isEmpty()) {
            TextureAtlasSprite icon = tileEntityIn.getTexture();
            float minU = icon.getMinU();
            float maxU = icon.getMaxU();
            float minV = icon.getMinV();
            float maxV = icon.getMaxV();



            double height = 1.0f - tileEntityIn.getProgress();
            float fillAmount = (float) (0.15625 * height + 0.84375);

            builder.pos(matrixStackIn.getLast().getMatrix(),0.0625F, fillAmount, 0.0625F).tex(minU, minV).normal(0, 1, 0).endVertex();
            builder.pos(matrixStackIn.getLast().getMatrix(),0.0625F, fillAmount, 0.9375F).tex(minU, maxV).normal(0, 1, 0).endVertex();
            builder.pos(matrixStackIn.getLast().getMatrix(),0.9375F, fillAmount, 0.9375F).tex(maxU, maxV).normal(0, 1, 0).endVertex();
            builder.pos(matrixStackIn.getLast().getMatrix(),0.9375F, fillAmount, 0.0625F).tex(maxU, minV).normal(0, 1, 0).endVertex();
        }

        matrixStackIn.pop();
    }

    public static void register() {
        ClientRegistry.bindTileEntityRenderer(ModTiles.SIEVE_TILE.get(), SieveRender::new);
    }
}

 

Here is the getTexture on the Tile Entity: 
 

Spoiler

public TextureAtlasSprite getTexture() {
        if (!blockStack.isEmpty()) {
            return Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelShapes()
                .getTexture(((BlockItem) blockStack.getItem()).getBlock().getDefaultState(), getWorld(),
                    getPos());
        }
        return null;
    }

 

Any help would be greatly appreciated! (And yes, I am aware that my mod id is too short. I haven't gotten around to changing it yet.)

Link to comment
Share on other sites

Hi

 

A vertex follows a particular format (see DefaultVertexFormats and RenderType) depending on which render buffer you are writing to

eg

   private static final RenderType SOLID = makeType("solid", DefaultVertexFormats.BLOCK, 7, 2097152, true, false, RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_ENABLED).texture(BLOCK_SHEET_MIPPED).build(true));
   public static final VertexFormat BLOCK = new VertexFormat(ImmutableList.<VertexFormatElement>builder().add(POSITION_3F).add(COLOR_4UB).add(TEX_2F).add(TEX_2SB).add(NORMAL_3B).add(PADDING_1B).build());

versus

public static final RenderType.Type LINES = makeType("lines", DefaultVertexFormats.POSITION_COLOR, 1, 256, RenderType.State.getBuilder().line(new RenderState.LineState(OptionalDouble.empty())).layer(PROJECTION_LAYERING).transparency
   public static final VertexFormat POSITION_COLOR = new VertexFormat(ImmutableList.<VertexFormatElement>builder().add(POSITION_3F).add(COLOR_4UB).build());

     
     

 

When you write a vertex to SOLID, you need to supply position (3 floats), colour (4 bytes), texture (2 floats), light map (2 shorts), normals (3 bytes), plus 1 byte padding.

But for LINES you only supply position (3 floats) and colour (4 bytes).

 

So for example- if the code you're using to render to the buffer (during your TER rendering) assumes that the buffer is LINES, but the buffer is actually SOLID, then your code will only write (3 floats + 4 bytes) for each vertex, which is not enough to fill all the elements of the vertex.

 

-TGG

 

 

Link to comment
Share on other sites

Ok that makes sense. I updated my points to the following:

builder.pos(matrixStackIn.getLast().getMatrix(),0.0625F, fillAmount, 0.0625F).color(1.0F, 1.0F, 1.0F, 1.0F).tex(minU, minV).lightmap(0, 240).normal(0, 1, 0).endVertex();
builder.pos(matrixStackIn.getLast().getMatrix(),0.0625F, fillAmount, 0.9375F).color(1.0F, 1.0F, 1.0F, 1.0F).tex(minU, maxV).lightmap(0, 240).normal(0, 1, 0).endVertex();
builder.pos(matrixStackIn.getLast().getMatrix(),0.9375F, fillAmount, 0.9375F).color(1.0F, 1.0F, 1.0F, 1.0F).tex(maxU, maxV).lightmap(0, 240).normal(0, 1, 0).endVertex();
builder.pos(matrixStackIn.getLast().getMatrix(),0.9375F, fillAmount, 0.0625F).color(1.0F, 1.0F, 1.0F, 1.0F).tex(maxU, minV).lightmap(0, 240).normal(0, 1, 0).endVertex();

This stops the crash from happening. However, I'm not getting anything to render still. I've tried reversing the points because I know that planes are one directional and that still didn't get me anything.

 

Also, do I want to use the SOLID RenderType, or should I be using something else?

Edited by Tikaji
Link to comment
Share on other sites

Hi

 

It really depends on what effect you're trying to achieve.  If you just want a block shape, consider using BlockBench and exporting as an entity model or block model, and rendering that.  Or alternatively, using Blender and exporting as an obj (wavefront model).

(Examples in this project if you need them: https://github.com/TheGreyGhost/MinecraftByExample)

Adding vertices manually is usually the hard way of doing it.  Unless you're aiming for a specific effect (eg like the Beacon) I'd consider using a standard method.

 

-TGG

 

 

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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