Jump to content

Make Mob Drop Item On Death, Does Not Work?


Beelzaboss

Recommended Posts

Hey all,

 

I am a really new to modding and this is my first mod I am working on. I having trouble whenever I am trying to slay a Zombie it should drop a DutarFragment (DutarEssence in this case) of a 25% drop chance, but it does not drop it at all no matter how many Zombies I kill.

 

There is no Error nor Warnings is this code. Everything works %100 with no errors (Client and Server), It's just the Zombie that does not want to drop the DutarFragment (DutarEssence in this case), I will also appreciate some guidelines and tips for better coding if mine is not according to the standards.

 

 

USING FML FOR THIS MOD

 

Any Help?

 

[spoiler=Class: AerialCraft.java]package Beelzaboss.Mod; //Package directory

 

import net.minecraft.block.Block;

import net.minecraft.entity.passive.EntitySheep;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.EnumHelper;

import net.minecraftforge.event.ForgeSubscribe;

import net.minecraftforge.event.entity.living.LivingDropsEvent;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.passive.EntitySheep;

import net.minecraft.entity.passive.EntitySquid;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraftforge.event.ForgeSubscribe;

import net.minecraftforge.event.entity.living.LivingDropsEvent;

 

 

//Setting Settings

@Mod(modid="Aerialcraft",name="Aerial Craft",version="1.0")

@NetworkMod(clientSideRequired=true,serverSideRequired=true)

 

public class AerialCraft {{

 

//Calling Items

AerialCraftItems AerialCraftItemsObj = new AerialCraftItems();

AerialCraftItemsObj.getClass();

 

//Calling Blocks

AerialCraftBlocks AerialCraftBlocksObj = new AerialCraftBlocks();

AerialCraftBlocksObj.getClass();

 

//Calling Tools

AerialCraftTools AerialCraftToolsObj = new AerialCraftTools();

AerialCraftToolsObj.getClass();

 

//Calling Event_LivingDrops

Event_LivingDrops Event_LivingDropsObj = new Event_LivingDrops();

Event_LivingDropsObj.getClass();

 

 

//Crafting Shapeless

//******************

//9 DutarEssence = 1 DutarBlock

GameRegistry.addShapelessRecipe(new ItemStack(AerialCraftBlocksObj.DutarBlock,1), new Object[]{

AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence, AerialCraftItemsObj.DutarEssence});

//1 DutarBlock = 9 DutarEssence

GameRegistry.addShapelessRecipe(new ItemStack(AerialCraftItemsObj.DutarEssence,9), new Object[]{

AerialCraftBlocksObj.DutarBlock});

 

//Crafting Shaped

//******************

GameRegistry.addRecipe(new ItemStack(AerialCraftToolsObj.DutarSword,1), new Object[]{" D "," D "," S ",'D',AerialCraftItemsObj.DutarIngot,'S',Item.stick});

 

//Smelting

//*********

//1 DutarEssence = 1 DutarIngot

GameRegistry.addSmelting(AerialCraftItemsObj.DutarEssence.itemID, new ItemStack(AerialCraftItemsObj.DutarIngot), 15.0f);

}

}

 

 

[spoiler=Class: AerialCraftBlocks.java]package Beelzaboss.Mod;

 

import net.minecraft.block.Block;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.EnumHelper;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

public class AerialCraftBlocks{

 

 

//Adding Block DutarBlock

public static Block DutarBlock;{

DutarBlock = new DutarBlock(2001, "DutarBlock").setUnlocalizedName("DutarBlock").setHardness(10.0F).setStepSound(Block.soundMetalFootstep).setResistance(15.0F);

GameRegistry.registerBlock(DutarBlock, "Dutar Block");

LanguageRegistry.addName(DutarBlock, "Dutar Block");

}

 

//

 

 

}

 

 

[spoiler=Class: AerialCraftItems.java]package Beelzaboss.Mod; //Package directory

 

import net.minecraft.block.Block;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.EnumHelper;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

public class AerialCraftItems {

 

//Adding Item DutarEssence

public static Item DutarEssence;{

DutarEssence = new DutarEssence(8000).setUnlocalizedName("DutarEssence");

LanguageRegistry.addName(DutarEssence, "Dutar Essence");}

 

//Adding Item DutarEssence

public static Item DutarIngot;{

DutarIngot = new DutarEssence(8001).setUnlocalizedName("DutarIngot");

LanguageRegistry.addName(DutarIngot, "Dutar Ingot");}

 

//

 

}

 

 

[spoiler=Class: AerialCraftTools.java]package Beelzaboss.Mod; //Package directory

 

import net.minecraft.block.Block;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.EnumHelper;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

public class AerialCraftTools {

 

//Enum Tools Materials

static EnumToolMaterial EnumToolMaterialDutar = EnumHelper.addToolMaterial("DutarPower", 0, 10, 8.0F, 10, 10);

 

//Add Tools Dutar DutarSword

public static Item DutarSword;{

DutarSword = new DutarSword(9000, EnumToolMaterialDutar).setUnlocalizedName("DutarSword");

LanguageRegistry.addName(DutarSword, "Dutar Essence");}

//

 

 

}

 

 

[spoiler=Class: DutarBlock.java]package Beelzaboss.Mod;

 

import java.util.Random;

 

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.registry.LanguageRegistry;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IconRegister;

import net.minecraft.creativetab.CreativeTabs;

 

