Jump to content

Recommended Posts

Posted (edited)

So I'm following some tutorials, and I'm trying to use them is ways other than exactly what they're doing (which helps me learn faster), but I may have caused problems by doing that... So the first problem started when I had a block and an item for that block. I could /setblock the block just fine, no errors. But when I /give-d myself the item, it says "an internal error occurred when running this command" and immediately crashed. I didn't understand what was wrong, but after some messing around I managed to make it stop doing that... With the slight side effect that the game wont even load. It just throws a bunch of errors, and comes up with a screen saying "1 error occurred". I have no clue how to fix this (the error seems blatantly unconnected), so I decided to ask about it here. I am using 1.14.4.

This is my main file (Noodles)

package com.happyhippo77.noodles;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("noodles")
public class Noodles {
    public static final String MODID = "noodles";

    // Directly reference a log4j logger.
    public static final Logger LOGGER = LogManager.getLogger();

    public Noodles() {
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);

    }

    private void setup(final FMLCommonSetupEvent event) {

    }
}

 

This is the file for the block (NoodleOre) don't ask why the obsession with noodles, I don't know
 

package com.happyhippo77.noodles.blocks.properties;

import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;

public class NoodleOre extends Block {
    public NoodleOre() {
        super(Properties.create(Material.ROCK)
                .sound(SoundType.STONE)
                .hardnessAndResistance(2.0f)
        );
        setRegistryName("noodle_ore");
    }
}


Here's the file for the blocks (ModBlocks)
 

package com.happyhippo77.noodles.blocks;

import com.happyhippo77.noodles.Noodles;
import com.happyhippo77.noodles.blocks.properties.NoodleOre;
import net.minecraft.block.Block;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ObjectHolder;

