Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

 

 

As the title says, I'm not sure why this method is causing a problem. I'm using the jar from gradle build, I have my sides properly set up (via IProxy), but this only breaks when I run this on a server. I know I'm probably missing something simple, but its not obvious to me. 

Crash Report:

Spoiler

---- Minecraft Crash Report ----
// This doesn't make any sense!

Time: 10/1/19 10:35 PM
Description: Exception in server tick loop

java.lang.NullPointerException: Can't use a null-name for the registry, object null.
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:287)
    at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:281)
    at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:113)
    at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:154)
    at com.cilka.telgt.EventSubscriber.registerBlocks(EventSubscriber.java:53)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_EventSubscriber_registerBlocks_Register.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:845)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:630)
    at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:99)
    at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:333)
    at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:125)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486)
    at java.lang.Thread.run(Unknown Source)

package com.cilka.telgt.block;

import com.cilka.telgt.Main;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.BlockRenderLayer;

public class BaseBlock extends Block {

	private String blockName;
	private BlockRenderLayer layer;
	private String tabName;
	public BaseBlock(String blockName) {
		
		super(Material.ROCK);
		setCreativeTab(CreativeTabs.MISC);
		setSoundType(SoundType.CLOTH);
		this.blockName = blockName;
		SetRegistrationFromFile();
	}
	
	public BaseBlock(String blockName, BlockOptions options)
	{
		super(options.GetMaterial());
		setCreativeTab(options.GetTab());
		setSoundType(options.GetSound());
		this.blockName = blockName;
		this.layer = options.GetLayer();
		SetRegistrationFromFile();
	}
	public String GetBlockName()
	{
		return blockName;
	
	}

	@Override
	public BlockRenderLayer getRenderLayer()
	{	
		return layer != null ? layer : super.getRenderLayer();
	}

	@Override 
	public boolean isOpaqueCube(IBlockState state)
	{

		return !getRenderLayer().equals(BlockRenderLayer.TRANSLUCENT);
	}
	private void SetRegistrationFromFile()
	{
		
		setRegistryName(Main.MODID, blockName);
		setTranslationKey(blockName);
	}
	

}

 

 

23 minutes ago, Cilka said:

java.lang.NullPointerException: Can't use a null-name for the registry, object null.

Somewhere you're trying to register a block to a null registry name. You should trace this back from EventSubscriber.registerBlocks() with the debugger to find out where the name isn't being set, if it's tricky enough.

 

Also: Code-Style #4

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

  • Author
37 minutes ago, SerpentDagger said:

Somewhere you're trying to register a block to a null registry name. You should trace this back from EventSubscriber.registerBlocks() with the debugger to find out where the name isn't being set, if it's tricky enough.

 

Also: Code-Style #4

Originally I thought that too. I traced it back to the BaseBlock.isOpaqueBlock method and found that replacing the return with false makes the server happy. I can double check, and see what else I've missed.

Wait, where are you even getting the getRenderLayer() method from? It's not a method accessible via Block, so your compiler should be shouting about that. The method I've been using is Block#getBlockLayer(), which does what I think you want.

 

The only reference I've found to getRenderLayer() is MinecraftForgeClient#getRenderLayer().

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

It is, however, getRenderLayer() in 1.14.4.

 

The thread title claims 1.12.2 -- has there been an attempt to copy/paste some 1.14.4 sample code into the 1.12.2 project, with unhappy results?

  • Author
5 hours ago, SerpentDagger said:

Wait, where are you even getting the getRenderLayer() method from? It's not a method accessible via Block, so your compiler should be shouting about that. The method I've been using is Block#getBlockLayer(), which does what I think you want.

 

The only reference I've found to getRenderLayer() is MinecraftForgeClient#getRenderLayer().

I just looked at the source of

 net.minecraft.block

and It had the getRenderLayer() method in there. If I try to use getBlockLayer(), the comipler complains that the method doesn't exist, which looking though source code it doesn't either. 

 

1 hour ago, Ommina said:

It is, however, getRenderLayer() in 1.14.4.

 

The thread title claims 1.12.2 -- has there been an attempt to copy/paste some 1.14.4 sample code into the 1.12.2 project, with unhappy results?

I was using a 1.12.2 tutorial from Harry's Tech Reviews as my base. I did notice that many of the things that he does in the tutorial goes against forge coding standards, so something could be off when I copied that line. 

Hmm. It seems, then, that you've installed a 1.14 version by mistake?

Regardless, assuming it works the same way in 1.(?), Block#getBlockLayer() is annotated with @SideOnly(Side.CLIENT), so it only exists on the physical client. Block#isOpaqueCube(), however, is present on both the physical client and the physical server. So when you call getBlockLayer() within isOpaqeCube(), it'll crash a physical server.

 

Edit: Also, Block#isOpaqueCube() is deprecated. I think you only have to use Block#getBlockLayer() now.

Edited by SerpentDagger

Fancy 3D Graphing Calculator mod, with many different coordinate systems.

Lightweight 3D/2D position/vector transformations library, also with support for different coordinate systems.

  • Author
7 hours ago, SerpentDagger said:

Hmm. It seems, then, that you've installed a 1.14 version by mistake?

Regardless, assuming it works the same way in 1.(?), Block#getBlockLayer() is annotated with @SideOnly(Side.CLIENT), so it only exists on the physical client. Block#isOpaqueCube(), however, is present on both the physical client and the physical server. So when you call getBlockLayer() within isOpaqeCube(), it'll crash a physical server.

 

Edit: Also, Block#isOpaqueCube() is deprecated. I think you only have to use Block#getBlockLayer() now.

I've looked in the .iml file and found that I am using version 1.12.2-14.23.5.2768 as evident here 

<libelement value="jar://$USER_HOME$/.gradle/caches/minecraft/net/minecraftforge/forge/1.12.2-14.23.5.2768/stable/39/forgeSrc-1.12.2-14.23.5.2768.jar!/" />

I'll see if updating forge to the latest version of 1.12.2 will work.

 

Edit: So I don't know why I didn't think of this before, but I have a work around now.

@Override 
public boolean isOpaqueCube(IBlockState state)
{

   return layer != null ? !layer.equals(BlockRenderLayer.TRANSLUCENT) : super.isOpaqueCube(state);
}

 The way I've initialize my blocks I will always use layer instead of getRenderLayer(). Slightly jank, but doesn't blow up my server. Thanks everyone!

Edited by Cilka
Solved my problem

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.