Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Missing registry object


Recommended Posts

I'm trying to register an object that uses other items in the class but I'm not sure how to make it register properly

 

Blueprints.java: (creating new blueprint)
 

public class Blueprints {

    private static final List<Blueprint.Resource> SKANA_RESOURCES =
            Arrays.asList(
                    new Blueprint.Resource(Items.STICK, 1),
                    new Blueprint.Resource(Resources.MORPHICS.get(), 1)
            );
    public static final RegistryObject<Item> SKANA_BLUEPRINT =
            Registration.ITEMS.register("skana_blueprint",
                    () -> new Blueprint(new Item.Properties().tab(TennoMC.TAB_TENNO), 
                            SKANA_RESOURCES,
                            Swords.SKANA.get())
            );
    
    public static void register() {}
}

Blueprint.java: (my new class)

public class Blueprint extends Item {

    public List<Resource> resources;
    public Item outputItem;

    public Blueprint(Properties properties, List<Resource> resources, Item outputItem) {
        super(properties);
        this.resources = resources;
        this.outputItem = outputItem;
    }


    public static class Resource {
        public final Item item;
        public final int amount;

        public Resource(Item item, int amount) {
            this.item = item;
            this.amount = amount;
        }
    }
}

Registration.java:

public class Registration {

    public static final DeferredRegister<Item> ITEMS =
            DeferredRegister.create(ForgeRegistries.ITEMS, TennoMC.MOD_ID);

    public static void init() {
        IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
        ITEMS.register(eventBus);
    }
}

TennoMC.java:

public TennoMC {
  registerModAdditions();
}

private void registerModAdditions() {

        // Inits additions
        Registration.init();

        // Inits in game items
        Resources.register();
        Blueprints.register();
}

 

Link to post
Share on other sites

Fixed the issue by referring to the ResourceLocation instead of Item.

Like so:

public class Blueprint extends Item {

    public List<Resource> resources;
    public ResourceLocation outputItem;

    public Blueprint(Properties properties, List<Resource> resources, ResourceLocation outputItem) {
        super(properties);
        this.resources = resources;
        this.outputItem = outputItem;
    }


    public static class Resource {
        public final ResourceLocation resourceLocation;
        public final int amount;

        public Resource(ResourceLocation resourceLocation, int amount) {
            this.resourceLocation = resourceLocation;
            this.amount = amount;
        }
    }
}

 

Link to post
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.

