summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-09-16 17:48:19 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:31 +0100
commit892b9732751b64c2016ba476801e1fe4ed4e750f (patch)
tree99aa40953de5d61e30d47bdf345ee2cb9c3c18e1 /src/GameState.cpp
parent2017-09-15 (diff)
downloadAltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.tar
AltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.tar.gz
AltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.tar.bz2
AltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.tar.lz
AltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.tar.xz
AltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.tar.zst
AltCraft-892b9732751b64c2016ba476801e1fe4ed4e750f.zip
Diffstat (limited to '')
-rw-r--r--src/GameState.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp
index 46b236c..98b49f7 100644
--- a/src/GameState.cpp
+++ b/src/GameState.cpp
@@ -140,8 +140,17 @@ void GameState::UpdatePacket()
world.ParseChunkData(packet);
break;
}
- case ConfirmTransactionCB:
+ case ConfirmTransactionCB: {
+ auto packet = std::static_pointer_cast<PacketConfirmTransactionCB>(ptr);
+ if (packet->WindowId == 0) {
+ try {
+ playerInventory.ConfirmTransaction(*packet);
+ } catch (std::exception &e) {
+ EventAgregator::PushEvent(EventType::Disconnect, DisconnectData{ "Transaction failed" });
+ }
+ }
break;
+ }
case CloseWindowCB:
break;
case OpenWindow: {
@@ -160,8 +169,13 @@ void GameState::UpdatePacket()
}
case WindowProperty:
break;
- case SetSlot:
+ case SetSlot: {
+ auto packet = std::static_pointer_cast<PacketSetSlot>(ptr);
+ if (packet->WindowId == 0) {
+ playerInventory.slots[packet->Slot] = packet->SlotData;
+ }
break;
+ }
case SetCooldown:
break;
case PluginMessageCB:
@@ -433,7 +447,7 @@ void GameState::HandleMovement(GameState::Direction direction, float deltaTime)
break;
case JUMP:
if (g_OnGround) {
- vel.y += 10;
+ vel.y += 5;
g_OnGround = false;
}
break;