Jump to content

[1.15.2]Modded Block Not Registering Into Minecraft[solved]


Somonestolemyusername

Recommended Posts

This has been happening for a while. I have the Code written down in my files but for some reason its not registering the block into minecraft. same Thing with my ore. the ore was spawning in the map but it still wasn't actually registered into the game therefore i wasn't able to equip it

 

package com.vicken.mod3.util;


import com.vicken.mod3.items.ItemBase;
import com.vicken.mod3.items.TeleportStaff;
import com.vicken.mod3.list.SoundList;
import com.vicken.mod3.my_mod;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.OreBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.item.*;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;


public class RegistryHandler<name> {



    public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, my_mod.Mod_ID);
    public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, my_mod.Mod_ID);


    public static void init() {
        ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
    }

    // Items
    public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", ItemBase::new);
    public static final RegistryObject<Item> NETHERITE_INGOT = ITEMS.register("netherite_ingot", ItemBase::new);
    public static final RegistryObject<Item> FRUIT = ITEMS.register("fruit",
            () -> new Item(new Item.Properties().group(ModItemGroup.instance)
                    .food(new Food.Builder().hunger(4).saturation(2).build())));
    public static final RegistryObject<Item> TELEPORT_STAFF = ITEMS.register("teleport_staff",
            () -> new TeleportStaff(new Item.Properties().group(ModItemGroup.instance).maxDamage(50)));


    // Blocks
    public static final RegistryObject<Block> NETHERITE_BLOCK = BLOCKS.register("netherite_block",  () -> new Block(Block.Properties.create(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(1f, 1200f).harvestLevel(2).harvestTool(ToolType.PICKAXE).lightValue(10)));
    public static final RegistryObject<OreBlock> NETHERITE_ORE = BLOCKS.register("netherite_ore", () -> new OreBlock(Block.Properties.from(Blocks.IRON_ORE)));


    //Discs
    public static final RegistryObject<Item> BEN10_MUSIC_DISC = ITEMS.register("ben10_disc", () -> new MusicDiscItem(1, SoundList.BEN10_DISC_LAZY, new Item.Properties().maxStackSize(1).group(ModItemGroup.instance)));

    // a new creative tab
    public static class ModItemGroup extends ItemGroup {
        public static final ModItemGroup instance = new ModItemGroup(ItemGroup.GROUPS.length, "ExtrasMod");
        private ModItemGroup(int index, String label) {
            super(index, label);
        }

        @Override
        public ItemStack createIcon() {
            return new ItemStack(RUBY.get());
        }
    }


}

 

Edited by Somonestolemyusername
Link to comment
Share on other sites

i tried but it gave me and error saying

Required Type:      block

Provided:       RegistryObject   <net.minecraft.block.Block>

 