public class DutarBlock extends Block {

 

 

//Loading

public DutarBlock(int par1, String texture) {

super(par1, Material.iron);

setCreativeTab(CreativeTabs.tabBlock); //place in creative tabs

 

}

 

//Broken Drop

public int quantityDropped(Random random)

{

return 1;

}

 

 

 

//Texture the block

public String getTextureFile(){

return "/textures/blocks/DutarBlock.png";

}

 

 

 

 

 

}

 

 

[spoiler=Class: DutarEssence]package Beelzaboss.Mod;

 

import net.minecraft.item.Item;

import cpw.mods.fml.relauncher.*;

import net.minecraft.creativetab.CreativeTabs;

 

 

public class DutarEssence extends Item {

 

public DutarEssence(int par1) {

super(par1); //Returns super constructor: par1 is ID

setCreativeTab(CreativeTabs.tabMaterials); //Tells the game what creative mode tab it goes in

 

 

 

}

}

 

 

[spoiler=Class: DutarIngot.java]package Beelzaboss.Mod;

 

import net.minecraft.item.Item;

import cpw.mods.fml.relauncher.*;

import net.minecraft.creativetab.CreativeTabs;

 

 

public class DutarIngot extends Item {

 

public DutarIngot(int par1) {

super(par1); //Returns super constructor: par1 is ID

setCreativeTab(CreativeTabs.tabMaterials); //Tells the game what creative mode tab it goes in

 

 

 

}

}

 

 

[spoiler=Class: DutarSword.java]package Beelzaboss.Mod;

 

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.ItemPickaxe;

import net.minecraft.item.ItemSword;

import net.minecraft.block.Block;

import net.minecraft.item.EnumToolMaterial;

import net.minecraft.item.Item;

import net.minecraft.item.ItemFood;

import net.minecraft.item.ItemStack;

import net.minecraftforge.common.EnumHelper;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

 

// *REMEBER* Change "ItemPickaxe" to ItemAxe, ItemHoe, ItemSword, etc if you are making those tools!

public class DutarSword extends ItemSword {

public DutarSword(int ItemID, EnumToolMaterial enumToolMaterialDutar){

super(ItemID, enumToolMaterialDutar);

}

}

 

 

 

 

And here is the Class I am having trouble with:

 

[spoiler=Class: Event_LivingDrops.java]package Beelzaboss.Mod;

 

import net.minecraft.entity.item.EntityItem;

import net.minecraft.entity.monster.EntityZombie;

import net.minecraft.entity.passive.EntitySheep;

import net.minecraft.entity.passive.EntitySquid;

import net.minecraft.item.Item;

import net.minecraftforge.event.ForgeSubscribe;

import net.minecraftforge.event.entity.living.*;

import net.minecraft.entity.player.*;

 

public class Event_LivingDrops {

 

static double rand;

 

@ForgeSubscribe

public void onEntityDrop(LivingDropsEvent event) {

if (event.source.getEntity() instanceof EntityPlayer) {

rand = Math.random();

EntityPlayer killer = (EntityPlayer)event.source.getEntity();

if (event.entity instanceof EntityZombie && !event.entity.worldObj.isRemote) {

 

if (rand < 0.25D){

 

//TODO change DutarEssence Item into DutarFragment Once Item Added

event.entity.dropItem(AerialCraftItems.DutarEssence.itemID, 1);

 

}

}

}

}

}

 

 

Thanks in advance,

Beelzaboss.

Trinity Gaming - South African Server, Custom Modpack (TrinityCraft/Launcher) 118 mods @ trinitygaming.co.za

Link to comment
Share on other sites

lol, you have to know that no COMPILATION error doesnt mean no logic error

 

simple example

if(1 == 1){
System.out.println(" 1+1 = 3");
}

 

this makes no sens but it will not give any error

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

as for the problem, i knwo exactly where it is but hum

 

is your main mod class complete ?

if yes what is this suppose to do  ? :P

Event_LivingDropsObj.getClass();

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Haha, Like I said I am completely new haha.

 

Event_LivingDropsObj.getClass();

 

Is suppost to goto Event_LivingDrops Class and then adding it to the game, this method works %100 with my Items, blocks and Tools... It adds those classes to the game and it works;

//Calling Items
AerialCraftItems AerialCraftItemsObj = new AerialCraftItems();
AerialCraftItemsObj.getClass();

//Calling Blocks
AerialCraftBlocks AerialCraftBlocksObj = new AerialCraftBlocks();
AerialCraftBlocksObj.getClass();

//Calling Tools
AerialCraftTools AerialCraftToolsObj = new AerialCraftTools();
AerialCraftToolsObj.getClass();

 

But I dunno why it does not wanna work with my calling Event_LivingDrops and if my code in that class is wrong or something...

 

Please help?

 

Thanks in advance,

Beelzaboss

Trinity Gaming - South African Server, Custom Modpack (TrinityCraft/Launcher) 118 mods @ trinitygaming.co.za

Link to comment
Share on other sites

ok, just saying, getClass does  straight up nothing.

 

you need to add

MinecraftForge.EVENT_BUS.register(some class with a @ForgeSubscribe annotation)

 

like this

MinecraftForge.EVENT_BUS.register(new Event_LivingDrops())

 

i also suggest very much you look at the tutorials and make a main mod class as it help a ton for organisation

 

and please .... learn a little about java and coding ... because itll hurt you in the long run

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Link to comment
Share on other sites

Thank You!

 

Will Do, I am completely gonna redo my mod once I understand some more coding stuff and have a better understanding...

 

Trinity Gaming - South African Server, Custom Modpack (TrinityCraft/Launcher) 118 mods @ trinitygaming.co.za

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



×
×
  • Create New...

Important Information

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