Shield prevents to use Altar of inspiration
LemADEC opened this issue ยท 8 comments
As of Vampirism-1.10.2-1.1.0-alpha+03-06-19-21.jar, you can't level up using the Altar of inspiration while wearing a shield.
Should not be that big a deal, since you can always un-equip the shield, but it might confuse new players, so I will try to fix that.
I took a look, but I'm not sure what's the best way to fix this.
- I could remove the requirement to sneak to activate it. So simply right-clicking it with a bare hand would start it (might happen accidentally).
- It could check each PlayerInteractEvent to force bypass the shield action (dirty and CPU time consuming, but would keep everything like it is)
What do you think?
Both sounds bad.
Can we just catch it at block level instead with on onBlockActivated()?
The problem is that this is not called when the player is sneaking and holding an item in any hand (which does not bypass use when sneaking) :/
yes, you need to allow the item to bypass the sneak usage, which is what it already does anyway ;).
Looks like SneakBypass changed since 1.7.10, seems to unusable for us now.
I guess removing the sneak requirement is the best option here then.
Not sure what you mean. As far as I can see OnActivated is only called if one of the following three conditions are fulfilled.
- The player is not sneaking.
- All held items have to doesSneakByPassUse (shields do not).
- Or the event force bypasses it (possible solution 2).
Or did I miss something?
boolean bypass = true;
for (ItemStack s : new ItemStack[]{player.getHeldItemMainhand(), player.getHeldItemOffhand()}) //TODO: Expand to more hands? player.inv.getHands()?
bypass = bypass && (s == null || s.getItem().doesSneakBypassUse(s, worldIn, pos, player));
EnumActionResult result = EnumActionResult.PASS;
if (!player.isSneaking() || bypass || event.getUseBlock() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW)
//onBlockActivated
net.minecraft.server.management.PlayerInteractionManager#processRightClickBlock @Forge1.10.2-12.18.3.2185