@SubscribeEvent
    public static void registerItems(final RegistryEvent.Register<Item> event)
    {
      	  {
        event.getRegistry().registerAll
                (
                        ItemList.netherite_block = new BlockItem(RegistryHandler.NETHERITE_BLOCK, new Item.Properties().group(RegistryHandler.ModItemGroup.instance)).setRegistryName(RegistryHandler.NETHERITE_BLOCK.getRegistryName())
      			);
                
       
    }

 

Edited by Somonestolemyusername
Link to comment
Share on other sites

the code is.down below. Also since I changed the code my Ore generation.java has errors.

 

@SubscribeEvent
public static void registerBlock(final RegistryEvent.Register<Block> event)
{
    event.getRegistry().registerAll
            (
                    BlockList.netherite_block = new Block(Block.Properties.create(Material.IRON).sound(SoundType.METAL)).setRegistryName(location("netherite_block"))
            );


}
@SubscribeEvent
public static void registerItems(final RegistryEvent.Register<Item> event)
{
    event.getRegistry().registerAll
            (
                    ItemList.netherite_block = new BlockItem(BlockList.netherite_block, new Item.Properties().group(RegistryHandler.ModItemGroup.instance)).setRegistryName(
 

 

Edited by Somonestolemyusername
Link to comment
Share on other sites

package com.vicken.mod3.util;


import com.vicken.mod3.items.ItemBase;
import com.vicken.mod3.items.TeleportStaff;
import com.vicken.mod3.list.BlockList;
import com.vicken.mod3.list.ItemList;
import com.vicken.mod3.list.SoundList;
import com.vicken.mod3.my_mod;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.OreBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.entity.layers.ArmorLayer;
import net.minecraft.item.*;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

import static com.vicken.mod3.my_mod.Mod_ID;


public class RegistryHandler<name> {



    public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, Mod_ID);
    public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, Mod_ID);


    public static void init() {
        ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
    }

    // Items
    public static final RegistryObject<Item> RUBY = ITEMS.register("ruby", ItemBase::new);
    public static final RegistryObject<Item> NETHERITE_INGOT = ITEMS.register("netherite_ingot", ItemBase::new);
    public static final RegistryObject<Item> FRUIT = ITEMS.register("fruit",
            () -> new Item(new Item.Properties().group(ModItemGroup.instance)
                    .food(new Food.Builder().hunger(4).saturation(2).build())));
    public static final RegistryObject<Item> TELEPORT_STAFF = ITEMS.register("teleport_staff",
            () -> new TeleportStaff(new Item.Properties().group(ModItemGroup.instance).maxDamage(50)));


    // Blocks
       public static final RegistryObject<OreBlock> NETHERITE_ORE = BLOCKS.register("netherite_ore", () -> new OreBlock(Block.Properties.from(Blocks.IRON_ORE)));

    @SubscribeEvent
    public static void registerBlock(final RegistryEvent.Register<Block> event)
    {
        event.getRegistry().registerAll
                (
                        BlockList.netherite_block = new Block(Block.Properties.create(Material.IRON).sound(SoundType.METAL)).setRegistryName(location("netherite_block"))
                );


    }
    @SubscribeEvent
    public static void registerItems(final RegistryEvent.Register<Item> event)
    {
        event.getRegistry().registerAll
                (
                        ItemList.netherite_block = new BlockItem(BlockList.netherite_block, new Item.Properties().group(RegistryHandler.ModItemGroup.instance)).setRegistryName(BlockList.netherite_block.getRegistryName())
                );


    }

    public static ResourceLocation location(String name)
    {
        return new ResourceLocation(Mod_ID, name);
    }


    //Discs
    public static final RegistryObject<Item> BEN10_MUSIC_DISC = ITEMS.register("ben10_disc", () -> new MusicDiscItem(1, SoundList.BEN10_DISC_LAZY, new Item.Properties().maxStackSize(1).group(ModItemGroup.instance)));

    //Armor


    // a new creative tab
    public static class ModItemGroup extends ItemGroup {
        public static final ModItemGroup instance = new ModItemGroup(ItemGroup.GROUPS.length, "ExtrasMod");
        private ModItemGroup(int index, String label) {
            super(index, label);
        }

        @Override
        public ItemStack createIcon() {
            return new ItemStack(RUBY.get());
        }
    }


}

 

Link to comment
Share on other sites

the ore isint broken it works perfectly its just like the netherite block(the ore did not get deleted) it did not appear in the inv. but when i add block items to the ore it gives an error for OreGeneration.java because its supposed to be 

 

RegistryHandler.NETHERITE_ORE.get().getDefaultState(), 10))

and I dont know what i would change it to if i make it with the ItemList.netherite_ore method

 

Link to comment
Share on other sites

7 minutes ago, Somonestolemyusername said:

well i want to do it with DeferredRegister but I dont know how im going to add it in with that. I was gonna watch the technovison tut but he made his vids unlisted so idk how im gonna make the block item with deferred register

You could always read the documentation on how to use deferred register.

Link to comment
Share on other sites

24 minutes ago, diesieben07 said:

I told you: "Your issue is because you did not add a BlockItem for your blocks". You then added the BlockItem for netherite_block. Then you complained that it still did not work for the ore.

I am baffled by this, because you obviously did not apply the fix for the ore and yet are surprised that the ore is still broken.

i did say it was for the ore because i also added that to it but then acedently undoed all of it which made me lose everything i wrote there

 

Edited by Somonestolemyusername
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

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

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