Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello guys,

I am adding a new type of ore, and they will drop 0-5 items each ore (similar to redstone/lapis).

I can get the dropped item in creativeTabs, but I can't get em when I broke the ore.

 

Below are my code (the custom names are changed to protect my mod)

 

Main Class :

package com.AndyLun.xxxx;

import net.minecraft.block.Block;
import net.minecraft.item.Item;

import com.AndyLun.xxxx.block.Blockxxxx;
import com.AndyLun.xxxx.core.proxy.CommonProxy;
import com.AndyLun.xxxx.item.Itemxxxx;
import com.AndyLun.xxxx.lib.Data;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

// Main Class for xxxxMod
// Author AndyLun

@Mod(modid = Data.MOD_ID, name = Data.MOD_NAME, version = Data.VERSION)
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class xxxx {

@Instance(Data.MOD_ID)
public static xxxx instance;

@SidedProxy(clientSide = Data.CLIENT_PROXY_CLASS,
			serverSide = Data.SERVER_PROXY_CLASS)
public static CommonProxy proxy;

public static Block BlockAA;

public static Item ItemBB;

@PreInit
public void preInit(FMLPreInitializationEvent event) {

}

@Init
public void Init(FMLInitializationEvent event) {
	proxy.registerRenderThings();

	BlockAA = new BlockAA(700, 0);
	ItemBB = new ItemBB(3700);

	GameRegistry.registerBlock(BlockAA, "BlockAA");
	GameRegistry.registerItem(ItemBB, "ItemBB");

	LanguageRegistry.addName(BlockAA, "AA Ore");
	LanguageRegistry.addName(ItemBB, "BB");
}

@PostInit
public void postInit(FMLPostInitializationEvent event) {

}
}

 

BlockAA Class :

 

package com.AndyLun.xxxx.block;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class BlockAA extends Block {

public BlockAA(int id, int texture) {
	super(id, texture, Material.rock);
	this.setBlockName("BlockAA");
	this.setHardness(4.0F);
	this.setResistance(4.0F);
	this.setLightValue(0F);
	this.setStepSound(soundStoneFootstep);
	this.setCreativeTab(CreativeTabs.tabBlock);
}

public String getTextureFile() {
	return "/xxxx/Blocks.png";
}

public int idDropped(int par1, Random random, int par2) {
	return 3700;
}

public int quantityDropped(Random random) {
	return random.nextInt(5) + 1;
                             // random.nextInt(5) generates an int between 0-4, and I made it +1 so that it becomes 1-5
}

}

 

ItemBB Class :

 

package com.AndyLun.xxxx.item;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class ItemBB extends Item {

public ItemBB(int id) {
	super(id);
	this.setItemName("ItemBB");
	this.setIconIndex(0);
	this.setCreativeTab(CreativeTabs.tabMaterials);
}

public String getTextureFile() {
	return "/xxxx/Items.png";
}
}

public int idDropped(int par1, Random par2Random, int par3)

    {

        return MOD.BLOCKBLA.idDropped(0, par2Random, par3);

    }

or

public int idDropped(int par1, Random par2Random, int par3)

    {

        return MODBLA.ITEMBLA.shiftedIndex;

    }

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.