AndrewSherman Posted June 17, 2013 Posted June 17, 2013 Hi, I was just wondering if there was a way to make a block affected by the efficiency enchantment. I thought that setting Material.ground would make this work but apparently not...thanks for the help! Quote
ObsequiousNewt Posted June 17, 2013 Posted June 17, 2013 On 6/17/2013 at 2:45 PM, AndrewSherman said: Hi, I was just wondering if there was a way to make a block affected by the efficiency enchantment. I thought that setting Material.ground would make this work but apparently not...thanks for the help! If you want picks to be effective, I believe you rather need Material.rock Quote BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
atrain99 Posted June 17, 2013 Posted June 17, 2013 On 6/17/2013 at 3:21 PM, ObsequiousNewt said: Quote Hi, I was just wondering if there was a way to make a block affected by the efficiency enchantment. I thought that setting Material.ground would make this work but apparently not...thanks for the help! If you want picks to be effective, I believe you rather need Material.rock Unless you want it to be efficiency on shovels that makes it go. Material.wood for axes, Material.rock or Material.iron for picks, and Material.ground for shovels. If you can enchant shears, you would use Material.leaves for those. Quote So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
AndrewSherman Posted June 17, 2013 Author Posted June 17, 2013 Yeah, that's not actually working! I'm using this as the constructor: protected BlockGraveDirt(int par1) { super(par1, Material.ground); } And with a (vanilla) efficiency shovel it doesn't make a difference... (Actually, it doesn't matter what I use to dig it, it always takes the same time to break!) Quote
ObsequiousNewt Posted June 17, 2013 Posted June 17, 2013 On 6/17/2013 at 7:05 PM, AndrewSherman said: Yeah, that's not actually working! I'm using this as the constructor: protected BlockGraveDirt(int par1) { super(par1, Material.ground); } And with a (vanilla) efficiency shovel it doesn't make a difference... (Actually, it doesn't matter what I use to dig it, it always takes the same time to break!) Um, out of curiosity, why is your constructor protected? Quote BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
AndrewSherman Posted June 17, 2013 Author Posted June 17, 2013 Oh, I don't know lol...bit weird... I think I extended block dirt at one point to see if that would help with anything...not sure if that would've done it or if it's just my own stupidity! Making it public still didn't change anything though by the way! Quote
ObsequiousNewt Posted June 17, 2013 Posted June 17, 2013 On 6/17/2013 at 8:34 PM, AndrewSherman said: Oh, I don't know lol...bit weird... I think I extended block dirt at one point to see if that would help with anything...not sure if that would've done it or if it's just my own stupidity! Making it public still didn't change anything though by the way! Meh, I had a feeling it wasn't getting called correctly (and so didn't register your material type.) Ah well. Unfortunately I don't have my Eclipse up right now, so I'll just ask to make quite certain that efficiency isn't having any effect? After all, dirt gets mined quickly. I have a nasty feeling, though, that Minecraft has "if dirt" hardcoded rather than "if material is ground." Quote BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
AndrewSherman Posted June 18, 2013 Author Posted June 18, 2013 On 6/17/2013 at 7:05 PM, AndrewSherman said: And with a (vanilla) efficiency shovel it doesn't make a difference... (Actually, it doesn't matter what I use to dig it, it always takes the same time to break!) Quote
ObsequiousNewt Posted June 18, 2013 Posted June 18, 2013 On 6/18/2013 at 12:13 AM, AndrewSherman said: Quote And with a (vanilla) efficiency shovel it doesn't make a difference... (Actually, it doesn't matter what I use to dig it, it always takes the same time to break!) Okay, I get your point. I've got Eclipse up now, researching... ...And it looks like the material doesn't matter. What *does* matter is ItemSpade.blocksEffectiveAgainst, which is static/final. Which means that you'll have to override ItemSpade. Rather silly. It seems there should be a Forge hook for this. (Unless there already is and I'm looking over it...) Quote BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
AndrewSherman Posted June 18, 2013 Author Posted June 18, 2013 I don't want to sound like a total noob but is a forge hook just a line of code in a base file that can be accessed by anyone to edit parts of the base file remotely (:. Reducing likelihood of compatibility errors) or is it something else entirely? Quote
ObsequiousNewt Posted June 18, 2013 Posted June 18, 2013 On 6/18/2013 at 9:48 AM, AndrewSherman said: I don't want to sound like a total noob but is a forge hook just a line of code in a base file that can be accessed by anyone to edit parts of the base file remotely (:. Reducing likelihood of compatibility errors) or is it something else entirely? No, it's more like an event that you handle. I think. I haven't been using them much. Quote BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
atrain99 Posted June 18, 2013 Posted June 18, 2013 A forge hook is a piece of code in forge that allows you to do things, like efficiency shovels working on your block. If you look in the file you would have to modify to make a function work, the forge hooks are at the bottom of the file, under a comment line that says "BEGIN FORGE PATCHES". The also may be a way to register your block through the MinecraftForge files themselves. Quote So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.
AndrewSherman Posted June 18, 2013 Author Posted June 18, 2013 /** * Register a block to be harvested by a tool class. This is the metadata * sensitive version, use it if your blocks are using metadata variants. * By default, this sets the block class as effective against that type. * * @param block The block to register. * @param metadata The metadata for the block subtype. * @param toolClass The tool class to register as able to remove this block. * You may register the same block multiple times with different tool * classes, if multiple tool types can be used to harvest this block. * @param harvestLevel The minimum tool harvest level required to successfully * harvest the block. * @see MinecraftForge#setToolClass for details on tool classes. */ public static void setBlockHarvestLevel(Block block, int metadata, String toolClass, int harvestLevel) { List key = Arrays.asList(block, metadata, toolClass); ForgeHooks.toolHarvestLevels.put(key, harvestLevel); ForgeHooks.toolEffectiveness.add(key); } Just found this. Posting before looking but hey, I'll see if it's actually useful in a sec! Ok, yes it's useful and yes it works! I know what to look out for in the future now, thanks everyone for you help! Quote
ObsequiousNewt Posted June 18, 2013 Posted June 18, 2013 On 6/18/2013 at 6:15 PM, AndrewSherman said: /** * Register a block to be harvested by a tool class. This is the metadata * sensitive version, use it if your blocks are using metadata variants. * By default, this sets the block class as effective against that type. * * @param block The block to register. * @param metadata The metadata for the block subtype. * @param toolClass The tool class to register as able to remove this block. * You may register the same block multiple times with different tool * classes, if multiple tool types can be used to harvest this block. * @param harvestLevel The minimum tool harvest level required to successfully * harvest the block. * @see MinecraftForge#setToolClass for details on tool classes. */ public static void setBlockHarvestLevel(Block block, int metadata, String toolClass, int harvestLevel) { List key = Arrays.asList(block, metadata, toolClass); ForgeHooks.toolHarvestLevels.put(key, harvestLevel); ForgeHooks.toolEffectiveness.add(key); } Just found this. Posting before looking but hey, I'll see if it's actually useful in a sec! Ok, yes it's useful and yes it works! I know what to look out for in the future now, thanks everyone for you help! Dangit, I saw that, but I assumed it was for tool strength not type... misleading function name. Quote BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
AndrewSherman Posted June 19, 2013 Author Posted June 19, 2013 Haha thanks anyway, at least this whole 'dilemma' has got me looking in the correct locations now! Quote
Recommended Posts
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.