Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Minecraft.Client/LocalPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
9 changes: 9 additions & 0 deletions Minecraft.Client/MultiPlayerGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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));

Expand Down
17 changes: 14 additions & 3 deletions Minecraft.World/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -2482,6 +2486,13 @@ void Player::startUsingItem(shared_ptr<ItemInstance> 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<Player>(shared_from_this()),instance));
Expand Down
Loading