Jump to content

Recommended Posts

Posted (edited)

I'm trying to get a custom modeled block, in the same fashion as the enchanted book on the Enchanting Table, registered and rendered properly.

 

I thought this line was likely what I needed and have tried using it in the same place I register all the renders for my mobs:

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityXelNagaPylon.class, new TileEntityXelNagaPylonRenderer());

 

When you place the block, it displays and animates correctly. However, when you log into the game, the block is invisible unless you left or right click on it. Then the model displays and animates correctly. After playing with it for a while, I have a strong hunch that I should not be using the above line at all. What is the proper way to register a custom modeled block?

 

Here is how I handle the TileEntity registrations if needed:

	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event)
	{	
		event.getRegistry().registerAll(KindredLegacyBlocks.BLOCKS.toArray(new Block[0]));

		TileEntityHandler.registerTileEntities();
	}
public static void registerTileEntities()
{
	GameRegistry.registerTileEntity(TileEntityXelNagaPylon.class, new ResourceLocation(ModInfo.MOD_ID, "xelnaga_pylon"));
	GameRegistry.registerTileEntity(TileEntityVespeneCondenser.class, new ResourceLocation(ModInfo.MOD_ID, "vespene_condenser"));
}

 

If it needs mentioning, these are not hybrid model blocks like the Enchanting Table is. Their appearances are entirely defined in their model classes.

Edited by FuzzyAcornIndustries
Problem is solved.
Posted
public class BlockXelNagaPylon extends BlockBase
{
	public BlockXelNagaPylon()
	{
		super("xelnaga_pylon", Material.ROCK);
		
		this.setHardness(2.0F);
		this.setResistance(10.0F);
		this.setLightLevel(0.5F);
	}

	@Override
    public boolean isFullCube(IBlockState state)
    {
        return false;
    }
	
	@Override
    public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }
	
	@Override
    public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand)
	{
		float xx = (float) pos.getX() + 0.5F, yy = (float) pos.getY() + rand.nextFloat() * 6.0F / 16.0F, zz = (float) pos.getZ() + 0.5F, xx2 = rand.nextFloat() * 0.3F - 0.2F, zz2 = 0.5F;
		
		worldIn.spawnParticle(EnumParticleTypes.SPELL_INSTANT, (double) (xx), (double) yy, (double) (zz), 0.0F, 0.0F, 0.0F);
	}
	
	@Override
    public boolean hasTileEntity(IBlockState state)
    {
    	return true;
    }
    
	@Override
    public TileEntity createTileEntity(World world, IBlockState state)
	{
		return new TileEntityXelNagaPylon();
	}
}

 

Posted

Ah! That might be the problem. I don't know where or how to register the TE renderer. Unless you mean the .bindTileEntitySpecialRenderer() mentioned above. That would be in these locations:

 

RenderHandler:

public static void registerTileEntityRenders()
{
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityXelNagaPylon.class, new TileEntityXelNagaPylonRenderer());
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVespeneCondenser.class, new TileEntityVespeneCondenserRenderer());
}

 

RegistryHandler:

public static void preInitRegistries()
{
	KindredLegacyEntities.registerEntityMob();
	KindredLegacyEntities.registerEntityAbilities();
	KindredLegacyEntities.registerEntityProjectiles();
	RenderHandler.registerEntityRenders();
	RenderHandler.registerTileEntityRenders();
}


Main class:

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	ConfigHandler.preInit(event);

	isBiomesOPlentyEnabled = Loader.isModLoaded("biomesoplenty");
	isGalacticraftEnabled = Loader.isModLoaded("galacticraftcore");

	networkHelper = new NetworkHelper(ModInfo.CHANNEL2, PoketamableNamePacket.class);

	RegistryHandler.preInitRegistries();
}

 

A TileEntityRenderer:

public class TileEntityXelNagaPylonRenderer extends TileEntitySpecialRenderer<TileEntityXelNagaPylon>
{
    private static final ResourceLocation TEXTURE_XELNAGA_PYLON = new ResourceLocation(ModInfo.MOD_ID + ":" +"textures/blocks/xelnaga_pylon.png");
    private static final ResourceLocation TEXTURE_XELNAGA_PYLON_GLOWS = new ResourceLocation(ModInfo.MOD_ID + ":" +"textures/blocks/xelnaga_pylon_glows.png");
    private final ModelXelNagaPylon modelXelNagaPylon = new ModelXelNagaPylon();
    private final ModelXelNagaPylon modelXelNagaPylonGlows = new ModelXelNagaPylon();

