Jump to content

[1.7.10] Item with durability wont break


KakesRevenge

Recommended Posts

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

Link to comment
Share on other sites

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

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

    • Hi, I'm trying to render a single quad in the world. I'm mixing into the ChestRenderer class. If I understand correctly, BufferSource#getBuffer opens a buffer according to the supplied RenderType (Quads with POSITION_COLOR in my case). Then, I can supply my vertices (a simple 1-block plane along the Z Axis) and close the buffer using BufferSource#endBatch for rendering. This is the code I'm using: @Inject(at = @At("TAIL"), method = "render(...)V") public void render(T blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource multiBufferSource, int packedLight, int packedOverlay, CallbackInfo ci) { BlockPos pos = blockEntity.getBlockPos(); AABB box = new AABB(pos, pos.offset(1, 1, 1)); BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource(); VertexConsumer consumer = buffer.getBuffer(RenderType.guiOverlay()); poseStack.pushPose(); poseStack.translate(-pos.getX(), -pos.getY(), -pos.getZ()); consumer.vertex(box.minX, box.maxY, box.minZ).color(1, 1, 1, 1).endVertex(); consumer.vertex(box.minX, box.maxY, box.maxZ).color(1, 1, 1, 1).endVertex(); consumer.vertex(box.minX, box.minY, box.maxZ).color(1, 1, 1, 1).endVertex(); consumer.vertex(box.minX, box.minY, box.minZ).color(1, 1, 1, 1).endVertex(); buffer.endBatch(RenderType.guiOverlay()); poseStack.popPose(); } However, the plane does not get rendered. However, if I replace those 4 vertices with a call to LevelRenderer#renderLineBox and set the RenderType to LINES, it works. Do I need something else to render planes other than the 4 edges of the quad? I used QUADS back in 1.8 where it was still the raw OpenGL type and it worked then. Or am I missing something else entirely? Thanks!
    • The Essential Role of Brunoe Quick Hack in Bitcoin Recovery Efforts The Brunoe Quick Hack has emerged as a vital tool in the ongoing efforts to recover lost or stolen Bitcoin. As the cryptocurrency landscape has evolved, the need for reliable and effective methods to regain access to misplaced or compromised digital assets has become increasingly pressing. The Brunoe Quick Hack, a specialized software solution, has stepped in to fill this critical void, offering Bitcoin users a lifeline when faced with the devastating prospect of permanently losing their hard-earned cryptocurrency holdings. At the core of this innovative technique lies a deep understanding of the underlying blockchain technology that powers Bitcoin, combined with a meticulous, methodical approach to identifying and exploiting vulnerabilities in the system. Through a series of carefully orchestrated steps, the Brunoe Quick Hack is able to bypass security measures, recover private keys, and restore access to Bitcoin wallets that were previously thought to be irretrievable. This process, while highly technical and requiring a skilled hand, has proven to be a game-changer for countless individuals and businesses who have fallen victim to the inherent risks of the cryptocurrency ecosystem. As the adoption of Bitcoin continues to grow, the Brunoe Quick Hack has emerged as an essential safeguard, providing a crucial safety net for those navigating the complex and ever-evolving world of digital finance. Contact this experts through: WhtasApp: + 170-"578-42"-635 Website: brunoequickhack.COM Email: brunoequickhack (AT) GMAIL (DOT) COM Thanks.
    • it doesnt let me import the zip that i use with curseforge
    • it doesnt let me import the zip that i use with curseforge
    • Halo semua, Kembali lagi bersama kami di situs Duta89 situs Aman, Terpercaya dan Situs yang memberikan hadiah terbesar kepada semua membernya. Pada kesempatan kali ini kami akan memberi tahu kalian semua mengenai situs permainan online yang bisa menghasilkan uang dengan cepat hanya dengan modal receh. Permainan apa kah itu? Saran bukan? >>>akungameaman<<< >>>akunminecrafsuper<<< >>>daftarsitus<<<
  • Topics

×
×
  • Create New...

Important Information

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