Jump to content

Recommended Posts

Posted (edited)

Probably a common issue with a simple fix, but i cannot figure it out, the copper ingot texture & name are not registering in testing.

 

I'm following TechnoVision's 1.15.2 modding tutorials, for reference.

 

Here's the 16x16 png texture for the ingot, which I have put in src/main/resources/assets/necessarytechnology/textures/items: copper_ingot.png

It's file shares the same name as the item, copper_ingot.


NecessaryTechonology.java, which is in src/main/java/com.cyphon.necessarytechnology

package com.cyphon.necessarytechnology;


import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import util.RegistryHandler;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.stream.Collectors;

@Mod("necessarytechnology")
public class NecessaryTechnology
{
    private static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "necessarytechnology";

    public NecessaryTechnology() {
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
        RegistryHandler.init();

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        LOGGER.info("HELLO FROM PREINIT");
        LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
    }

    private void doClientStuff(final FMLClientSetupEvent event) {
        LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
    }

    private void enqueueIMC(final InterModEnqueueEvent event)
    {
        InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
    }

    private void processIMC(final InterModProcessEvent event)
    {
        LOGGER.info("Got IMC {}", event.getIMCStream().
                map(m->m.getMessageSupplier().get()).
                collect(Collectors.toList()));
    }
    @SubscribeEvent
    public void onServerStarting(FMLServerStartingEvent event) {
        LOGGER.info("HELLO from server starting");
    }

    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
        @SubscribeEvent
        public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
            LOGGER.info("HELLO from Register Block");
        }
    }
}

 

 

ItemBase.java, which is in src/main/java/items:

package items;

import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;

public class ItemBase extends Item {

        
        public ItemBase() {
            super(new Item.Properties().group(ItemGroup.MATERIALS));
        }
    
    }

 

RegistryHandler.java, which is in src/main/java/util:

package util;

import com.cyphon.necessarytechnology.NecessaryTechnology;

import 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 {
    
    public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, NecessaryTechnology.MOD_ID);
    
    public static void init() {ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());}
    
    // Items
    public static final RegistryObject<Item> COPPER_INGOT = ITEMS.register("copper_ingot", ItemBase::new);

}

 

en_us.json, which is in src/main/resources/assets/necessarytechnology/lang:

{
"item.necessarytechnology.copper_ingot": "Copper Ingot"
}

 

copper_ingot.json, which is in src/main/resources/assets/necessarytechnology/models/item:

{
  "parent": "item/generated",
  "textures": {
    "layer0": "necessarytechnology:items/copper_ingot"
  }
}

 

Thanks in advance!

Edited by Cyphon
fixed file location typos
Posted
27 minutes ago, Cyphon said:

src/main/resources/assets/models/item

You forgot to include a folder with your mod ID.

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
1 hour ago, Cyphon said:

I'm following TechnoVision's 1.15.2 modding tutorials, for reference.

Please, don't, they're pretty bad. It's better for you to look at vanilla examples and other people's mods like Botania.

 

1 hour ago, Cyphon said:

ItemBase.java, which is in src/main/java/items:

Don't make base item classes, it'll just be a nuisance when you want to extend something else.

Besides that looking at your problem I don't see anything wrong, post more code, preferably as a git repo.

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Posted (edited)
1 hour ago, Cyphon said:

ItemBase.java, which is in src/main/java/items:

There's already an "item base" class, its called Item and is in the net.minecraft.item package.

 

Any reason you're using a deferred register for your items, but a registry event for your blocks?

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

I'll be starting fresh with this mod, not like I had much.

 

Learning how Minecraft is coded directly from it's code sounds like exactly what I want.

 

How would I go about looking through vanilla code in Eclipse?

Or is there another program you would reccomend?

Posted
3 minutes ago, Cyphon said:

I'll be starting fresh with this mod, not like I had much.

 

Learning how Minecraft is coded directly from it's code sounds like exactly what I want.

 

How would I go about looking through vanilla code in Eclipse?

Or is there another program you would reccomend?

Referenced libraries

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

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.