• 0

    posted a message on Minecraft Modding Forge textures

    Thank you for your reply. I'm currently modding in the Minecraft version 1.16.1. Below you can see the code

    This is my registration:


    package net.PigBoss.tutorial.setup;

    import net.PigBoss.tutorial.TutorialMod;
    import net.minecraft.block.Block;
    import net.minecraft.item.Item;
    import net.minecraftforge.eventbus.api.IEventBus;
    import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
    import net.minecraftforge.registries.DeferredRegister;
    import net.minecraftforge.registries.ForgeRegistries;

    public class Registration {
    public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TutorialMod.MOD_ID);
    public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TutorialMod.MOD_ID);

    public static void register(){
    IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
    BLOCKS.register(modEventBus);
    ITEMS.register(modEventBus);

    ModBlocks.register();
    ModItems.register();
    }

    }


    This is my main:


    @Mod(TutorialMod.MOD_ID)
    public class TutorialMod {
    public static final String MOD_ID = "tutorial";

    private static final Logger LOGGER = LogManager.getLogger();

    public TutorialMod() {
    Registration.register();



    FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);

    FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);

    FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);

    FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);


    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");
    }
    }

    This is my Block class:


    public class ModBlocks {
    public static final RegistryObject<Block> SILVER_ORE = register("silver_ore", () ->
    new Block(AbstractBlock.Properties.create(Material.ROCK).hardnessAndResistance(3, 10).harvestLevel(2).sound(SoundType.STONE)));
    public static final RegistryObject<Block> SILVER_BLOCK = register("silver_block", () ->
    new Block(AbstractBlock.Properties.create(Material.IRON).hardnessAndResistance(3, 10).sound(SoundType.METAL)));
    static void register() {}

    private static <T extends Block>RegistryObject<T> registerNoItem(String name, Supplier<T> block) {
    return Registration.BLOCKS.register(name, block);
    }
    private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> block) {
    RegistryObject<T> ret = registerNoItem(name, block);
    Registration.ITEMS.register(name, () -> new BlockItem(ret.get(), new Item.Properties().group(ItemGroup.BUILDING_BLOCKS)));
    return ret;
    }

    }

    This is Items:


    public class ModItems {
    public static final RegistryObject<Item> SILVER_INGOT = Registration.ITEMS.register("silver_ingot", () ->
    new Item(new Item.Properties().group(ItemGroup.MATERIALS)));

    static void register(){
    }
    }


    Note: I did not include the imports of the libs because they are a lot and unnecessary anyway for you.

    Posted in: Modification Development
  • 0

    posted a message on Minecraft Modding Forge textures
    Hey guys, I'm fairly new to mc modding and I was wondering how do I import textures to my custom and existing blocks and items. They are all done but dont have a texture. What I need is how do I assign the textures to the blocks and items, how to import textures and how to register them in generell. Or is there any good tutorial for easily getting into how to import textures?


    Thanks in advance!
    Posted in: Modification Development
  • To post a comment, please .