Jump to content

[1.7.10] BlockRenderer vs TileEntitySpecialRenderer


r00t

Recommended Posts

Hello,

I just started modding and cannot grasp some concepts yet. I've been using these documentations as a basis in combination with the vanilla code and big mods from github. However, the vanilla code has obfuscated method/variable names and the big mods use many custom libraries, making them harder to follow.

 

For starters, I wanted to created a sloped block like this: Super-Slopes-Mod-3.png

The slope block should be rendered as a 3D item in world and the inventory.

The Block should be a tile entity later on but for now I just wanted it to render like this.

 

1. In many projects I saw a BlockRenderer and a TileEntitySpecialRenderer implemented. Why do I need two renderers for the same block, even if the TileEntity is an empty class for now?

2. Isn't it possible to use the block's renderer to created a scaled item version? Do I really need to implement a new ItemRenderer?

3. Are there good documented tutorials/minimal examples for 1.7.10 I am missing? 

 

Thank you!

 

http://greyminecraftcoder.blogspot.de/2013/08/rendering-inventory-items.html

http://www.minecraftforge.net/wiki/Tile_entity_special_renderer

http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-7/metadata-blocks-and-items/

Link to comment
Share on other sites

In a nutshell: ISBRH is cached for efficiency and is called infrequently, TESR is not and gets called every frame.

 

in ISBRH you are already in a context of Tessellator.startDrawing(GL_QUADS). All you can do is specific quad geometries to the tessellator. The ISBRH represents a huge global draw call, where the draw call is sent once for every block in the world (or the blocks needed for render update). This is done only when world render state needs to update. (e.g. light state chagned).

 

in TESR you send out draw calls by yourself, and they get called every frame. This allows rendering of *dynamic* effects and complex geometries, also enables you to do transformation using ``GL11.glTranslate`` and ``glRotate``. However because that each TESR call needs at least one draw call, it is generally slower.

 

So, use TESR only when it's necessary.

 

NOTE: Those conclusion comes from reading the source code and might be somehow inaccurate. Feel free to correct me >.<

 

 

Link to comment
Share on other sites

NOTE: Those conclusion comes from reading the source code and might be somehow inaccurate. Feel free to correct me >.<

 

AFAIK that is an accurate statement.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Great, thank you!

 

So, I created the BlockRenderer and the corners look fine now. I am using setBlockBoundsBasedOnState to set the bounds to the corner slab for now.

1. When looking at the block, the inventory item changes according to the orientation, though always being the corner piece of the BlockBounds. Do I have to add a completely new renderer or is it possible to use the scaled model version of a certain block direction? What is the performance solution here?

 

2. How can set the BlockBounds to prevent an entity to stand inside the block, while allowing it to walk it like stairs? The corner block does not seem like a good solution. The borders should be customary rendered on the block. Is it enough to use addCollisionBoxesToList? (this thread was a dead end: http://www.minecraftforge.net/forum/index.php?topic=22129.0)

 

	@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
	int meta = world.getBlockMetadata(x, y, z);
	if (meta == LibRef.DIRECTION.NORTH) {
		setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 0.5F);
	}
	if (meta == LibRef.DIRECTION.EAST) {
		setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
	}
	if (meta == LibRef.DIRECTION.SOUTH) {
		setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 0.5F, 1.0F);
	}
	if (meta == LibRef.DIRECTION.WEST) {
		setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 0.5F, 1.0F);
	}
}

 

width=180 height=105http://s8.postimg.org/ei3ccoc4h/Screen_Shot_2015_11_14_at_18_18_49.jpg[/img]

Link to comment
Share on other sites

Then you will receive no help here.

And that link you posted is 100% FLAT OUT WRONG.

It's nothing but spreading FUD.

Any mod that says they can not update is wrong and are just being lazy.

This has been proven many many times. Every time someone comes along and says "ITS IMPOSSIBLE!" We come back and show them it's not.

But retards like you only see the bitching and don't think for yourself or try for yourself.

So ya, you're not going to get any help here.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

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.