mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-04-27 09:26:47 +00:00
Sword blocking mechanics and interactoin locks (#1532)
- Fixed #1532 by makingthe blocking correctly reduces damage; per Java 1.8 mechs. - Fixed an attack going through while blocking. - Fixed a bug where you could mine while blocking. - Swing animation while blocking was overrided; per Java 1.8 mechs.
This commit is contained in:
parent
0fc2b5aa5b
commit
4b911b09b7
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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<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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue