Jump to content

Recommended Posts

Posted (edited)

Hi. I've just made a torch that extinguishes over time, but only as a floor block. The torch is functional, but to finish it I need to pass the floor block through a WallOrFloorItem, along with a wall block.
I'm struggling with figuring out the proper way to register WallOrFloorItem along with those two blocks. Do I register the TorchBlock and WallTorchBlock with their own unique registry-names, or do they get registered as part of WallOrFloorItem? If they all should be registered, shouldn't I be able to use the same registry-name for WallOrFloorItem and TorchBlock?

If only there was an example resource to look at, that'd help a lot too!

tl;dr: What's the right way to register custom WallOrFloorItem, TorchBlock and WallTorchBlock?

ModItems:

public static final RegistryObject<Item> FLIMSY_TORCH = Registration.ITEMS.register("flimsy_torch", () ->
		new WallOrFloorItem(ModBlocks.FLIMSY_TORCH.get(), Blocks.WALL_TORCH, (new Item.Properties()).group(ItemGroup.DECORATIONS)));

 

ModBlocks:

public static final RegistryObject<Block> FLIMSY_TORCH = register("flimsy_torch", () ->
		new FlimsyTorchBlock(Block.Properties.from(Blocks.TORCH).tickRandomly().setLightLevel((state) -> {
		      return 14;
		   }), ParticleTypes.FLAME, 3));

//Still missing a WallTorchBlock, using vanilla WallTorch as placeholder


When trying to register the TorchBlock in addition to the WallOrFloorItem(using same name), I'm presented with this error:

 

[04:25:28] [modloading-worker-1/ERROR] [ne.mi.fm.ja.FMLModContainer/LOADING]: Failed to create mod instance. ModID: solidrocks, class com.snoodle.solidrocks.SolidRocks
java.lang.ExceptionInInitializerError: null
	at com.snoodle.solidrocks.setup.Registration.register(Registration.java:25) ~[?:?] {re:classloading}
	at com.snoodle.solidrocks.SolidRocks.<init>(SolidRocks.java:19) ~[?:?] {re:classloading}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_271] {}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_271] {}
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_271] {}
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_271] {}
	at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_271] {}
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:81) ~[forge:35.1] {re:classloading}
	at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$4(ModContainer.java:120) ~[forge:?] {re:classloading}
	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640) [?:1.8.0_271] {}
	at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1632) [?:1.8.0_271] {}
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) [?:1.8.0_271] {}
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067) [?:1.8.0_271] {}
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703) [?:1.8.0_271] {}
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172) [?:1.8.0_271] {}
Caused by: java.lang.IllegalArgumentException: Duplicate registration flimsy_torch
	at net.minecraftforge.registries.DeferredRegister.register(DeferredRegister.java:125) ~[forge:?] {re:classloading}
	at com.snoodle.solidrocks.setup.ModItems.<clinit>(ModItems.java:20) ~[?:?] {re:classloading}
	... 15 more
Edited by StealthyNoodle
Posted
5 hours ago, ChampionAsh5357 said:

Well, yes. Names must be unique on a per registry basis. That's where your error is coming from.

Currently I don't register a WallTorchBlock, so I wouldn't think that's the duplicate (unless it's being registered as part of the WallOrFloorItem). But at the same time I find it odd that it would register my WallOrFloorItem(which is registered under ITEMS) to be in conflict with my TorchBlock(which is registered under BLOCKS with the same name) as they're unique in their registries as you say.

Could it be that I'm messing up somewhere else? Data generation perhaps?

Posted
4 hours ago, StealthyNoodle said:

Could it be that I'm messing up somewhere else? Data generation perhaps?

Well, I wouldn't know, the entire class where the error is occurring is not shown. If you could provide a link to your repo, it would provide more detail. Also, you shouldn't use a vanilla block within a BlockItem placeholder. That will cause all instances of that block to believe that your item is its item representation.

Posted
6 minutes ago, StealthyNoodle said:

I see that I'm running a copy method on the torch, under the ItemTagsProvider (ModItemTagsProvider). That should be transfering data from the block tag into an item tag. Maybe that's what's causing the duplicate registration.

Nope, you're just registering the item twice. Your block calls this method which creates an item to which you then create another item under the same name.

  • Thanks 1
Posted
On 1/15/2021 at 5:19 PM, ChampionAsh5357 said:

Nope, you're just registering the item twice. Your block calls this method which creates an item to which you then create another item under the same name.


Fantastic - That would take me days to figure out!

spacer.png

Got it all up and running now. Thanks a lot, man!
 

 

On 1/15/2021 at 4:09 PM, ChampionAsh5357 said:

Also, you shouldn't use a vanilla block within a BlockItem placeholder. That will cause all instances of that block to believe that your item is its item representation.

I'll keep this in mind too

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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