Jump to content

[1.15.2][Solved] Weird issue with adding blocks to creative tab


GhostGaming

Recommended Posts

I created a mod a few days ago but moved everything to a new project to tidy it up because I really wasn't happy with how unorganized everything was (although most things were working fine). For the most part, the code didn't change which is why I'm utterly confused on why the blocks are not being added to the creative inventory anymore. I tried it with a custom creative tab and also with the vanilla ones but it's not working in both cases. I checked whether the BlockItems are not being registered but they are. I can place the blocks down using /setblock, I can give them to myself using /give and place them down afterwards but they are not only not being rendered in the creative inv, they simply don't exist. Anyone has a clue why this could happen?

Edited by GhostGaming
Link to comment
Share on other sites

Just now, GhostGaming said:

Anyone has a clue why this could happen?

When you created your BlockItem instances did you set the ItemGroup via Item.Properties?

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

3 minutes ago, GhostGaming said:

Yes, I did. I used the code that Cadiboo used in his example mod

I don't need to look at someone else's code when I am helping you with your own. I have no guarantee you did everything Cadiboo did unless you directly copy-pasted his code.

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

Just now, Animefan8888 said:

I don't need to look at someone else's code when I am helping you with your own. I have no guarantee you did everything Cadiboo did unless you directly copy-pasted his code.

Basically, I loop through all my blocks in the item registry event and create and register a new ItemBlock with the ItemGroup. The weird thing is, that even when using one of my blocks as the tab icon it doesn't show up

Link to comment
Share on other sites

Just now, GhostGaming said:

Basically, I loop through all my blocks in the item registry event and create and register a new ItemBlock with the ItemGroup. The weird thing is, that even when using one of my blocks as the tab icon it doesn't show up

If you don't show us your code no one on here can actually help you all we can do is make shortsighted guesses on what could be causing your problem. If you don't feel comfortable sharing your code then don't and know we can't really help you.

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

1 minute ago, Animefan8888 said:

If you don't show us your code no one on here can actually help you all we can do is make shortsighted guesses on what could be causing your problem. If you don't feel comfortable sharing your code then don't and know we can't really help you.

Sorry, I was on my phone ?

 

My Mod class constructor:

public GhostsExplosives() {
	final ModLoadingContext modLoadingContext = ModLoadingContext.get();
	final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

	ModBlocks.BLOCKS.register(modEventBus);
	ModItems.ITEMS.register(modEventBus);
	ModEntityTypes.ENTITY_TYPES.register(modEventBus);

	modLoadingContext.registerConfig(ModConfig.Type.CLIENT, ConfigHolder.CLIENT_SPEC, "ghostsexplosives2-client.toml");
	modLoadingContext.registerConfig(ModConfig.Type.SERVER, ConfigHolder.SERVER_SPEC, "ghostsexplosives2-server.toml");
}

 

My ModBlocks class:

public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, GhostsExplosives.MODID);

public static final RegistryObject<BlockTNTGhostsExplosives> TNT_X1_2 = registerBlockTNT(TNTProperties.TNT_X1_2);

 

My ModEventBusSubscriber class:

