Jump to content

[SOLVED] [1.12] Trying to add a block but it isn't being recognized


felinoid

Recommended Posts

I'm trying to make a mod that adds a block. I've got three java files:


src/main/java/ore_reeds/OreReeds.java:

package felinoid.ore_reeds;

import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.*;
import net.minecraft.block.Block;


@Mod(modid = OreReeds.MODID, name = OreReeds.NAME, version = OreReeds.VERSION)

public class OreReeds
{
	public static final String NAME = "Ore Reeds";
	public static final String MODID = "ore_reeds";
	public static final String VERSION = "1.12.2-1.0.0";
	
	@Mod.Instance("ore_reeds")
	public static OreReeds instance;
	
	@Mod.EventHandler
	public void preInit(final FMLPreInitializationEvent event) {}
	
	@Mod.EventHandler
	public void init(final FMLInitializationEvent event) {}
	
	@Mod.EventHandler
	public void postInit(final FMLPostInitializationEvent event) {}
}



src/main/java/ore_reeds/blocks/ModBlocks.java:

package felinoid.ore_reeds;

import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.registries.*;

public class ModBlocks {
	public static Block ore_essence;
	
	public static Item item_ore_essence = Item.getItemFromBlock(ore_essence);

	public static void preInit() {}

	public static void init() {}

	
	@SubscribeEvent
	public void registerBlock(RegistryEvent.Register<Block> event) {
		event.getRegistry().register(ore_essence);
	}
	
	@SubscribeEvent
	public void registerItemBlocks(RegistryEvent.Register<Item> event) {
		event.getRegistry().register(item_ore_essence);
	}
    
}

(I'm pretty much entirely guessing at how to register things here, so maybe that's the problem.)

and src/main/java/blocks/OreEssence.java:

package felinoid.ore_reeds;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;

public class BlockOreEssence extends Block
{
    protected BlockOreEssence()
    {
        super(Material.ROCK);
        setUnlocalizedName("ore_essence");
        setRegistryName("ore_essence");
        this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    }

    /**
     * Get the MapColor for this Block and the given BlockState
     */
    public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        return MapColor.BLACK;
    }
    
}



There's also some json files, a texture, and a lang, but from what I understand it should at least show up even without those. My block is not showing up in the creative mode inventory, and if I try to use /give or /setblock, it tells me ore_reeds:ore_essence isn't a real block. Any idea what could be going wrong?

Edited by felinoid
Change title to SOLVED
Link to comment
Share on other sites

Which tutorial did you use? Because from what I can see, your ModBlocks class is not registered to the event bus. I do not know if it is different with the registry stuff, but usually you register the class with your events by using MinecraftForge.EVENT_BUS.register(new_instance_of_your_class);

Try add that to the preInit of your mod. In this case the instance would be a new ModBlocks instance.

  • Thanks 1
Link to comment
Share on other sites

I haven't found a good tutorial for 1.12, so I've been using a mix of tutorials for older versions, looking at the Minecraft source, looking at the java output of MCreator, and reading random forum posts. Unfortunately the only one of those that really describes how to register events the new way was a random forum post.

 

Ok, so the preinit function in OreReeds.java now looks like this:

	@Mod.EventHandler
	public void preInit(final FMLPreInitializationEvent event) 
	{
		MinecraftForge.EVENT_BUS.register(ModBlocks.class);
	}

However, the block is still not showing up.

 

And my BlockOreEssence.java now looks like:

package felinoid.ore_reeds;

import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.math.BlockPos;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;

public class BlockOreEssence extends Block
{
    protected BlockOreEssence()
    {
        super(Material.ROCK);
        setUnlocalizedName("ore_reeds_ore_essence");
        setRegistryName("ore_essence");
        this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
    }

    /**
     * Get the MapColor for this Block and the given BlockState
     */
    @Override
    public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        return MapColor.BLACK;
    }
    
}

@diesieben07, is that the correct way to solve the other problems?

