Posted April 10, 201312 yr Hello, I have a block which I want to only be able to harvest when I have a specified enchantment on my pickaxe. I have this code in the block class: @Override public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { if (EnchantmentHelper.getEnchantmentLevel(XXXX.xxxx.effectId, par2EntityPlayer.getHeldItem()) > 0); { ItemStack is = new ItemStack(XXXX.yyyy); par1World.spawnEntityInWorld(new EntityItem(par1World, par3, par4, par5, is)); } } and this to define what can harvest it: MinecraftForge.setBlockHarvestLevel(zzzz, "pickaxe", 0); my enchantment code looks like so: package mods.XXXX; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnumEnchantmentType; import net.minecraft.util.StatCollector; public class EnchantmentXxxx extends Enchantment { public EnchantmentXxxx(int par1, int par2) { super(par1, par2, EnumEnchantmentType.digger); } public int getMaxLevel() { return 1; } public String getTranslatedName(int par1) { String enchantmentName = "Xxxx"; return enchantmentName + " " + StatCollector.translateToLocal("enchantment.level." + par1); } public int getMinEnchantability(int par1) { return 22; } public int getMaxEnchantability(int par1) { return 22; } } However, when I mine my block with any pickaxe, it drops the itemstack specified in the harvestBlock method regradless of whether the pickaxe has the enchantment or not.
April 10, 201312 yr @Override public int quantityDropped(int meta, int fortune, Random random) { return 0; } Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 10, 201312 yr All I can say at this point is: Add debug statements, figure out where the program is going that it shouldn't be and why. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
April 17, 201312 yr Author Found the problem, the if statement was invalid because there was a semi colon after it. herpy derp derp!
April 17, 201312 yr Author Found the problem, the if statement was invalid because there was a semi colon after it. herpy derp derp!
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.