    @Override
    public void render(TileEntityXelNagaPylon tileEntity, double x, double y, double z, float partialTicks, int destroyStage, float alpha)
    {
		GL11.glPushMatrix();
		GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
		GL11.glRotatef(180, 0F, 0F, 1F);

		this.bindTexture(TEXTURE_XELNAGA_PYLON);

		GL11.glPushMatrix();
		this.modelXelNagaPylon.renderModel(0.0625F, (TileEntityXelNagaPylon)tileEntity);
		GL11.glPopMatrix();
		GL11.glPopMatrix();

		/* ************ */

		GL11.glPushMatrix();
		GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
		GL11.glRotatef(180, 0F, 0F, 1F);

		this.bindTexture(TEXTURE_XELNAGA_PYLON_GLOWS);

		float f1 = 1.0F;
		GL11.glEnable(GL11.GL_BLEND);
		GL11.glDisable(GL11.GL_ALPHA_TEST);
		GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
		GL11.glDisable(GL11.GL_LIGHTING);
		char c0 = 61680;
		int j = c0 % 65536;
		int k = c0 / 65536;
		OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j / 1.0F, (float)k / 1.0F);
		GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glColor4f(1.0F, 1.0F, 1.0F, f1);

		GL11.glPushMatrix();
		this.modelXelNagaPylonGlows.renderModel(0.0625F, (TileEntityXelNagaPylon)tileEntity);
		GL11.glDisable(GL11.GL_BLEND);
		GL11.glPopMatrix();
		GL11.glPopMatrix();
    }
}

 

There are probably issues with the render() function as I still have a hard time understanding all that GL11 code.

Posted

I tested if the code ran while it was invisible but didn't until it was visible.

 

I am embarrassed to admit but I think I found what happened. As I was changing the code, I left the blocks that were already placed as is. As I was playing around with the blocks in the loaded environment just a few moments ago, I accidentally destroyed one. When I placed a new one down, it no longer turned invisible on loading the game.

 

I deeply thank you for looking at my code and confirming that I did most of this right! It was very difficult to get this far.

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

    • Start by following the docs to get a workspace setup: https://docs.minecraftforge.net/en/latest/gettingstarted/ Then poke around some of the tutorials, https://www.mcjty.eu/docs/1.20/ used to be the goto, but not sure if there are any updates for regular forge or not, but if you've brushed up on Java, it will be enough to get you started. Poke around the Minecraft and Forge sources to see how things are done. Read the FAQ for information on how to post code/logs when you run into issues. Share as much info on issues you have as possible. Use github to host projects, chances of someone helping are higher when they can actually see all your code and/or build it themselves. And finally, keep it on the forums, don't direct message people with questions, most people do not provide personal support like that. Also keep in mind forums posts are not always immediately answered, if you're looking for a quicker response, you can always try the Minecraft Forge discord server.
    • Hello, I have a Forge Minecraft sever (I host it at g-portal.com) which has always worked fine and I had no problems, but today it doesn't wanna work anymore. Today I started the server and the status said online, but after a few seconds it said this: "Start failed". And then out of nowhere it restarted itself and the same thing happened again and again and now it's in an infinite loop where it just keeps failing and then restarts. Here's the download link for the server logs: https://www.mediafire.com/file/sq30dgoonjevib1/2025-07-06-1.log/file Does anyone know how to fix this? If yes I would really appreciate help. Best wishes, Gabs1107
    • I'm experiencing a critical issue on a dedicated Arch Linux server running the latest Forge for Minecraft 1.20.1. When a player exits a Nether portal (not enters, and not via /tp) or teleports into the End via portal, the server completely freezes for 1–10 minutes. During this time, all commands are unresponsive, and the game world essentially locks up. This is with watchdog disabled. Environment: OS: Arch Linux (latest packages) Java: OpenJDK 17 (up to date) Forge Version: Latest 1.20.1 (tested multiple versions from the past ~3 months) Mods: None (issue occurs on a clean install) Server Type: Proxmox VM with: 4 virtual cores 64 GB RAM (63 GB allocated via -Xmx and -Xms flags) Observed Behavior: Observed Behavior: The server freezes for 1–10 minutes when: Exiting a Nether portal (entering does not trigger the issue) Entering or exiting the End using a portal Teleporting using commands (e.g., /tp) works only for the Nether; teleporting to the End via command also causes a freeze The issue occurs anywhere in the world, not tied to specific coordinates or builds During the freeze: The server becomes completely unresponsive to all commands and player actions No crash reports, no errors, and no warnings are logged CPU usage remains under 50%, and RAM usage stays around 6–14 GB After 1–10 minutes, the server recovers automatically and resumes normal operation
    • Hey man, I just found this section in your code.  Try to do this: { "parent": "minecraft:item/generated", "textures": { "layer0": "testmod:item/alexandrite" } } This means your png should be named alexandrite.png. Hope it helps  
  • Topics

×
×
  • Create New...

Important Information

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