summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2015-05-19 19:43:19 +0200
committerAlexander Harkness <bearbin@gmail.com>2015-05-19 19:43:19 +0200
commitcbb425f027a7b51c4aed5d3399b26cf325c4c8ce (patch)
tree6a35f2c9c44b7d3d5142635178bf1ec9ca5e428c /src/Blocks
parentUpdated Core. (diff)
parentMerge pull request #2057 from Seadragon91/master (diff)
downloadcuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar
cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.gz
cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.bz2
cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.lz
cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.xz
cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.tar.zst
cuberite-cbb425f027a7b51c4aed5d3399b26cf325c4c8ce.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockBed.cpp4
-rw-r--r--src/Blocks/BlockComparator.h2
-rw-r--r--src/Blocks/BlockDoor.cpp6
-rw-r--r--src/Blocks/BlockFire.h6
-rw-r--r--src/Blocks/BlockLeaves.h28
-rw-r--r--src/Blocks/BlockLever.h2
-rw-r--r--src/Blocks/BlockPiston.h2
-rw-r--r--src/Blocks/BlockRail.h16
-rw-r--r--src/Blocks/BlockTrapdoor.h2
9 files changed, 40 insertions, 28 deletions
diff --git a/src/Blocks/BlockBed.cpp b/src/Blocks/BlockBed.cpp
index e56f4bfe0..dfa392d9b 100644
--- a/src/Blocks/BlockBed.cpp
+++ b/src/Blocks/BlockBed.cpp
@@ -14,7 +14,7 @@ void cBlockBedHandler::OnDestroyed(cChunkInterface & a_ChunkInterface, cWorldInt
NIBBLETYPE OldMeta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
Vector3i ThisPos( a_BlockX, a_BlockY, a_BlockZ);
- Vector3i Direction = MetaDataToDirection( OldMeta & 0x7);
+ Vector3i Direction = MetaDataToDirection( OldMeta & 0x3);
if (OldMeta & 0x8)
{
// Was pillow
@@ -111,7 +111,7 @@ void cBlockBedHandler::OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface
// Is foot end
VERIFY((Meta & 0x4) != 0x4); // Occupied flag should never be set, else our compilator (intended) is broken
- PillowDirection = MetaDataToDirection(Meta & 0x7);
+ PillowDirection = MetaDataToDirection(Meta & 0x3);
if (a_ChunkInterface.GetBlock(a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z) == E_BLOCK_BED) // Must always use pillow location for sleeping
{
a_WorldInterface.GetBroadcastManager().BroadcastUseBed(*a_Player, a_BlockX + PillowDirection.x, a_BlockY, a_BlockZ + PillowDirection.z);
diff --git a/src/Blocks/BlockComparator.h b/src/Blocks/BlockComparator.h
index 3443fc69e..ed73a162e 100644
--- a/src/Blocks/BlockComparator.h
+++ b/src/Blocks/BlockComparator.h
@@ -22,7 +22,7 @@ public:
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
- Meta ^= 0x04; // Toggle 3rd (addition/subtraction) bit with XOR
+ Meta ^= 0x04; // Toggle 3rd (addition / subtraction) bit with XOR
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
}
diff --git a/src/Blocks/BlockDoor.cpp b/src/Blocks/BlockDoor.cpp
index d2bf180be..d13c8d657 100644
--- a/src/Blocks/BlockDoor.cpp
+++ b/src/Blocks/BlockDoor.cpp
@@ -134,7 +134,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
return a_Meta;
}
- // Holds open/closed meta data. 0x0C == 1100.
+ // Holds open / closed meta data. 0x0C == 1100.
NIBBLETYPE OtherMeta = a_Meta & 0x0C;
// Mirrors according to a table. 0x03 == 0011.
@@ -152,7 +152,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorXY(NIBBLETYPE a_Meta)
NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
{
- // Top bit (0x08) contains door panel type (Top/Bottom panel) Only Bottom panels contain position data
+ // Top bit (0x08) contains door panel type (Top / Bottom panel) Only Bottom panels contain position data
// Return a_Meta if panel is a top panel (0x08 bit is set to 1)
// Note: Currently, you can not properly mirror the hinges on a double door. The orientation of the door is stored
@@ -165,7 +165,7 @@ NIBBLETYPE cBlockDoorHandler::MetaMirrorYZ(NIBBLETYPE a_Meta)
return a_Meta;
}
- // Holds open/closed meta data. 0x0C == 1100.
+ // Holds open / closed meta data. 0x0C == 1100.
NIBBLETYPE OtherMeta = a_Meta & 0x0C;
// Mirrors according to a table. 0x03 == 0011.
diff --git a/src/Blocks/BlockFire.h b/src/Blocks/BlockFire.h
index bafd385ab..2038df94b 100644
--- a/src/Blocks/BlockFire.h
+++ b/src/Blocks/BlockFire.h
@@ -106,7 +106,7 @@ public:
void FindAndSetPortalFrame(int X, int Y, int Z, cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface)
{
int MaxY = FindObsidianCeiling(X, Y, Z, a_ChunkInterface); // Get topmost obsidian block as reference for all other checks
- int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add/subtract one as we've checked the original already the line above
+ int X1 = X + 1, Z1 = Z + 1, X2 = X - 1, Z2 = Z - 1; // Duplicate XZ values, add / subtract one as we've checked the original already the line above
if (MaxY == 0) // Oh noes! Not a portal coordinate :(
{
@@ -139,7 +139,7 @@ public:
return;
}
- /** Evaluates if coordinates are a portal going XP/XM; returns true if so, and writes boundaries to variable
+ /** Evaluates if coordinates are a portal going XP / XM; returns true if so, and writes boundaries to variable
Takes coordinates of base block and Y coord of target obsidian ceiling */
bool FindPortalSliceX(int X1, int X2, int Y, int Z, int MaxY, cChunkInterface & a_ChunkInterface)
{
@@ -179,7 +179,7 @@ public:
return (FoundFrameXP && FoundFrameXM);
}
- /// Evaluates if coords are a portal going ZP/ZM; returns true if so, and writes boundaries to variable
+ /// Evaluates if coords are a portal going ZP / ZM; returns true if so, and writes boundaries to variable
bool FindPortalSliceZ(int X, int Y, int Z1, int Z2, int MaxY, cChunkInterface & a_ChunkInterface)
{
Dir = 2;
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index bd9a7414e..4d4610fd8 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -40,29 +40,41 @@ public:
{
cFastRandom rand;
- // Old leaves - 3 bits contain display; new leaves - 1st bit, shifted left two for saplings to understand
- if (rand.NextInt(6) == 0)
+ // There is a chance to drop a sapling that varies depending on the type of leaf broken.
+ // TODO: Take into account fortune for sapling drops.
+ int chance;
+ if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_JUNGLE))
+ {
+ // Jungle leaves have a 2.5% chance of dropping a sapling.
+ chance = rand.NextInt(40);
+ }
+ else
+ {
+ // Other leaves have a 5% chance of dropping a sapling.
+ chance = rand.NextInt(20);
+ }
+ if (chance == 0)
{
a_Pickups.push_back(
cItem(
E_BLOCK_SAPLING,
1,
- (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (2 << (a_BlockMeta & 0x01))
+ (m_BlockType == E_BLOCK_LEAVES) ? (a_BlockMeta & 0x03) : (4 + (a_BlockMeta & 0x01))
)
);
}
-
- // 1 % chance of dropping an apple, if the leaves' type is Apple Leaves
+
+ // 0.5 % chance of dropping an apple, if the leaves' type is Apple Leaves
if ((m_BlockType == E_BLOCK_LEAVES) && ((a_BlockMeta & 0x03) == E_META_LEAVES_APPLE))
{
- if (rand.NextInt(101) == 0)
+ if (rand.NextInt(200) == 0)
{
a_Pickups.push_back(cItem(E_ITEM_RED_APPLE, 1, 0));
}
}
}
-
-
+
+
virtual void OnNeighborChanged(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) override
{
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
diff --git a/src/Blocks/BlockLever.h b/src/Blocks/BlockLever.h
index f5bedea6c..2da138e5f 100644
--- a/src/Blocks/BlockLever.h
+++ b/src/Blocks/BlockLever.h
@@ -19,7 +19,7 @@ public:
virtual void OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
{
- // Flip the ON bit on/off using the XOR bitwise operation
+ // Flip the ON bit on / off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x08);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);
diff --git a/src/Blocks/BlockPiston.h b/src/Blocks/BlockPiston.h
index 9a891025a..5933d4885 100644
--- a/src/Blocks/BlockPiston.h
+++ b/src/Blocks/BlockPiston.h
@@ -108,7 +108,7 @@ private:
case E_BLOCK_ENCHANTMENT_TABLE:
case E_BLOCK_END_PORTAL:
case E_BLOCK_END_PORTAL_FRAME:
- // Notice the lack of an E_BLOCK_ENDER_CHEST here; its because ender chests can totally be pushed/pulled in MCS :)
+ // Notice the lack of an E_BLOCK_ENDER_CHEST here; its because ender chests can totally be pushed / pulled in MCS :)
case E_BLOCK_FURNACE:
case E_BLOCK_LIT_FURNACE:
case E_BLOCK_INVERTED_DAYLIGHT_SENSOR:
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 02fe3aa95..a2e27a351 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -502,11 +502,11 @@ public:
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Rotates according to table; 0x07 == 0111.
- // Rails can either be flat (North/South) or Ascending (Asc. East)
+ // Rails can either be flat (North / South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
- case 0x00: return 0x01 + OtherMeta; // North/South -> East/West
- case 0x01: return 0x00 + OtherMeta; // East/West -> North/South
+ case 0x00: return 0x01 + OtherMeta; // North / South -> East / West
+ case 0x01: return 0x00 + OtherMeta; // East / West -> North / South
case 0x02: return 0x04 + OtherMeta; // Asc. East -> Asc. North
case 0x04: return 0x03 + OtherMeta; // Asc. North -> Asc. West
@@ -538,11 +538,11 @@ public:
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Rotates according to table; 0x07 == 0111.
- // Rails can either be flat (North/South) or Ascending (Asc. East)
+ // Rails can either be flat (North / South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
- case 0x00: return 0x01 + OtherMeta; // North/South -> East/West
- case 0x01: return 0x00 + OtherMeta; // East/West -> North/South
+ case 0x00: return 0x01 + OtherMeta; // North / South -> East / West
+ case 0x01: return 0x00 + OtherMeta; // East / West -> North / South
case 0x02: return 0x05 + OtherMeta; // Asc. East -> Asc. South
case 0x05: return 0x03 + OtherMeta; // Asc. South -> Asc. West
@@ -574,7 +574,7 @@ public:
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Mirrors according to table; 0x07 == 0111.
- // Rails can either be flat (North/South) or Ascending (Asc. East)
+ // Rails can either be flat (North / South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
case 0x05: return 0x04 + OtherMeta; // Asc. South -> Asc. North
@@ -605,7 +605,7 @@ public:
// Save powered rail flag.
NIBBLETYPE OtherMeta = a_Meta & 0x08;
// Mirrors according to table; 0x07 == 0111.
- // Rails can either be flat (North/South) or Ascending (Asc. East)
+ // Rails can either be flat (North / South) or Ascending (Asc. East)
switch (a_Meta & 0x07)
{
case 0x02: return 0x03 + OtherMeta; // Asc. East -> Asc. West
diff --git a/src/Blocks/BlockTrapdoor.h b/src/Blocks/BlockTrapdoor.h
index 8c96de0f1..dbb0b5a5b 100644
--- a/src/Blocks/BlockTrapdoor.h
+++ b/src/Blocks/BlockTrapdoor.h
@@ -35,7 +35,7 @@ public:
return;
}
- // Flip the ON bit on/off using the XOR bitwise operation
+ // Flip the ON bit on / off using the XOR bitwise operation
NIBBLETYPE Meta = (a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) ^ 0x04);
a_ChunkInterface.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, Meta);