Posted December 28, 20186 yr i've made an pickaxe and an block but the problem is that i want to make the block only be harvestable by that particulair pickaxe and no other but it want succeed with setharvestlevel here the code: pickaxe: package com.CloudyProductions.DreamMod.heaven.items; import com.CloudyProductions.DreamMod.Main; import com.CloudyProductions.DreamMod.init.ItemInit; import com.CloudyProductions.DreamMod.util.DevMode; import com.CloudyProductions.DreamMod.util.IHasModel; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemPickaxe; public class ToolPickaxe extends ItemPickaxe implements IHasModel { public ToolPickaxe(String name, ToolMaterial material, CreativeTabs tab) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); setMaxDamage(1000); setMaxStackSize(1); DevMode.DevMode("Pickaxe: " + name + " tab: " + tab + " maxdamage: " + 1000 + " stacksize: " + 1); ItemInit.ITEMS.add(this); } @Override public void registerModels() { Main.proxy.registerItemRendere(this, 0, "inventory"); } } the block class: package com.CloudyProductions.DreamMod.heaven.blocks; import com.CloudyProductions.DreamMod.Main; import com.CloudyProductions.DreamMod.init.BlockInit; import com.CloudyProductions.DreamMod.init.ItemInit; import com.CloudyProductions.DreamMod.util.DevMode; import com.CloudyProductions.DreamMod.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import java.util.Random; public class CloudBlock extends Block implements IHasModel { public CloudBlock(String name, Material material, CreativeTabs tab) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(tab); setSoundType(SoundType.STONE); setHardness(100f); setResistance(18000000f); setHarvestLevel("pickaxe", 10); setLightLevel(0f); setLightOpacity(0); BlockInit.BLOCKS.add(this); ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName())); DevMode.DevMode("name: " + name + " material: " + material + " tab: " + tab); } public void registerModels() { Main.proxy.registerItemRendere(Item.getItemFromBlock(this), 0, "inventory"); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Item.getItemFromBlock(this); } @Override public int quantityDropped(Random random) { return 1; } } the material code: public static final Item.ToolMaterial CLOUD_TOOL = EnumHelper.addToolMaterial("cloud_tool", 10, 1000, 15.0f, 30.0f, 20);
December 28, 20186 yr This is what i did: package com.diamondminer88.mod.character.blocks.a.glass; import com.diamondminer88.mod.character.blocks.blockbases.a.BlockBaseGlassA; import com.diamondminer88.mod.character.init.ModBlocks; import com.diamondminer88.mod.character.init.ModItems; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import java.util.Random; public class AGlassBlack extends BlockBaseGlassA { public Item item; public EntityPlayer entityPlayer; public AGlassBlack(String name, Material material) { super(name, material); } @Override public Item getItemDropped(IBlockState state, Random rand, int fortune) { if (harvesters.get() != null) { entityPlayer = harvesters.get(); Item MainHandHeldItem = entityPlayer.getHeldItemMainhand().getItem(); if (MainHandHeldItem.equals(ModItems.TOOL_DIAMOND_GLASS_CUTTER) || MainHandHeldItem.equals(ModItems.TOOL_IRON_GLASS_CUTTER)) { this.item = Item.getItemFromBlock(ModBlocks.A_GLASS_BLACK); } else { this.item = ModItems.GLASS_SHARD_BLACK; } } return this.item; } @Override protected ItemStack getSilkTouchDrop(IBlockState state) { return new ItemStack(ModBlocks.A_GLASS_BLACK); } } And please when you are posting code onto the forum use the "code" function like i did. I made it so if you break the "AGlassBlack" block by my GlassCutter, it drops the block but if not, drops shards. As for the quantity, there there is only point to do quantityDropped if you're making it drop more than one of that item. The default is 1. Edited December 28, 20186 yr by DiamondMiner88 Submitted to fast
December 29, 20186 yr Author thanks my idea is to make a block that is unbreakable with diamond or lower but with the cloud pickaxe it's breakable
December 29, 20186 yr Author yeah so how can i make it that you can only break that block with cloud pickaxe and not with other pickaxes
December 29, 20186 yr Author yeah but how to make it with that that it's only breakable by own pickaxe
December 29, 20186 yr Author did it already with if (harvesters.get() != null) { player = harvesters.get(); Item pickaxe = player.getHeldItemMainhand().getItem(); if (pickaxe.equals(ItemInit.CLOUD_PICKAXE)) { return; } else { setBlockUnbreakable(); } } but didn't work
December 29, 20186 yr Author how did they do it with obsidian obsidian is breakable only by an diamond pickaxe isn't it
December 29, 20186 yr Are you wanting to make it so its impossible to break it if its not the Cloud tool but possible if it is?
December 29, 20186 yr @Override public boolean canHarvestBlock(IBlockAccess world, BlockPos pos, EntityPlayer player) { Item MainHandHeldItem = player.getHeldItemMainhand().getItem(); if (MainHandHeldItem.equals(ItemInit.CLOUD_PICKAXE)) { return true; } else { return false; } } In your block class Edited December 29, 20186 yr by DiamondMiner88
December 29, 20186 yr Oh sorry. Then whats a better way to do it? I posted my code at the top of my page and is that bad too? Edited December 29, 20186 yr by DiamondMiner88
December 29, 20186 yr Author now i'm getting the error Method does not override Method from it's super class
December 29, 20186 yr What did you do and btw can you setup a github repo i want to see your mod I'm interested.
December 29, 20186 yr Author i don't want to make an github don't want to make it open-source it's still in development gonna realease it soon and what i did imported IBlockState needs to be IBlockAccess. about open-source maybe in the feature i'm gonna make some sort of api or something for my mod and that you can use it for you're mod
December 29, 20186 yr Author yeah i'm new to mod coding now a bit of java but still learning java now some basic things but i come from the spigot plugin side
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.