diff --git a/Minecraft.Client/LocalPlayer.cpp b/Minecraft.Client/LocalPlayer.cpp index 852b830814..f40a5867f9 100644 --- a/Minecraft.Client/LocalPlayer.cpp +++ b/Minecraft.Client/LocalPlayer.cpp @@ -1279,6 +1279,12 @@ void LocalPlayer::handleMouseDown(int button, bool down) if (!down) missTime = 0; if (button == 0 && missTime > 0) return; + if (isBlocking()) + { + minecraft->gameMode->stopDestroyBlock(); + return; + } + if (down && minecraft->hitResult != nullptr && minecraft->hitResult->type == HitResult::TILE && button == 0) { int x = minecraft->hitResult->x; @@ -1476,7 +1482,7 @@ bool LocalPlayer::handleMouseClick(int button) bool returnItemPlaced = false; if (button == 0 && missTime > 0) return false; - if (button == 0) + if (button == 0 && !isBlocking()) { //app.DebugPrintf("handleMouseClick - Player %d is swinging\n",GetXboxPad()); swing(); @@ -1510,7 +1516,7 @@ bool LocalPlayer::handleMouseClick(int button) } else if (minecraft->hitResult->type == HitResult::ENTITY) { - if (button == 0) + if (button == 0 && !isBlocking()) { minecraft->gameMode->attack(minecraft->localplayers[GetXboxPad()], minecraft->hitResult->entity); } diff --git a/Minecraft.Client/MultiPlayerGameMode.cpp b/Minecraft.Client/MultiPlayerGameMode.cpp index 96071d283f..130879a8cc 100644 --- a/Minecraft.Client/MultiPlayerGameMode.cpp +++ b/Minecraft.Client/MultiPlayerGameMode.cpp @@ -116,6 +116,8 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { if(!minecraft->player->isAllowedToMine()) return; + if(minecraft->player->isBlocking()) return; + if (localPlayerMode->isAdventureRestricted()) { if (!minecraft->player->mayDestroyBlockAt(x, y, z)) @@ -181,6 +183,13 @@ void MultiPlayerGameMode::stopDestroyBlock() void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) { if(!minecraft->player->isAllowedToMine()) return; + if(minecraft->player->isBlocking()) + { + isDestroying = false; + destroyProgress = 0; + minecraft->level->destroyTileProgress(minecraft->player->entityId, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1); + return; + } ensureHasSentCarriedItem(); // connection.send(new PlayerActionPacket(PlayerActionPacket.CONTINUE_DESTROY_BLOCK, x, y, z, face)); diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index db6ee06e1d..ee327b1d85 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -243,9 +243,13 @@ void Player::updateFrameTick() // 4J Stu - Fix for #45508 - TU5: Gameplay: Eating one piece of food will result in a second piece being eaten as well // Original code was item != useItem. Changed this now to use the equals function, and add the nullptr check as well for the other possible not equals (useItem is not nullptr if we are here) // This is because the useItem and item could be different objects due to an inventory update from the server, but still be the same item (with the same id,count and auxvalue) - if (item == nullptr || !item->equals(useItem) ) + if (item == nullptr || !item->equals(useItem)) { - stopUsingItem(); + const UseAnim anim = useItem->getUseAnimation(); + if (anim != UseAnim_block) + { + stopUsingItem(); + } } else { @@ -1467,7 +1471,7 @@ void Player::actuallyHurt(DamageSource *source, float dmg) if (isInvulnerable()) return; if (!source->isBypassArmor() && isBlocking() && dmg > 0) { - dmg = (1 + dmg) * .5f; + dmg = dmg * 0.5f; } dmg = getDamageAfterArmorAbsorb(source, dmg); dmg = getDamageAfterMagicAbsorb(source, dmg); @@ -2482,6 +2486,13 @@ void Player::startUsingItem(shared_ptr instance, int duration) setUsingItemFlag(true); } + if (instance->getUseAnimation() == UseAnim_block) + { + swinging = false; + swingTime = 0; + attackAnim = 0.0f; + } + // 4J-JEV, hook for ItemUsed event, and ironbelly achievement. awardStat(GenericStats::itemsUsed(instance->getItem()->id), GenericStats::param_itemsUsed(dynamic_pointer_cast(shared_from_this()),instance));