Jump to content

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


Recommended Posts

Posted (edited)

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
Posted
  On 4/13/2020 at 12:17 PM, GhostGaming said:

Anyone has a clue why this could happen?

Expand  

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.

Posted
  On 4/13/2020 at 12:25 PM, GhostGaming said:

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

Expand  

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.

Posted
  On 4/13/2020 at 12:31 PM, 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.

Expand  

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

Posted
  On 4/13/2020 at 12:34 PM, 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

Expand  

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.

Posted
  On 4/13/2020 at 12:36 PM, 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.

Expand  

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

Posted (edited)

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
Posted
  On 4/13/2020 at 1:03 PM, 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

Expand  

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.

Posted
  On 4/13/2020 at 1:07 PM, 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.

Expand  

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 ?

Posted
  On 4/13/2020 at 5:43 PM, GhostGaming said:

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

Expand  

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.

Posted
  On 4/13/2020 at 6:07 PM, 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.

Expand  

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 ?

Posted
  On 4/13/2020 at 6:14 PM, 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.

Expand  

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.

Posted (edited)
  On 4/13/2020 at 6:14 PM, 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 ?

Expand  

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.

Posted
  On 4/13/2020 at 6:23 PM, 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

Expand  

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

Posted
  On 4/13/2020 at 6:23 PM, 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.

Expand  

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

Posted
  On 4/13/2020 at 7:44 PM, 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

Expand  

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.

Posted
  On 4/13/2020 at 7:46 PM, Animefan8888 said:

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

Expand  

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;
			}
		});

 

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

    • Honestly just want to play with my brother but LAN won't work for us so we have to try this.. Anyone?
    • Got modded, shit ton custom pack. Tried making a world, and it kicked me out saying that. Singelplayer. https://pastesio.com/crash-3317
    • I received an unexpected email claiming that a long-lost relative had left me a substantial inheritance $140,000 in cryptocurrency At first I was skeptical The message came with a lot of convincing documents legal jargon and even a supposed lawyer’s contact information They insisted everything was legitimate and the funds were waiting to be transferred All I needed to do they said was cover a few minor processing and transfer fees It seemed like a small price to pay for such a large windfall Against my better judgment I paid the fees Then more fees followed They kept assuring me the payout was right around the corner Weeks went by and the excuses kept coming Eventually it became clear this was a sophisticated scam The $140K inheritance was never real and I had been tricked into sending thousands of dollars to fraudsters embarrassed I started researching online and came across Byte phantom cyber services I was hesitant at first after all I had just been scammed But their website had positive reviews and they specialized in cryptocurrency fraud I reached out not expecting much To my surprise they responded quickly and professionally They were incredibly understanding and didn't make me feel foolish Their team walked me through the process step by step They used digital forensics and blockchain tracing techniques to track down the wallet addresses involved in the scam Within weeks they identified the fraudsters and began recovery efforts To my amazement Byte phantom cyber services recovered 100% of my lost funds Every cent I honestly couldn’t believe it They taught me how to recognize red flags avoid similar traps in the future and protect my digital identity I now feel empowered and informed not just lucky If you've been scammed or even suspect it don't stay silent Reach out to Byte phantom cyber services I got my money back
    • abro el juego pero al tocar un solo jugador me tira la de   [02:23:30] [Render thread/FATAL] [ne.mi.co.ForgeMod/]: Preparing crash report with UUID c3ff08d5-d285-458d-a3b5-fbba17743dff #@!@# Game crashed! Crash report saved to: #@!@# C:\juegos\Minecraft\instances\1.20.1 forge\.minecraft\crash-reports\crash-2025-05-02_02.23.30-client.txt Process exited with code -1 (0xffffffffffffffff). ¡Por favor, ten en cuenta que normalmente ni el código de salida ni su descripción son suficientes para diagnosticar problemas! Sube siempre el registro entero y no solo el código de salida.
    • So, First of I am new to modding so bare with me I am creating a 1.20.1 forge mod that needs Oculus/Embeddium as a dependancy because later on I need to add custom shaders in for lights and such. I am using ParchmentMC as I've heard its better because of namings of things but that doesn't seem to like it when I run it alongside Oculus (Its a very barebones script adding two blocks and an item, and tested it before I did this) The 4 errors I get when I run 'runClient' is Caused by: org.spongepowered.asm.mixin.transformer.throwables.MixinTransformerError: An unexpected critical error was encountered Caused by: org.spongepowered.asm.mixin.throwables.MixinApplyError: Mixin [mixins.oculus.json:texture.MixinAbstractTexture] from phase [DEFAULT] in config [mixins.oculus.json] FAILED during APPLY Caused by: org.spongepowered.asm.mixin.injection.throwables.InvalidInjectionException: Critical injection failure: @Inject annotation on iris$afterGenerateId could not find any targets matching 'Lnet/minecraft/client/renderer/texture/AbstractTexture;m_117963_()I' in net.minecraft.client.renderer.texture.AbstractTexture. Using refmap oculus-mixins-refmap.json [PREINJECT Applicator Phase -> mixins.oculus.json:texture.MixinAbstractTexture -> Prepare Injections ->  -> handler$zgm000$iris$afterGenerateId(Lorg/spongepowered/asm/mixin/injection/callback/CallbackInfoReturnable;)V -> Parse] And then a "Execution failed for task ':runClient'." error My dependancies are just these with latest forge for 1.20.1 implementation fg.deobf('curse.maven:oculus-581495:6020952') // Oculus for 1.20.1 - 1.8.0  implementation fg.deobf('curse.maven:embeddium-908741:5681725') // Embeddium for 1.20.1 - 0.3.31 I have tested these mods & forge in a different modpack alone and it works fine Any help is much appreciated!
  • Topics

×
×
  • Create New...

Important Information

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