Guest
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.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Ok i can't make it work. It gives me this error "java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/tileentity/ItemStackTileEntityRenderer for invalid dist DEDICATED_SERVER" I try to move the chestRenderer() methods to a separate class but it keeps to give me this error. I don't know how to separate the Supplier<Callable<ItemStackTileEntityRenderer>> renderMethod parameter to the server registration. I tryied to make a class for only the items, removing it from the Blocks class:   public class Items { public static final DeferredRegister<Item> ITEMS; private static final RegistryObject<Item> MINI_CHEST; private static final RegistryObject<Item> SMELTING_CHEST; private static final RegistryObject<Item> INVISIBLE_CHEST; private static final RegistryObject<Item> TRAP_CHEST; private static final RegistryObject<Item> PITFALL_CHEST; private static final RegistryObject<Item> DRILL_CHEST; private static final RegistryObject<Item> TELEPORT_CHEST; private static final RegistryObject<Item> LOOT_CHEST; private static final RegistryObject<Item> MONSTER_CHEST; private static final RegistryObject<Item> POCKET_DIMENSION_CHEST; private static final RegistryObject<Item> COLOSSAL_CHEST; static { ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TenChest.MODID); MINI_CHEST = register("mini_chest", Blocks.MINI_CHEST, ItemBlockRenderer::baseChestRenderer); SMELTING_CHEST = register("smelting_chest", Blocks.SMELTING_CHEST, ItemBlockRenderer::smeltingChestRenderer); INVISIBLE_CHEST = register("invisible_chest", Blocks.INVISIBLE_CHEST, ItemBlockRenderer::baseChestRenderer); TRAP_CHEST = register("trap_chest", Blocks.TRAP_CHEST, ItemBlockRenderer::baseChestRenderer); PITFALL_CHEST = register("pitfall_chest", Blocks.PITFALL_CHEST, ItemBlockRenderer::baseChestRenderer); DRILL_CHEST = register("drill_chest", Blocks.DRILL_CHEST, ItemBlockRenderer::baseChestRenderer); TELEPORT_CHEST = register("teleport_chest", Blocks.TELEPORT_CHEST, ItemBlockRenderer::teleportChestRenderer); LOOT_CHEST = register("loot_chest", Blocks.LOOT_CHEST, ItemBlockRenderer::lootChestRenderer); MONSTER_CHEST = register("monster_chest", Blocks.MONSTER_CHEST, ItemBlockRenderer::baseChestRenderer); POCKET_DIMENSION_CHEST = register("pocket_dimension_chest", Blocks.POCKET_DIMENSION_CHEST, ItemBlockRenderer::pocketDimensionChestRenderer); COLOSSAL_CHEST = register("colossal_chest", Blocks.COLOSSAL_CHEST, ItemBlockRenderer::baseChestRenderer); } private static <T extends Item> RegistryObject<T> register(String name, RegistryObject<Block> block, Supplier<Callable<ItemStackTileEntityRenderer>> renderMethod) { return register(name, block, (item) -> item(block, renderMethod)); } private static <T extends Item> RegistryObject<T> register(String name, RegistryObject<Block> ret, Function<RegistryObject<Block>, Supplier<? extends Item>> itemCreator) { return ITEMS.register(name, (Supplier) itemCreator.apply(ret)); } private static Supplier<BlockItem> item(RegistryObject<? extends Block> block, Supplier<Callable<ItemStackTileEntityRenderer>> renderMethod) { return () -> { BlockItem blockItem = new BlockItem(block.get(), (new Item.Properties().tab(TenChest.MOD_GROUP).setISTER(renderMethod))); return blockItem; }; } } But the items are not registered, and i don't know why. It gives to me this:   [16:06:18] [Render thread/INFO] [ne.mi.re.GameData/REGISTRIES]: Injecting existing registry data into this CLIENT instance [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:colossal_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:colossal_chest_part [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:drill_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:invisible_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:loot_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:mini_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:monster_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:pitfall_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:pocket_dimension_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:smelting_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:teleport_chest [16:06:18] [Render thread/INFO] [ne.mi.re.ForgeRegistry/REGISTRIES]: Registry Item: Found a missing id from the world tenchest:trap_chest [16:06:18] [Render thread/DEBUG] [ne.mi.re.GameData/REGISTRIES]: There are 12 mappings missing - attempting a mod remap [16:06:18] [Render thread/ERROR] [ne.mi.re.GameData/REGISTRIES]: Unidentified mapping from registry minecraft:item tenchest:colossal_chest: 987 tenchest:colossal_chest_part: 986 tenchest:drill_chest: 981 tenchest:invisible_chest: 978 tenchest:loot_chest: 983 tenchest:mini_chest: 976 tenchest:monster_chest: 984 tenchest:pitfall_chest: 980 tenchest:pocket_dimension_chest: 985 tenchest:smelting_chest: 977 tenchest:teleport_chest: 982 tenchest:trap_chest: 979  
    • I've tried to play my old world with mods, but Minecraft just crashes after the mods loading screen. The Minecraft version is 1.12.2 and the Forge version is the latest one, 14.23.5.2855   I've already reinstalled forge, deleted the mods and using the previous version (which I used originally and worked) and even using different versions of Java, so I don't know what else to do   The debug.log file is this: https://pastebin.com/vwLHWvFE . The error is in the line 332, I hope it helps.   Thanks in advance
    • https://github.com/DefDaemon/Daemons_Horror_Moon/blob/02a0d917a9738e7f7076865abb4a74de0e97eb3c/src/main/java/com/defdaemon/horrormoon/lists/ToolMaterialList.java#L9 You cannot access your items here yet, the registration has not happened yet. Store the supplier instead of the item.
    • I have a problem about my game keep crashing because of my code. Code: package net.flexstudios.armorytests.items; import com.google.common.collect.Multimap; import net.minecraft.entity.ai.attributes.Attribute; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.*; public class PoweredChestplateItem extends ArmorItem { public PoweredChestplateItem(IArmorMaterial materialIn, EquipmentSlotType slot, Properties builder) { super(materialIn, slot, builder); } @Override public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType equipmentSlot) { Multimap<Attribute, AttributeModifier> result = super.getAttributeModifiers(equipmentSlot); result.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Armor dmg", (double)4, AttributeModifier.Operation.ADDITION)); return result; } } A part of the crashing report: Description: Initializing game java.lang.UnsupportedOperationException: null at com.google.common.collect.ImmutableMultimap.put(ImmutableMultimap.java:427) ~[guava-21.0.jar:?] {} at net.flexstudios.armorytests.items.PoweredChestplateItem.func_111205_h(PoweredChestplateItem.java:19) ~[?:beta1.0.0] {re:classloading} at net.minecraftforge.common.extensions.IForgeItem.getAttributeModifiers(IForgeItem.java:77) ~[?:?] {re:classloading} at net.minecraft.item.ItemStack.func_111283_C(ItemStack.java:844) ~[?:?] {re:classloading} at net.minecraft.item.ItemStack.func_82840_a(ItemStack.java:614) ~[?:?] {re:classloading} at net.minecraft.client.Minecraft.lambda$populateSearchTreeManager$7(Minecraft.java:642) ~[?:?]  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.