Jump to content

[1.7.10] BlockRenderer vs TileEntitySpecialRenderer


Recommended Posts

Posted

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/

Posted

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

 

 

Posted
  On 11/13/2015 at 10:23 AM, WeAthFolD said:

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.

Posted

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]

Posted

Update to 1.8, this becomes infinitely more simple as you don't have to do any GL crap and can just use a sloped model.

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

Posted

I started with 1.8 but jumped back to 1.7.10 because major mods are not ported yet and might never be. I plan to use Thermal Foundation and AppleCore among others later on.

Posted

That's not an excuse, update. You're going to have to do this anyways so do it.

Stop feeding the 'chicken-egg' cycle.

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

Posted

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

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • just rewatched the tutorial and my code is exactly the same as kaupenjoe's.  the item is added into the game but like i said to start it doesnt have a texture or a proper name for whatever reason.
    • yes the name is en_us.json and it is in resources -> assests -> testmod -> lang folders.  i have checked my code and am pretty confident that the code itself is correct.  i even tried loading the project in eclipse and it has the same problems, I think i will just rewatch the whole tutorial and will give an update on the situation.
    • same error, I also tried removing Valkyrian skies as well because I noticed it coming up a lot in the debug log errors
    • Hey man,    i have only been modding Minecraft for a few days but maybe I can help you. First of all make sure to follow every step of Kaupenjoe's tutorial, I found it to been very helpful and complete. The game uses the raw translation key for the item (in your case "item.testmod.alexandrite") if it can't find the correct lang file. Make sure it's name is "en_us.json" and it is saved under "ressources" -> "assets" -> "testmod".
    • whenever I try to get this item to render into the game it appears with the not texture purple and black squares and calls itself by the lang translation file path instead of the name i gave it.   { "item.testmod.alexandrite": "Alexandrite" } this is the lang json file package net.Hurst.testmod.item; import net.Hurst.testmod.TestMod; import net.minecraft.world.item.Item; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; public class ModItems { public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TestMod.MOD_ID); public static final RegistryObject<Item> ALEXANDRITE = ITEMS.register("alexandrite", () -> new Item(new Item.Properties())); public static void register(IEventBus eventBus){ ITEMS.register(eventBus); } } this is my ModItems.java file package net.Hurst.testmod; import com.mojang.logging.LogUtils; import net.Hurst.testmod.item.ModItems; import net.minecraft.world.item.CreativeModeTabs; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.BuildCreativeModeTabContentsEvent; import net.minecraftforge.event.server.ServerStartingEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.slf4j.Logger; // The value here should match an entry in the META-INF/mods.toml file @Mod(TestMod.MOD_ID) public class TestMod { public static final String MOD_ID = "testmod"; private static final Logger LOGGER = LogUtils.getLogger(); public TestMod() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); modEventBus.addListener(this::commonSetup); ModItems.register(modEventBus); MinecraftForge.EVENT_BUS.register(this); modEventBus.addListener(this::addCreative); ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC); } private void commonSetup(final FMLCommonSetupEvent event) { } // Add the example block item to the building blocks tab private void addCreative(BuildCreativeModeTabContentsEvent event) { if(event.getTabKey() == CreativeModeTabs.INGREDIENTS){ event.accept(ModItems.ALEXANDRITE); } } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(ServerStartingEvent event) { } // You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent @Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public static class ClientModEvents { @SubscribeEvent public static void onClientSetup(FMLClientSetupEvent event) { } } } this is my TestMod.java file { "parent": "minecraft:item/generated", "textures": { "layer0": "testmod:item/generated" } } this is my model file for the item. I am using intellij 2025.1.2 with fdk 1.21 and java 21 I would appreciate the help.
  • Topics

×
×
  • Create New...

Important Information

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