@Mod.EventBusSubscriber(modid = Noodles.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
@ObjectHolder(Noodles.MODID)
public class ModBlocks {
        @SubscribeEvent
        public static void onBlocksRegistry(final RegistryEvent.Register<Block> event) {
            // register a new block here
            event.getRegistry().register(new NoodleOre());
            Noodles.LOGGER.info("Registered Blocks");
        }

    public static NoodleOre NOODLE_ORE = null;
}

 

And here's the file for the items (ModItems)
 

package com.happyhippo77.noodles.items;

import com.happyhippo77.noodles.Noodles;
import com.happyhippo77.noodles.blocks.ModBlocks;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = Noodles.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModItems {

    @SubscribeEvent
    public static void onItemsRegistry(final RegistryEvent.Register<Item> event) {
        // register a new block here
        event.getRegistry().register(new BlockItem(ModBlocks.NOODLE_ORE, new Item.Properties()).setRegistryName(ModBlocks.NOODLE_ORE.getRegistryName()));
        Noodles.LOGGER.info("Registered Items");
    }
}


 

Overall the code is just kind of erratic, so there's probably some really idiotic mistake in there that I can't see. Nonetheless, I really can't figure it out, so any help is appreciated!

Oh yeah, and here's the console from around the time the errors start to where they end.
 

  Reveal hidden contents

 

Edited by HappyHippo77
Posted (edited)

ModBlocks::NOODLE_ORE is always null. You've never give it a value.

Edited by DavidM

Some tips:

  Reveal hidden contents

 

Posted

From the looks, nothing that you're doing in your block's constructor should be there, also why are you registering your block to receive events?

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 2/22/2020 at 12:56 AM, DaemonUmbra said:

From the looks, nothing that you're doing in your block's constructor should be there, also why are you registering your block to receive events?

Expand  

I'm not entirely sure what this means, nor how I should fix it. What is a constructor, and what is a receive event, and what should I be doing instead?

Posted
  On 2/22/2020 at 8:07 PM, HappyHippo77 said:

What is a constructor, and what is a receive event, and what should I be doing instead?

Expand  

Not what you want to hear, but you honestly should probably be learning basic Java/OOP. Not knowing what a constructor is is a bad thing.

  • Like 1
Posted
  On 2/22/2020 at 10:11 PM, Ugdhar said:

Not what you want to hear, but you honestly should probably be learning basic Java/OOP. Not knowing what a constructor is is a bad thing.

Expand  

I already have a basic understanding of how Java functions. I can get around alright in a Java environment. I guess I just never heard "constructor" before.

One problem that I may have is that I can't learn Java well with anything except Forge. I only learn well when I'm doing something I find interesting, and the boring, drawling, here's-this-now-go-use-it tutorials you usually find never teach me anything I'll remember. I'll end up learning Forge faster if I just learn to use Forge than if I spend forever scurrying around trying to find the smallest shred of a good resource for Java.

  • Like 1
Posted (edited)

- NoodleOre (Block) needs a registry name (noodle_ore)

- The public static field NOODLE_ORE (ModBlocks class) will always be null because afaik ObjectHolder pupulates only PSF fields, not PS (so make it final)

 

Not sure about the 2nd point though, check the ObjectHolder class, I think its explained in there

 

EDIT: NVM just seen that you set the registry name inside the constructor.

Edited by CAS_ual_TY
Posted
  On 2/22/2020 at 11:06 PM, HappyHippo77 said:

I already have a basic understanding of how Java functions. I can get around alright in a Java environment. I guess I just never heard "constructor" before.

One problem that I may have is that I can't learn Java well with anything except Forge. I only learn well when I'm doing something I find interesting, and the boring, drawling, here's-this-now-go-use-it tutorials you usually find never teach me anything I'll remember. I'll end up learning Forge faster if I just learn to use Forge than if I spend forever scurrying around trying to find the smallest shred of a good resource for Java.

Expand  

Forge has a very good API/ Docs for Minecraft 1.14.x - 1.15.x. You simply need to see on the Docs and: https://mcforge.readthedocs.io/en/latest/concepts/registries/#injecting-registry-values-into-fields

New in Modding? == Still learning!

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

    • That is incorrect. Use the run.bat or run.sh to run the server.
    • Hello, I have been trying for days to create my server with forge-1.20.1-47.4.1-installer, which installs the server, but the forge-1.20.1-47.4.1.jar file, which is necessary to create the server, does not appear. I no longer know what to do. Help. hola buenas, llevo dias intentando poder hacer mi servidor con forge-1.20.1-47.4.1-installer el cual instalo el server, pero no aparece el archivo forge-1.20.1-47.4.1.jar , el cual es necesario para poder crear el server, ya no se que hacer ayuda.
    • Does this happen if you use the regular vanilla minecraft launcher? Also, unsure if TLauncher ever has a legit usage, as I have always seen it associated with software piracy, but if it has a legit mode, make sure it is using online mode so that it can authenticate your MS account to login. Aside from that, more information is likely needed. Post logs, as well as the paths you are placing files in (screenshots of your file explorer can be helpful as well).
    • I am using a third-party launcher that has pre-installed forge versions of Minecraft.  When I insert mods from CurseForge, I extract the files and as expected put them in the .mods folder. I am guessing that there is an error with the file transfer but I don't know for sure and sometimes I use Forge to test mods that I created before releasing previously on a different pc, so I don't know if it is the if it an extraction error but if are any tips or knowledge reply and I will read it. This is also will be kept on the forum for others that have the issues.
    • I make wires and i need connection 2 wires block. I have BooleanPropertys registered, but in mod loading it show Unknown the property in assets/wuntare/blockState. public static final BooleanProperty CONNECTED_NORTH = BooleanProperty.create("connected_north"); public static final BooleanProperty CONNECTED_SOUTH = BooleanProperty.create("connected_south"); public static final BooleanProperty CONNECTED_WEST = BooleanProperty.create("connected_west"); public static final BooleanProperty CONNECTED_EAST = BooleanProperty.create("connected_east"); public static final BooleanProperty CONNECTED_UP = BooleanProperty.create("connected_up"); public static final BooleanProperty CONNECTED_DOWN = BooleanProperty.create("connected_down"); public CopperWireWithoutInsulation0(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any() .setValue(CONNECTED_NORTH, false) .setValue(CONNECTED_SOUTH, false) .setValue(CONNECTED_WEST, false) .setValue(CONNECTED_EAST, false) .setValue(CONNECTED_UP, false) .setValue(CONNECTED_DOWN, false)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) { builder.add(CONNECTED_NORTH, CONNECTED_SOUTH, CONNECTED_WEST, CONNECTED_EAST, CONNECTED_UP, CONNECTED_DOWN); } In this part blockState have problem "multipart": [ { "apply": { "model": "wuntare:block/copper_wire_without_insulation0" } }, { "when": { "connected_north": true }, "apply": { "model": "wuntare:block/copper_wire_without_insulation0_north" } },  
  • Topics

×
×
  • Create New...

Important Information

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