Jump to content

Recommended Posts

Posted

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

Posted

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-

Posted

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-

Posted

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

Posted

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-

Posted

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

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

    • Hello, I have this same problem. Did you manage to find a solution? Any help would be appreciated. Thanks.
    • log: https://mclo.gs/QJg3wYX as stated in the title, my game freezes upon loading into the server after i used a far-away waystone in it. The modpack i'm using is better minecraft V18. Issue only comes up in this specific server, singleplayer and other servers are A-okay. i've already experimented with removing possible culprits like modernfix and various others to no effect. i've also attempted a full reinstall of the modpack profile. Issue occurs shortly after the 'cancel' button dissapears on the 'loading world' section of the loading screen.   thanks in advance.
    • You would have better results asking a more specific question. What have you done? What exactly do you need help with? Please also read the FAQ regarding posting logs.
    • Hi, this is my second post with the same content as no one answered this and it's been a long time since I made the last post, I want to make a client-only mod, everything is ok, but when I use shaders, none of the textures rendered in RenderLevelStageEvent nor the crow entity model are rendered, I want them to be visible, because it's a horror themed mod I've already tried it with different shaders, but it didn't work with any of them and I really want to add support for shaders Here is how i render the crow model in the CrowEntityRenderer<CrowEntity>, by the time i use this method, i know is not the right method but i don't think this is the cause of the problem, the renderType i'm using is entityCutout @Override public void render(CrowEntity p_entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { super.render(p_entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); ClientEventHandler.getClient().crow.renderToBuffer(poseStack, bufferSource.getBuffer(ClientEventHandler.getClient().crow .renderType(TEXTURE)), packedLight, OverlayTexture.NO_OVERLAY, Utils.rgb(255, 255, 255)); } Here renderLevelStage @Override public void renderWorld(RenderLevelStageEvent e) { horrorEvents.draw(e); } Here is how i render every event public void draw(RenderLevelStageEvent e) { for (HorrorEvent event : currentHorrorEvents) { event.tick(e.getPartialTick()); event.draw(e); } } Here is how i render the crow model on the event @Override public void draw(RenderLevelStageEvent e) { if(e.getStage() == RenderLevelStageEvent.Stage.AFTER_ENTITIES) { float arcProgress = getArcProgress(0.25f); int alpha = (int) Mth.lerp(arcProgress, 0, 255); int packedLight = LevelRenderer.getLightColor(Minecraft.getInstance().level, blockPos); VertexConsumer builder = ClientEventHandler.bufferSource.getBuffer(crow); Crow<CreepyBirdHorrorEvent> model = ClientEventHandler .getClient().crow; model.setupAnim(this); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, packedLight, OverlayTexture.NO_OVERLAY, alpha); builder = ClientEventHandler.bufferSource.getBuffer(eyes); RenderHelper.renderModelInWorld(model, position, offset, e.getCamera(), e.getPoseStack(), builder, 15728880, OverlayTexture.NO_OVERLAY, alpha); } } How i render the model public static void renderModelInWorld(Model model, Vector3f pos, Vector3f offset, Camera camera, PoseStack matrix, VertexConsumer builder, int light, int overlay, int alpha) { matrix.pushPose(); Vec3 cameraPos = camera.getPosition(); double finalX = pos.x - cameraPos.x + offset.x; double finalY = pos.y - cameraPos.y + offset.y; double finalZ = pos.z - cameraPos.z + offset.z; matrix.pushPose(); matrix.translate(finalX, finalY, finalZ); matrix.mulPose(Axis.XP.rotationDegrees(180f)); model.renderToBuffer(matrix, builder, light, overlay, Utils .rgba(255, 255, 255, alpha)); matrix.popPose(); matrix.popPose(); } Thanks in advance
  • Topics

×
×
  • Create New...

Important Information

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