Jump to content

Recommended Posts

Posted

so im following this tutorial [https://cadiboo.github.io/tutorials/1.15.2/forge/1.7-itemgroup/] and I'm completely new to all of this. I'm literally copy and pasting while adding stuff so some lines are colored and styled like the site says but noting is working. This is what the log says:  

error: invalid method declaration; return type required
        public ModItemGroup(final String name, final Supplier<ItemStack> iconSupplier) {
               ^
1 error

this is the code

package com.[REDACTED].[REDACTED].init;


import java.util.function.Supplier;

import com.[REDACTED].[REDACTED].[REDACTED];
import net.minecraft.item.ItemGroup;
import net.minecraft.item.Items;

[File: ModItemGroups.java]


public static class ModItemGroup extends ItemGroup {

	private final Supplier<ItemStack> iconSupplier;
	public ModItemGroup(final String name, final Supplier<ItemStack> iconSupplier) {
		super(name);
		this.iconSupplier = iconSupplier;
	}
	@Override
	public ItemStack createIcon() {
		return iconSupplier.get();
	}
	public static final ItemGroup MOD_ITEM_GROUP = new ModItemGroup([REDACTED].MODID, () -> new ItemStack(ModItems.EXAMPLE_ITEM));
}
[File: ModItems.java]

package com.[REDACTED].[REDACTED].init;

import com.[REDACTED].[REDACTED].[REDACTED]; //Main File for the ModName.MODID so its colored and styled
import net.minecraftforge.registries.ObjectHolder;

@ObjectHolder([REDACTED].MODID)
public class ModItems {
	public static final Item EXAMPLE_ITEM = null;
}
[FIle: MOdEventSubscriber.java]

package com.[REDACTED].[REDACTED];

import com.[REDACTED].[REDACTED].init.ModItemGroup; // for stuff to be colored and styled

import net.minecraft.item.Items;//part of this i took from another post from the same problem I had eariler since I know nothing for inports and just barley started to understand gradle errors
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;

@Mod.EventBusSubscriber(modid = [REDACTED].MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ModEventSubscriber {

	@SubscribeEvent
	public static void onRegisterItems(RegistryEvent.Register<Item> event) {
		
		event.getRegistry().registerAll(
				setup(new Item(new Item.Properties().group(ModItemGroup.MOD_ITEM_GROUP)), "mega_cookie")
		);
	}

	public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final String name) {
        return setup(entry, new ResourceLocation([REDACTED].MODID, name));
	}
	public static <T extends IForgeRegistryEntry<T>> T setup(final T entry, final ResourceLocation registryName) {
        entry.setRegistryName(registryName);
        return entry;
    }


}

if anyone knows what the problem is or could give hints or something then please tell me

email is: [email protected]  [yea i know. made it when i was like 14 or something so about 4 years ago]

thanks

Posted

ok, i removed 'class' from "public static class ModItemGroup extends ItemGroup {" and now the "error:  invalid method declaration; return type required" doesn't show with "public static final ItemGroup MOD_ITEM_GROUP = new ModItemGroup(ExampleMod.MODID, () -> new ItemStack(Items.LIGHT_BLUE_BANNER));" being underlined but now im getting 

:\Users\dwzki\Desktop\minecraft mod making\mods\llamaMod\src\main\java\com\llama\llcstuff\init\ModItemGroups.java:10: error: class, interface, or enum expected
public static ModItemGroup extends ItemGroup {
              ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:12: error: class, interface, or enum expected
        private final Supplier<ItemStack> iconSupplier;
                      ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:13: error: class, interface, or enum expected
        public ModItemGroup(final String name, final Supplier<ItemStack> iconSupplier) {
               ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups. java:13: error: class, interface, or enum expected
        public ModItemGroup(final String name, final Supplier<ItemStack> iconSupplier) {
                                  ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:13: error: class, interface, or enum expected
        public ModItemGroup(final String name, final Supplier<ItemStack> iconSupplier) {
                                                     ^
C:\Users\dwzki\Desktop\minecraft mod making\mods\llamaMod\src\main\java\com\llama\llcstuff\init\ModItemGroups.java:15: error: class, interface, or enum expected
                return this.iconSupplier = iconSupplier;
                ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups. java:16: error: class, interface, or enum expected
        }
        ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:18: error: class, interface, or enum expected
        public ItemStack createIcon() {
               ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:20: error: class, interface, or enum expected
        }
        ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:21: error: class, interface, or enum expected
        public static final ItemGroup MOD_ITEM_GROUP = new ModItemGroup(LlamasMod.MODID, () -> new ItemStack(ModItems.EXAMPLE_ITEM));
                            ^
C:\Users\===\Desktop\minecraft mod making\mods\===\src\main\java\com\===\====\init\ModItemGroups.java:22: error: class, interface, or enum expected
}
^
11 errors

 

Posted

Why does your static class have a constructor?

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 (edited)

so......i forgot the maker of the tutorial had a github so i looked through it....my problem was that "public static final ItemGroup MOD_ITEM_GROUP = new ModItemGroup([REDACTED].MODID, () -> new ItemStack(ModItems.EXAMPLE_ITEM));" needed to be at the top and not at the bottom.  i. atleast i know how to read gradle logs now. sorry for the trouble

Edited by llamacorn1921

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



×
×
  • Create New...

Important Information

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