ShetiPhian Posted August 19, 2012 Posted August 19, 2012 I've ran into a snag while converting my 1.2.5 mod PlayerAPI edits on the EntityPlayerSP & MP level which works for most things but flops for canHarvestBlock ForgeHooks.canHarvestBlock calls EntityPlayer.canHarvestBlock which returns its value to ForgeHooks.canHarvestBlock My code does nothing through PlayerAPI, but doing a temp edit in EntityPlayer get everything working fine. For the life of me I just can't seem to think of a way to edit the return of a direct call to EntityPlayer.canHarvestBlock from EntityPlayerSP.canHarvestBlock Quote
OvermindDL1 Posted August 19, 2012 Posted August 19, 2012 PlayerAPI edits can be made dynamically in forge now using the asm library most likely. Quote
ShetiPhian Posted August 19, 2012 Author Posted August 19, 2012 It would be nice to drop a dependency, I noticed the new Event system was able to replace a few things I needed PAPI for. Anyhow, looks like I'm off to google I've never used asm before and have no clue what to do. If anyone want to post any helpful info I'd be grateful Quote
ShetiPhian Posted August 20, 2012 Author Posted August 20, 2012 Well the good news is the event system was able to replace all but two parts from my PAPI code. (Just a bit of rethinking was required) The bad news is I'm apparently too dumb to understand how to use the asm library :'( Maybe if I better explained what I'm trying to do. My Mod adds player classes, the strongman/earth class is the only one with troubles. They can punch through stone and get a small bonus to mining speed. To make this work I need to change the return of EntityPlayer.getCurrentPlayerStrVsBlock and EntityPlayer.canHarvestBlock EntityPlayer.canHarvestBlock mock-up public boolean canHarvestBlock(Block par1Block) { //return this.inventory.canHarvestBlock(par1Block); return ShetiPhian.proxy.canHarvestBlock(this, this.inventory.canHarvestBlock(par1Block), par1Block); } EntityPlayer.getCurrentPlayerStrVsBlock mock-up public float getCurrentPlayerStrVsBlock(Block par1Block, int meta) { ItemStack stack = inventory.getCurrentItem(); float var2 = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta)); int var3 = EnchantmentHelper.getEfficiencyModifier(this.inventory); if (var3 > 0 && ForgeHooks.canHarvestBlock(par1Block, this, meta)) { var2 += (float)(var3 * var3 + 1); } if (this.isPotionActive(Potion.digSpeed)) { var2 *= 1.0F + (float)(this.getActivePotionEffect(Potion.digSpeed).getAmplifier() + 1) * 0.2F; } if (this.isPotionActive(Potion.digSlowdown)) { var2 *= 1.0F - (float)(this.getActivePotionEffect(Potion.digSlowdown).getAmplifier() + 1) * 0.2F; } if (this.isInsideOfMaterial(Material.water) && !EnchantmentHelper.getAquaAffinityModifier(this.inventory)) { var2 /= 5.0F; } if (!this.onGround) { var2 /= 5.0F; } //return var2; return ShetiPhian.proxy.getCurrentPlayerStrVsBlock(this, var2, par1Block, meta); } Quote
OvermindDL1 Posted August 20, 2012 Posted August 20, 2012 Hmm, asm could do it, but I have not learned it yet either (not even looked at its code even). 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.