@Mod.EventBusSubscriber(modid = GhostsExplosives.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEventBusSubscriber {
	@SubscribeEvent
	public static void onItemRegistry(RegistryEvent.Register<Item> event) {
		final IForgeRegistry<Item> registry = event.getRegistry();

		ModBlocks.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {
     			final Item.Properties properties = new Item.Properties().group(ItemGroup.SEARCH);
       			final BlockItem blockItem = new BlockItem(block, properties);
       			blockItem.setRegistryName(block.getRegistryName());
       			registry.register(blockItem);
       		});
	}

 

I think this should be everything important

Link to comment
Share on other sites

5 minutes ago, GhostGaming said:

I think this should be everything important

When, where, and how is ItemGroup.SEARCH initialized?

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

2020-04-13_15_00_59.thumb.png.661f16c806a7e9e3f88cf9cffac0c8db.png

Here is an image where I tried to add the block in the hotbar to my custom creative tab and set it as the tab icon

 

My custom ItemGroup class:

public class ModItemGroups {
	public static final ItemGroup ITEMGROUP_TNT_BLOCKS = new ModItemGroup("tnt_blocks", () -> new ItemStack(ModBlocks.TNT_X5.get()));
	public static final ItemGroup ITEMGROUP_TNT_MINECARTS = new ModItemGroup("tnt_minecarts", () -> new ItemStack(Items.TNT_MINECART));

	public static final class ModItemGroup extends ItemGroup {
		@Nonnull
		private final Supplier<ItemStack> iconSupplier;

		public ModItemGroup(@Nonnull final String name, @Nonnull final Supplier<ItemStack> iconSupplier) {
			super(GhostsExplosives.MODID + "." + name);
			this.iconSupplier = iconSupplier;
		}

		@Override
		@Nonnull
		public ItemStack createIcon() {
			return iconSupplier.get();
		}
	}
}

 

Edited by GhostGaming
Link to comment
Share on other sites

Just now, GhostGaming said:

Here is an image where I tried to add the block in the hotbar to the inventory and set it as the tab icon

Post your code as a working github repo I would like to test this locally to find an answer. I might be blind or missing information.

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

56 minutes ago, Animefan8888 said:

Post your code as a working github repo I would like to test this locally to find an answer. I might be blind or missing information.

I tried using GitHub Desktop to publish my repository but it looks like it completely wrecked my project because all my source files are gone, so I'm gonna cry now for a few days and maybe I'll come back here after I've implemented everything back ?

Link to comment
Share on other sites

10 minutes ago, GhostGaming said:

Well... I got my project back running and the issue still exists. Here is the github repository

Wait are you registering your Blocks twice? Here and here. I'm not sure how I didn't notice this. And commenting out the registry event fixes the issue. Register your Blocks once and only once.

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

3 minutes ago, Animefan8888 said:

Wait are you registering your Blocks twice? Here and here. I'm not sure how I didn't notice this. And commenting out the registry event fixes the issue. Register your Blocks once and only once.

So my blocks are being registered again just by subscribing to the registry event? Interesting, I though that event was just called after all blocks have been registered. But anyways, thanks for your help ?

Link to comment
Share on other sites

Just now, GhostGaming said:

So my blocks are being registered again just by subscribing to the registry event? Interesting, I though that event was just called after all blocks have been registered.

Actually I'm crazy sleep deprived, they aren't being registered twice. But commenting out the registry event does fix the problem. And honestly I don't have the brain capacity to see what exactly is happening but I'm gonna say the problem is your Items are getting a different version of the Block than what is actually registered. As such the Block to Item mapping is returning an air Block.

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

10 minutes ago, GhostGaming said:

So my blocks are being registered again just by subscribing to the registry event? Interesting, I though that event was just called after all blocks have been registered. But anyways, thanks for your help ?

Well.

Yes.

Because that's what that event is for. You use either a deferred register or the appropriate event.

 

Also:

// SET THE BLOCKS IN THE TNT PROPERTIES

...do that when you construct the block...seriously. You have a perfectly good place to do this already:

https://github.com/alessio1309/GhostsExplosives/blob/cd50068d6c3d5a213df7e7c8791b2b3d69470ffc/scr/main/java/mod/ghostgaming/ghostsexplosives2/init/ModBlocks.java#L73

Edited by Draco18s

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

48 minutes ago, Draco18s said:

Well.

Yes.

Because that's what that event is for. You use either a deferred register or the appropriate event.

 

Also:


// SET THE BLOCKS IN THE TNT PROPERTIES

...do that when you construct the block...seriously. You have a perfectly good place to do this already:

https://github.com/alessio1309/GhostsExplosives/blob/cd50068d6c3d5a213df7e7c8791b2b3d69470ffc/scr/main/java/mod/ghostgaming/ghostsexplosives2/init/ModBlocks.java#L73

Yes, I realized that as well, thank you anyways :)

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

Actually I'm crazy sleep deprived, they aren't being registered twice. But commenting out the registry event does fix the problem. And honestly I don't have the brain capacity to see what exactly is happening but I'm gonna say the problem is your Items are getting a different version of the Block than what is actually registered. As such the Block to Item mapping is returning an air Block.

I've examined what exactly caused the problem and it had nothing to do with the registry event but instead with registering the dispense behavior. I don't understand why this is happening but as soon as I register any sort of dispense behavior, even the default one, it won't show up in the creative inventory anymore. Really weird

Link to comment
Share on other sites

Just now, GhostGaming said:

I've examined what exactly caused the problem and it had nothing to do with the registry event but instead with registering the dispense behavior. I don't understand why this is happening but as soon as I register any sort of dispense behavior, even the default one, it won't show up in the creative inventory anymore. Really weird

Where are you doing it and how are you doing it?

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

1 minute ago, Animefan8888 said:

Where are you doing it and how are you doing it?

In the constructor of the block and by using DispenserBlock.registerDispenseBehavior()

DispenserBlock.registerDispenseBehavior(this, new DefaultDispenseItemBehavior() {
			protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
				World world = source.getWorld();
				BlockPos blockpos = source.getBlockPos().offset(source.getBlockState().get(DispenserBlock.FACING));

				BlockTNTGhostsExplosives block = (BlockTNTGhostsExplosives) ((BlockItem) stack.getItem()).getBlock();

				if (block.getProperties().isIgnitableByDispensers()) {
					EntityTNTGhostsExplosives tntentity = new EntityTNTGhostsExplosives(world, (double) blockpos.getX() + 0.5D, (double) blockpos.getY(), (double) blockpos.getZ() + 0.5D, (LivingEntity) null, block.getProperties());
					world.addEntity(tntentity);
					world.playSound(null, tntentity.getPosX(), tntentity.getPosY(), tntentity.getPosZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F);
					stack.shrink(1);
				} else {
					Direction direction = source.getBlockState().get(DispenserBlock.FACING);
					IPosition iposition = DispenserBlock.getDispensePosition(source);
					ItemStack itemstack = stack.split(1);
					doDispense(source.getWorld(), itemstack, 6, direction, iposition);
				}
				return stack;
			}
		});

 

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Slot Aster88 adalah bocoran slot rekomendasi gacor dari Aster88 yang bisa anda temukan di SLOT Aster88. Situs SLOT Aster88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Aster88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Aster88 merupakan SLOT Aster88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Aster88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Aster88 hari ini yang telah disediakan SLOT Aster88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Aster88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Aster88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Aster88 di link SLOT Aster88.
  • Topics

×
×
  • Create New...

Important Information

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