Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

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

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.