Jump to content

Ran into a snag


ShetiPhian

Recommended Posts

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

Link to comment
Share on other sites

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  ;D

Link to comment
Share on other sites

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);
    }

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



×
×
  • Create New...

Important Information

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