Jump to content

I have an error on creating an item in 1.15.2


Yunus Emre

Recommended Posts

package com.yunus.sinif.util;

import com.yunus.sinif.DenemeMod;
import com.yunus.sinif.items.ItemBase;
import net.minecraft.item.Item;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

public class RegistryHandler {

    private static final String MOD_ID = DenemeMod.MOD_ID;

    public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, "dp");

    public static void init(){

        ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());

    }

    public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", ItemBase::new);

}

 

public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, "dp");

 

but this line returns me an error.

I dont know what is error just new DeferredRegister<> strikethrough

 

can you help me? 

 

discord: Даяк Ыаде#3511

Link to comment
Share on other sites

21 minutes ago, Yunus Emre said:

but this line returns me an error.

I dont know what is error just new DeferredRegister<> strikethrough

A warning is not an error. An error is an error. It's letting you know that this method of calling the constructor is deprecated and should be replaced with DeferredRegister::create. However, you could of found this out by hovering over the strike-through.

Link to comment
Share on other sites

5 minutes ago, ChampionAsh5357 said:

A warning is not an error. An error is an error. It's letting you know that this method of calling the constructor is deprecated and should be replaced with DeferredRegister::create. However, you could of found this out by hovering over the strike-through.

C:\Users\Pc\Desktop\1.15.2 mod from yunus\src\main\java\com\yunus\sinif\util\RegistryHandler.java:15: error: '(' or '[' expected
    public static final DeferredRegister<Item> ITEMS = new DeferredRegister::create(ForgeRegistries.ITEMS, MOD_ID);
                                                                                                                                                        ^

Link to comment
Share on other sites

3 minutes ago, Yunus Emre said:

new DeferredRegister::create

I need a facepalm emoji so badly. I use the double colon operator to specify the location of a function. Let's break down what you wrote. First, you tried calling a static method using the double colon operator. Please learn some basic java and don't just follow some youtube tutorial. If you want a hint, a dot helps. Second, you called new on a method. You can only call new on constructors to create objects. A method is not a constructor. In this case, DeferredRegister::create is a static method for a constructor initialization circumventing the new operator (its called inside).

 

And the easiest way you could've found this out is by reading the docs.

Link to comment
Share on other sites

2 minutes ago, ChampionAsh5357 said:

I need a facepalm emoji so badly. I use the double colon operator to specify the location of a function. Let's break down what you wrote. First, you tried calling a static method using the double colon operator. Please learn some basic java and don't just follow some youtube tutorial. If you want a hint, a dot helps. Second, you called new on a method. You can only call new on constructors to create objects. A method is not a constructor. In this case, DeferredRegister::create is a static method for a constructor initialization circumventing the new operator (its called inside).

 

And the easiest way you could've found this out is by reading the docs.

 

I am watching this video: 

 

 

 

 

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



×
×
  • Create New...

Important Information

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