Jump to content

Changing what drops when i break a block doesn't work (1.8).


Wooden_Brick

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

}

 

 

 

 

 

}

Link to comment
Share on other sites

Hi

 

You might find these links helpful to track down your bug

http://www.terryanderson.ca/debugging/run.html

http://www.vogella.com/tutorials/EclipseDebugging/article.html

 

In this case -

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

your items or blocks probably aren't initialised which you call addRecipe (they are still null)

 

-TGG

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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){

 

}

 

 

 

}

 

Link to comment
Share on other sites

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;

//}

}

Link to comment
Share on other sites

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.

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

    • today i downloaded forge 1.20.1 version 47.2.0 installed it in my .minecraft and installed the server, with and without mod it literally gives the same error, so i went to see other versions like 1.17 and it worked normally   https://paste.ee/p/VxmfF
    • If you're seeking an unparalleled solution to recover lost or stolen cryptocurrency, let me introduce you to GearHead Engineers Solutions. Their exceptional team of cybersecurity experts doesn't just restore your funds; they restore your peace of mind. With a blend of cutting-edge technology and unparalleled expertise, GearHead Engineers swiftly navigates the intricate web of the digital underworld to reclaim what's rightfully yours. In your moment of distress, they become your steadfast allies, guiding you through the intricate process of recovery with transparency, trustworthiness, and unwavering professionalism. Their team of seasoned web developers and cyber specialists possesses the acumen to dissect the most sophisticated schemes, leaving no stone unturned in their quest for justice. They don't just stop at recovering your assets; they go the extra mile to identify and track down the perpetrators, ensuring they face the consequences of their deceitful actions. What sets  GearHead Engineers apart is not just their technical prowess, but their unwavering commitment to their clients. From the moment you reach out to them, you're met with compassion, understanding, and a resolute determination to right the wrongs inflicted upon you. It's not just about reclaiming lost funds; it's about restoring faith in the digital landscape and empowering individuals to reclaim control over their financial futures. If you find yourself ensnared in the clutches of cybercrime, don't despair. Reach out to GearHead Engineers and let them weave their magic. With their expertise by your side, you can turn the tide against adversity and emerge stronger than ever before. In the realm of cybersecurity, GearHead Engineers reigns supreme. Don't just take my word for it—experience their unparalleled excellence for yourself. Your journey to recovery starts here.
    • Ok so this specific code freezes the game on world creation. This is what gets me so confused, i get that it might not be the best thing, but is it really so generation heavy?
    • Wizard web recovery has exhibited unparalleled strength in the realm of recovery. They stand out as the premier team to collaborate with if you encounter withdrawal difficulties from the platform where you’ve invested. Recently, I engaged with them to recover over a million dollars trapped in an investment platform I’d been involved with for months. I furnished their team with every detail of the investment, including accounts, names, and wallet addresses to which I sent the funds. This decision proved to be the best I’ve made, especially after realizing the company had scammed me.   Wizard web recovery ensures exemplary service delivery and ensures the perpetrators face justice. They employ advanced techniques to ensure you regain access to your funds. Understandably, many individuals who have fallen victim to investment scams may still regret engaging in online services again due to the trauma of being scammed. However, I implore you to take action. Seek assistance from Wizard Web Recovery today and witness their remarkable capabilities. I am grateful that I resisted their enticements, and despite the time it took me to discover Wizard web recovery, they ultimately fulfilled my primary objective. Without wizard web recovery intervention, I would have remained despondent and perplexed indefinitely.
    • I've tested the same code on three different envionrments (Desktop win10, desktop Linux and Laptop Linux) and it kinda blows up all the same. Gonna try this code and see if i can tune it
  • Topics

×
×
  • Create New...

Important Information

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