Jump to content

Recommended Posts

Posted

I have been trying to make it that my ore would drop a gem, but when i start the client in eclipse, it instantly closes.

 

The code that i used:

 

public Item getItemDropped(int meta, Random rand, int fortune)

    {

        return TutorialItems.gem_1;

    }

 

TutorialItems is my class that has my items, gem_1 is the item.

Thank you in advance.

Posted

Not enough code. Need Main class and proxies most likely (block and item init).

 

Use @Override annotation.

 

If the client crashes right away (during launch) it's not fault of this particular method. Error is elsewhere.

1.7.10 is no longer supported by forge, you are on your own.

Posted

I have all of those classes, but your right for saying there problems not there, once i commented out everything, the game still wouldn't start. The error message:

b---- Minecraft Crash Report ----

// Oops.

 

Time: 6/3/15 4:17 PM

Description: Initializing game

 

http://www.minecraftforge.net/forum/Themes/default/images/bbc/spoiler.gifjava.lang.NullPointerException: Initializing game

at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:270)

at net.minecraftforge.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:236)

at net.minecraftforge.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:231)

at com.Babuska.init.TutorialBlocks.recipe(TutorialBlocks.java:63)

at com.Babuska.TutorialMod.preInit(TutorialMod.java:25)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)

at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118)

at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:514)

at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:447)

at net.minecraft.client.Minecraft.run(Minecraft.java:356)

at net.minecraft.client.main.Main.main(Main.java:117)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

Hope the detailed walkthrow isn't needed. what i did before trying to change the block drops was make a crafting recipe, and it perfectly worked. after that i tried to change what drops when you break a block. And thats where it went all wrong, now even if i comment out everything i did after the recipe, it still wont launch. Heres the code that the recipe is in:

 

http://www.minecraftforge.net/forum/Themes/default/images/bbc/spoiler.gifpackage com.Babuska.init;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.MapColor;

import net.minecraft.block.material.Material;

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

import com.Babuska.References;

import com.Babuska.blocks.BlockTest;

import com.Babuska.material.MaterialTest;

 

public class TutorialBlocks {

 

 

public static Block test_1;

public static Block test_block;

public static Block test_2;

public static Block test_3;

 

public static void init() {

 

test_1 = new BlockTest(Material.iron).setUnlocalizedName("test_1");

test_block = new BlockTest(Material.iron).setUnlocalizedName("test_block");

test_2 = new BlockTest(Material.iron).setUnlocalizedName("test_2");

test_3 = new BlockTest(Material.iron).setUnlocalizedName("test_3");

}

 

 

public static void register() {

 

GameRegistry.registerBlock(test_1, test_1.getUnlocalizedName().substring(5));

GameRegistry.registerBlock(test_block, test_block.getUnlocalizedName().substring(5));

GameRegistry.registerBlock(test_2, test_2.getUnlocalizedName().substring(5));

GameRegistry.registerBlock(test_3, test_3.getUnlocalizedName().substring(5));

}

 

 

public static void registerRenders()

{

 

registerRender(test_1);

registerRender(test_block);

registerRender(test_2);

registerRender(test_3);

}

 

public static void registerRender(Block block)

{

Item item = Item.getItemFromBlock(block);

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

}

 

 

 

public static void recipe()

{

GameRegistry.addRecipe(new ItemStack(test_2), new Object[]{"RRR",

                                                      " S ",

                                                      " S ", 'R', TutorialItems.gem_1, 'S', Items.stick});

}

 

 

 

 

 

}

Posted

After some testing, i found that when i try to craft some items it instantly crashes. do i have to do something more to define it?

for instance if i try to craft or use in crafting gem_1, its doesnt even load minecraft, if i use test_item it crashes when i try and craft it, and when i craft my test_2 item it for some reason works???? am i missing something complicated or very obvious?

 

Posted

package com.Babuska;

 

import net.minecraftforge.fml.common.Mod;

import net.minecraftforge.fml.common.Mod.EventHandler;

import net.minecraftforge.fml.common.SidedProxy;

import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

import com.Babuska.init.TutorialBlocks;

import com.Babuska.init.TutorialItems;

import com.Babuska.proxy.CommonProxy;

 

 

@Mod(modid = References.MOD_ID, name = References.MOD_NAME, version = References.VERSION)

public class TutorialMod {

@SidedProxy(clientSide = References.CLIENT_PROXY_CLASS, serverSide = References.SERVER_PROXY_CLASS)

public static CommonProxy proxy;

 

@EventHandler

public void preInit(FMLPreInitializationEvent event){

TutorialBlocks.init();

TutorialBlocks.register();

    TutorialBlocks.recipe();

TutorialItems.init();

TutorialItems.register();

}

@EventHandler

public void init(FMLInitializationEvent event){

proxy.registerRenders();

 

}

 

@EventHandler

public void postInit(FMLPostInitializationEvent event){

 

}

 

 

 

}

 

Posted

Thank you :) now all i need to do is figure out why the block drops dont work. i used a code that was for 1.7.10. Does this still work?

 

package com.Babuska.blocks;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.block.state.IBlockState;

import net.minecraft.item.Item;

 

import com.Babuska.init.TutorialItems;

 

