Jump to content

Recommended Posts

Posted

Hello everyone,

i have a problem with my durable item ...

in crafting it works fine but when im damaging item with itemstack.setItemDamage(itemstack.getItemDamage() + 1);

it just wont break :( i would appreciate any help

Thank you :)

 

Durable Item class

 

package fewmorethings.items;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.world.World;

import fewmorethings.Main;

import fewmorethings.handlers.BlocksHandler;

import fewmorethings.handlers.ItemsHandler;

import fewmorethings.help.LogHelper;

import fewmorethings.help.Reference;

 

public class ClickSmelt extends Item {

 

public ClickSmelt() {

this.setUnlocalizedName("ClickSmelt");

this.setTextureName(Reference.MODID + ":" + "ClickSmelt");

this.setCreativeTab(Main.fmtab);

this.setMaxDamage(64);

this.setMaxStackSize(1);

}

 

@Override

public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par1, float par2, float par3, float par4) {

Block blockoneye = world.getBlock(x, y, z);

int metadata = world.getBlockMetadata(x, y, z);

 

if(player.canPlayerEdit(x, y, z, par1, itemstack)) {

//Block to Block

if(blockoneye == Blocks.sand) {

world.setBlock(x, y, z, Blocks.glass);

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.glass) {

world.setBlock(x, y, z, BlocksHandler.ClearGlass);

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.cobblestone) {

world.setBlock(x, y, z, Blocks.stone);

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.clay) {

world.setBlock(x, y, z, Blocks.hardened_clay);

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

//Block to Item

}if(blockoneye == Blocks.iron_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.iron_ingot));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.coal_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.coal));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.gold_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.gold_ingot));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.lapis_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.dye,1,4));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.redstone_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.redstone));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.diamond_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.diamond));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.emerald_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.emerald));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.log || blockoneye == Blocks.log2) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.coal,1,1));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.cactus) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.dye,1,2));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.netherrack) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.netherbrick));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == Blocks.quartz_ore) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(Items.quartz));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == BlocksHandler.blockOres && metadata == 0) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(ItemsHandler.Ingots));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == BlocksHandler.blockOres && metadata == 1) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(ItemsHandler.Ingots,1,1));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == BlocksHandler.blockOres && metadata == 2) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(ItemsHandler.Ingots,1,2));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == BlocksHandler.blockOres && metadata == 3) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(ItemsHandler.Ingots,1,3));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}if(blockoneye == BlocksHandler.blockOres && metadata == 4) {

world.setBlockToAir(x, y, z);

player.inventory.addItemStackToInventory(new ItemStack(ItemsHandler.Ingots,1,4));

itemstack.setItemDamage(itemstack.getItemDamage() + 1);

}

}

return false;

}

 

@Override

public boolean getShareTag() {

    return true;

}

 

    public boolean hasContainerItem(ItemStack itemStack) {

        return true;

    }

   

    @Override

    public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) {   

      return false;

    }

   

    @Override

    public ItemStack getContainerItem(ItemStack itemStack) {

        ItemStack stack = itemStack.copy();

 

        stack.setItemDamage(stack.getItemDamage() + 1);

 

        return stack;

    }

}

 

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

Im sorry, but thats the only way i can do it :/ Im trying to learn ...

If you could help me more i would appreciate that.

And how to do the stack size 0 to null conversion ??

Thank you

 

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Posted

Im gonna go look at some basic java tutorials

Thank you :)

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

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

    • Dear Brunoe Quick Hack (Team) Thank you so much for your remarkable help in recovering my funds after I was scammed. As a busy surgeon and single mother to three children, the loss was overwhelming.Web-Site: Brunoequickhack.COM Your team's hard work, expertise, and unwavering support gave me hope and helped restore my financial stability. I admire your professionalism and the way you genuinely care about your clients. I highly recommend your services to anyone who has fallen prey to scammers. You are truly life savers. Whats-App: +1705-(7842)-635 With heartfelt thanks, Contact information: BrunoequickhackATgmail.cOM Dear Brunoe Quick Hack (Team) Thank you so much for your remarkable help in recovering my funds after I was scammed. As a busy surgeon and single mother to three children, the loss was overwhelming.Web-Site: Brunoequickhack.COM Your team's hard work, expertise, and unwavering support gave me hope and helped restore my financial stability. I admire your professionalism and the way you genuinely care about your clients. I highly recommend your services to anyone who has fallen prey to scammers. You are truly life savers. Whats-App: +1705-(7842)-635 With heartfelt thanks, Contact information: BrunoequickhackATgmail.cOM
    • ok i tried to disable the last mod's i installed and it is some of then, so now im going to do the classic enable and disable trick to find out which mod cause the crash. thanks for the help  
    • ok  make it work (java not being recognize) by downloading the zip putting it in the java folder and manually setting the path but is still give the same crush report https://pastebin.com/PPmR6jN0
    • Install this one: https://www.azul.com/downloads/?version=java-17-lts&os=windows&architecture=x86-64-bit&package=jdk#zulu After installation, set the java version in your Launcher / Java settings
    • it say it requires java 17 so when i go to install it is say "the installer has encounter an unexpected error installing this package." error code 2503 and 2502. https://pastebin.com/AL6AHMM9
  • Topics

×
×
  • Create New...

Important Information

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