Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Chest orientation fixed and added chest opening/closing sound, fixes #…

  • Loading branch information...
commit 062346f1194b884681ad2abd274f884543933a05 1 parent 2e5383c
@fador authored
View
1  include/packets.h
@@ -106,6 +106,7 @@ enum
PACKET_MULTI_BLOCK_CHANGE = 0x34,
PACKET_BLOCK_CHANGE = 0x35,
PACKET_BLOCK_ACTION = 0x36,
+ PACKET_NAMED_SOUND_EFFECT = 0x3E,
PACKET_GAMESTATE = 0x46,
PACKET_OPEN_WINDOW = 0x64,
PACKET_PROGRESS_BAR = 0x69,
View
7 include/protocol.h
@@ -163,6 +163,13 @@ class Protocol
return ret;
}
+ static Packet namedSoundEffect(std::string name, int32_t x, int32_t y, int32_t z, float volume, int8_t pitch)
+ {
+ Packet ret;
+ ret << (int8_t)PACKET_NAMED_SOUND_EFFECT << name << x << y << z << volume << pitch;
+ return ret;
+ }
+
static Packet entityHeadLook(int eid, int head_yaw)
{
Packet ret;
View
52 src/blocks/chest.cpp
@@ -261,27 +261,47 @@ bool BlockChest::onPlace(User* user, int16_t newblock, int32_t x, int16_t y, int
}
direction = user->relativeToBlock(x, y, z);
-
+ printf("Direction: %d\r\n", direction);
//// Fix orientation
- //switch (direction)
- //{
- //case BLOCK_EAST:
- // direction = BLOCK_SOUTH;
- // break;
- //case BLOCK_BOTTOM:
- // direction = BLOCK_EAST;
- // break;
- //case BLOCK_NORTH:
- // direction = BLOCK_NORTH;
- // break;
- //case BLOCK_SOUTH:
- // direction = BLOCK_BOTTOM;
- // break;
- //}
+
+ switch (direction)
+ {
+ case BLOCK_EAST:
+ //direction = BLOCK_SOUTH;
+ break;
+ case BLOCK_BOTTOM:
+ direction = BLOCK_WEST;
+ break;
+ case BLOCK_NORTH:
+ direction = BLOCK_TOP;
+ break;
+ case BLOCK_SOUTH:
+ //direction = BLOCK_NORTH;
+ break;
+ }
+
int32_t connectedChestX, connectedChestZ;
if(findConnectedChest(x, y, z, map, &connectedChestX, &connectedChestZ))
{
+ if(connectedChestX != x)
+ {
+ if(!(direction == 3 || direction == 2))
+ {
+ direction = 3;
+ }
+ }
+ if(connectedChestZ != z)
+ {
+ if(!(direction == 4 || direction == 5))
+ {
+ direction = 4;
+ }
+ }
+
+ ServerInstance->map(map)->setBlock(connectedChestX, y, connectedChestZ, (char)newblock, direction);
+ ServerInstance->map(map)->sendBlockChange(connectedChestX, y, connectedChestZ, (char)newblock, direction);
+
// create a new chest and connect it to another chest --> large chest
chestDataPtr connectedChest;
if(getChestByCoordinates(connectedChestX, y, connectedChestZ, map, connectedChest))
View
4 src/inventory.cpp
@@ -1288,7 +1288,8 @@ bool Inventory::onwindowOpen(User* user, int8_t type, int32_t x, int32_t y, int3
{
case WINDOW_CHEST:
case WINDOW_LARGE_CHEST:
- pkt << Protocol::blockAction(x,y,z,1,1,BLOCK_CHEST);
+ pkt << Protocol::blockAction(x,y,z,1,1,BLOCK_CHEST)
+ << Protocol::namedSoundEffect("random.chestopen", x, y, z, 9.0, 63);
user->sendAll(pkt);
break;
}
@@ -1349,6 +1350,7 @@ bool Inventory::onwindowClose(User* user, int8_t type, int32_t x, int32_t y, int
if(type == WINDOW_CHEST || type == WINDOW_LARGE_CHEST)
{
Packet pkt = Protocol::blockAction(x,y,z,1,0,BLOCK_CHEST);
+ pkt << Protocol::namedSoundEffect("random.chestclosed", x, y, z, 9.0, 63);
user->sendAll(pkt);
}
Please sign in to comment.
Something went wrong with that request. Please try again.