Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[SOLVED] How to register WallOrFloorItem / Torch


Recommended Posts

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
Link to post
Share on other sites
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?

Link to post
Share on other sites
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.

Link to post
Share on other sites
17 minutes ago, ChampionAsh5357 said:

If you could provide a link to your repo, it would provide more detail.

Certainly! https://github.com/Fnkee/solidrocks

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.

Link to post
Share on other sites
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
Link to post
Share on other sites
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

Link to post
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.

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



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Goals and Tasks are defined within the flyweight Entity itself whenever it is constructed. I would suggest taking a look at already implemented entities with goals and tasks if you want to implement them yourself.
    • Any mod present on the server (assuming it doesn't have the ignore extension point set) must be present on the client to allow both to connect.
    • Yes, you are passing in an Item instead of a supplier of an item. I would suggest taking another read over the docs.
    • Hi again, I'm trying to create a custom living entity but I keep running into this issue that causes a crash due to a ticking entity. Crash: [12:31:15] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.crash.ReportedException: Ticking entity at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:855) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:787) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.integrated.IntegratedServer.tickServer(IntegratedServer.java:78) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:642) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:232) ~[forge:?] {re:classloading,pl:accesstransformer:B} at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282] {} Caused by: java.lang.NullPointerException at net.minecraft.entity.LivingEntity.travel(LivingEntity.java:1905) ~[forge:?] {re:classloading} at net.minecraft.entity.LivingEntity.aiStep(LivingEntity.java:2449) ~[forge:?] {re:classloading} at net.minecraft.entity.MobEntity.aiStep(MobEntity.java:488) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.entity.AgeableEntity.aiStep(AgeableEntity.java:115) ~[forge:?] {re:classloading} at net.minecraft.entity.passive.AnimalEntity.aiStep(AnimalEntity.java:51) ~[forge:?] {re:classloading} at net.minecraft.entity.LivingEntity.tick(LivingEntity.java:2158) ~[forge:?] {re:classloading} at net.minecraft.entity.MobEntity.tick(MobEntity.java:300) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tickNonPassenger(ServerWorld.java:611) ~[forge:?] {re:classloading} at net.minecraft.world.World.guardEntityTick(World.java:554) ~[forge:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.world.server.ServerWorld.tick(ServerWorld.java:404) ~[forge:?] {re:classloading} at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:851) ~[forge:?] {re:classloading,pl:accesstransformer:B} ... 5 more AL lib: (EE) alc_cleanup: 1 device not closed  It seems to be that I have not defined an ai/brain but I have no idea how to do this. I cant seem to see any event to do this in the library.  Any help would be greatly appreciated.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.