public class BlockTest extends Block {

 

public BlockTest(Material materialIn) {

super(materialIn);

this.setHardness(2.0F);

this.setHarvestLevel("pickaxe", 1); //dmd 3, iron 2, stone 1, wood 0,

}

 

 

 

//public Item getItemDropped(int meta, Random rand, int fortune)

    //{

    //    return TutorialItems.gem_1;

    //}

 

//@Override

//public int quantityDropped(Random rand){

// return 6;

//}

}

Posted

It works thank you :) One last thing, and then i guess ill go away for like 2 weeks, so people get a break from my questions :D The pickaxe that i made has no texture in game, i guess the only thing diferent with it is that i used in my items:

 

public class TutorialItems {

 

public static Item test_item;

public static Item gem_1;

public static Item gem_pickaxe;

 

public static final Item.ToolMaterial gemToolMaterial = EnumHelper.addToolMaterial("gemToolMaterial", 2, 512, 7.0F, 2.0F, 10);

 

public static void init(){

test_item = new Item().setUnlocalizedName("test_item");

gem_1 = new Item().setUnlocalizedName("gem_1");

gem_pickaxe = new ItemGemPickaxe(gemToolMaterial).setUnlocalizedName("gem_pickaxe");

 

}

 

public static void register() {

GameRegistry.registerItem(test_item, test_item.getUnlocalizedName().substring(5)); //"tile.test_item"

GameRegistry.registerItem(gem_1, gem_1.getUnlocalizedName().substring(5));

GameRegistry.registerItem(gem_pickaxe, gem_pickaxe.getUnlocalizedName().substring(5));

 

}

 

public static void registerRenders() {

 

registerRender(test_item);

registerRender(gem_1);

registerRender(gem_pickaxe);

}

 

 

public static void registerRender(Item item) {

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(References.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

 

}

 

}

 

and in the actual ItemGemPickaxe class:

 

import net.minecraft.item.ItemPickaxe;

 

public class ItemGemPickaxe extends ItemPickaxe {

 

public ItemGemPickaxe(ToolMaterial material) {

super(material);

 

}

}

 

i have the .json.

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

    • I also just tried with iron's spellbooks removed, since that seemed related, but i am still having the same problem, even in newly created worlds. https://mclo.gs/AtrAfaj 
    • My Gradle Project for my Minecraft mod isn't building. Terminal: * Where: Settings file 'C:\Users\csonn\OneDrive\Desktop\fusionlucky\settings.gradle' line: 2 * What went wrong: Could not compile settings file 'C:\Users\csonn\OneDrive\Desktop\fusionlucky\settings.gradle'. > startup failed:   settings file 'C:\Users\csonn\OneDrive\Desktop\fusionlucky\settings.gradle': 2: The pluginManagement {} block must appear before any other statements in the script.   For more information on the pluginManagement {} block, please refer to https://docs.gradle.org/9.0.0/userguide/plugins.html#sec:plugin_management in the Gradle documentation.    @ line 2, column 1.      pluginManagement {      ^   1 error * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to generate a Build Scan (Powered by Develocity). > Get more help at https://help.gradle.org.   Setting.Gradle File:   rootProject.name = 'fusion-lucky-block' pluginManagement {     repositories {         gradlePluginPortal()         maven { url "https://maven.minecraftforge.net/" }         mavenCentral()     } }
    • no change still. here's a new log  https://mclo.gs/RXwiZmn 
    • Whenever I go to build my it says "Build failed in " how many seconds   Here is what is said in my terminal * Where: Build file 'C:\Users\csonn\OneDrive\Desktop\fusionlucky\build.gradle' line: 3 * What went wrong: Plugin [id: 'net.minecraftforge.gradle', version: '6.1.51'] was not found in any of the following sources: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Included Builds (No included builds contain this plugin) - Plugin Repositories (could not resolve plugin artifact 'net.minecraftforge.gradle:net.minecraftforge.gradle.gradle.plugin:6.1.51')   Searched in the following repositories:     Gradle Central Plugin Repository     MinecraftForge(https://maven.minecraftforge.net/) * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Get more help at https://help.gradle.org.   Here is what is in my build.gradle file plugins {     id 'java'     id 'net.minecraftforge.gradle' version '6.1+' }   group = 'io.github.csonnic03.fusionlucky' version = '1.0.0' archivesBaseName = 'fusionlucky'   java {     toolchain {         languageVersion = JavaLanguageVersion.of(17)     } }   repositories {     mavenCentral()     maven {         name "forgeMaven"         url "https://maven.minecraftforge.net/<repository>" } }   dependencies {     minecraft 'net.minecraftforge:forge:1.20.1-47.1.0' }   minecraft {     mappings channel: 'official', version: '1.20.1'     runs {         client {             workingDirectory project.file('run')         }         server {             workingDirectory project.file('run')         }     } }   tasks.withType(JavaCompile) {     options.encoding = 'UTF-8' }   jar {     manifest {         attributes(             "Specification-Title": "Fusion Lucky Block",             "Specification-Vendor": "example",             "Implementation-Title": project.name,             "Implementation-Version": project.version,             "Implementation-Vendor": "example",             "ModLauncher-TargetFMLVersion": "[47,)"         )     } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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