Link to comment
Share on other sites

1 minute ago, felinoid said:

MinecraftForge.EVENT_BUS.register(ModBlocks.class)

This registers your class to the bus, and the bus can only invoke static methods on it, but your @SubscribeEvent methods are not static.

  • Thanks 1

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

Ok, so I made those methods static:

	@SubscribeEvent
	public static void registerBlock(RegistryEvent.Register<Block> event) {
		event.getRegistry().register(ore_essence);
	}
	
	@SubscribeEvent
	public static void registerItemBlocks(RegistryEvent.Register<Item> event) {
		event.getRegistry().register(item_ore_essence);
	}

Now it crashes Minecraft while Forge is loading. Progress!

 

The error is:

:runClient FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':runClient'.
> Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 255

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 22.074 secs

On rerunning with --debug I get:

13:50:58.488 [LIFECYCLE] [class org.gradle.TaskExecutionLogger] :runClient FAILED
13:50:58.488 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :runClient (Thread[main,5,main]) completed. Took 11.07 secs.
13:50:58.488 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[main,5,main]] finished, busy: 14.985 secs, idle: 0.04 secs
13:50:58.497 [ERROR] [org.gradle.BuildExceptionReporter] 
13:50:58.497 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] 
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':runClient'.
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] > Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 255
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] 
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] * Try:
13:50:58.498 [ERROR] [org.gradle.BuildExceptionReporter] Run with --stacktrace option to get the stack trace. 
13:50:58.498 [LIFECYCLE] [org.gradle.BuildResultLogger] 
13:50:58.499 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
13:50:58.499 [LIFECYCLE] [org.gradle.BuildResultLogger] 
13:50:58.499 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 21.477 secs
13:50:58.517 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshotsToTreeSnapshotsIndex.bin (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts/fileSnapshotsToTreeSnapshotsIndex.bin)
13:50:58.517 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache treeSnapshots.bin (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts/treeSnapshots.bin)
13:50:58.518 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache treeSnapshotUsage.bin (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts/treeSnapshotUsage.bin)
13:50:58.518 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskArtifacts.bin (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts/taskArtifacts.bin)
13:50:58.518 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshots.bin (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts/fileSnapshots.bin)
13:50:58.518 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts/fileHashes.bin)
13:50:58.519 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task history cache (/media/tiffany/4cf1084a-2b89-44a4-b210-3d6bac12ca8e/tiffany/test/minecraft_mod/.gradle/2.14/taskArtifacts).
13:50:58.520 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.memcache.InMemoryCachedRepositoryFactory] In-memory dependency metadata cache closed. Repos cached: 45, cache instances: 6, modules served from cache: 14, artifacts: 5
13:50:58.520 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Generated Gradle JARs cache (/home/tiffany/.gradle/caches/2.14/generated-gradle-jars) was closed 0 times.
13:50:58.521 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache artifact-at-repository.bin (/home/tiffany/.gradle/caches/modules-2/metadata-2.16/artifact-at-repository.bin)
13:50:58.521 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (/home/tiffany/.gradle/caches/modules-2/metadata-2.16/module-metadata.bin)
13:50:58.521 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (/home/tiffany/.gradle/caches/modules-2).
13:50:58.521 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 1, disk reads: 1 (avg: 0.012 secs, total: 0.012 secs)
13:50:58.522 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 0 (avg: 0.0 secs, total: 0.0 secs)
13:50:58.522 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 2 resolution results binary files in 0.001 secs
13:50:58.524 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (/home/tiffany/.gradle/caches/2.14/plugin-resolution) was closed 0 times.
13:50:58.524 [DEBUG] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopping 0 compiler daemon(s).
13:50:58.525 [INFO] [org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonManager] Stopped 0 compiler daemon(s).

 

Link to comment
Share on other sites

Oh, and running with --stacktrace gets me:

:runClient FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':runClient'.
> Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 255

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':runClient'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:66)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
        at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:153)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:150)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:98)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:92)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:92)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:83)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:99)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:48)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:30)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:81)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:46)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:239)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:212)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:205)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:55)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:36)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 255
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
        at org.gradle.process.internal.DefaultJavaExecAction.execute(DefaultJavaExecAction.java:31)
        at org.gradle.api.tasks.JavaExec.exec(JavaExec.java:74)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:621)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:604)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 60 more


BUILD FAILED

Total time: 22.061 secs

I thought knowing C++ would be enough to get me by, but I guess I'll have to figure out all this weird reflection stuff Java has.

 

Edit: Okay, I'm a dumbo who should have read the crash log, which is much more helpful than the error message. Namely,

Time: 8/24/18 3:01 PM
Description: Initializing game

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:272)
	at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:266)
	at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:110)
	at felinoid.ore_reeds.ModBlocks.registerBlock(ModBlocks.java:28)

(followed by more stack tracing). So it looks like I'm trying to resister it to a null registry? How do I specify a registry that is not null?

Edited by felinoid
Link to comment
Share on other sites

Thank you! I'd thought that declaring the variable automatically called the constructor like in C++, but I guess not in Java. It no longer crashes, and the block now shows up in the game! It has no texture and the item for it still doesn't exist, but I think I might be able to figure those out. Thank you all for all your help!

Link to comment
Share on other sites

29 minutes ago, felinoid said:

Thank you! I'd thought that declaring the variable automatically called the constructor like in C++, but I guess not in Java.

As null is a perfectly valid value, all objects are initialized to null.

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

4 hours ago, diesieben07 said:

You must explicitly register an ItemBlock.

Thanks! That did the trick.

 

3 hours ago, Draco18s said:

As null is a perfectly valid value, all objects are initialized to null.

Yeah, I guess I mostly forgot everything's a pointer in Java.

 

So now I have an item for it, and I fixed the missing texture for the block (it needed to be ore_reeds:blocks/ore_essence, not just blocks/ore_essence), but the item still has a missing texture and the lang file isn't working.

 

My lang file is at src/main/resources/assets/ore_reeds/lang/en_us.lang and looks like:

tile.ore_essence.name=Ore Essence

I've also tried

tile.ore_reeds:ore_essence.name=Ore Essence

but in both cases my block shows up in-game as tile.ore_reeds:ore_essence.name.

 

For my json files I've got

src/main/resources/assets/ore_reeds/blockstates/ore_essence.json:

{
    "variants": {
        "normal": { "model": "ore_reeds:ore_essence" }
    }
}

 

src/main/resources/assets/ore_reeds/models/item/ore_essence.json:

{
    "parent": "ore_reeds:block/ore_essence"
}

 

and src/main/resources/assets/ore_reeds/models/block/ore_essence.json:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "ore_reeds:blocks/ore_essence"
    }
}

 

Thanks again for helping me get this far!

Edited by felinoid
Link to comment
Share on other sites

15 minutes ago, felinoid said:

the lang file isn't working.

Name the lang file en_US.lang or put a mcmeta file for a resource pack that specifies the correct version.

18 minutes ago, felinoid said:

missing texture 

Did you register the model in the ModelRegistryEvent using ModelLoader.setCustomModelResourceLocation

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Hooray! It works!

 

Funny, the only thing I found when searching for why my lang file didn't work was someone saying it needed to be en_us, not en_US, but changing it to en_US fixed it. And now that I also register the model for the item, the item has a texture! Thank you everyone!

Link to comment
Share on other sites

2 minutes ago, felinoid said:

Hooray! It works!

 

Funny, the only thing I found when searching for why my lang file didn't work was someone saying it needed to be en_us, not en_US, but changing it to en_US fixed it. And now that I also register the model for the item, the item has a texture! Thank you everyone!

its en_us if you're using pack_format 3 in your pack.mcmeta file. If a value isn't specified it uses version 2.

  • Thanks 1

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

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.

×
×
  • Create New...

Important Information

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