summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorluksor111@gmail.com <luksor111@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-19 10:29:53 +0100
committerluksor111@gmail.com <luksor111@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-12-19 10:29:53 +0100
commita10c4774f541028817c2a08dc6860fef252d0200 (patch)
tree4db3805965552fccc43d14febb9e83148a0a3f5b /source
parentFixed time calculation in cWorld::Tick() (diff)
downloadcuberite-a10c4774f541028817c2a08dc6860fef252d0200.tar
cuberite-a10c4774f541028817c2a08dc6860fef252d0200.tar.gz
cuberite-a10c4774f541028817c2a08dc6860fef252d0200.tar.bz2
cuberite-a10c4774f541028817c2a08dc6860fef252d0200.tar.lz
cuberite-a10c4774f541028817c2a08dc6860fef252d0200.tar.xz
cuberite-a10c4774f541028817c2a08dc6860fef252d0200.tar.zst
cuberite-a10c4774f541028817c2a08dc6860fef252d0200.zip
Diffstat (limited to 'source')
-rw-r--r--source/BlockID.cpp4
-rw-r--r--source/Blocks/BlockDoor.cpp28
-rw-r--r--source/Blocks/BlockDoor.h7
-rw-r--r--source/Blocks/BlockFenceGate.h56
-rw-r--r--source/Blocks/BlockHandler.cpp2
5 files changed, 86 insertions, 11 deletions
diff --git a/source/BlockID.cpp b/source/BlockID.cpp
index 9a3682615..5f7302a85 100644
--- a/source/BlockID.cpp
+++ b/source/BlockID.cpp
@@ -395,9 +395,12 @@ public:
g_BlockTransparent[E_BLOCK_CHEST] = true;
g_BlockTransparent[E_BLOCK_COBWEB] = true;
g_BlockTransparent[E_BLOCK_CROPS] = true;
+ g_BlockTransparent[E_BLOCK_FENCE] = true;
+ g_BlockTransparent[E_BLOCK_FENCE_GATE] = true;
g_BlockTransparent[E_BLOCK_FIRE] = true;
g_BlockTransparent[E_BLOCK_GLASS] = true;
g_BlockTransparent[E_BLOCK_ICE] = true;
+ g_BlockTransparent[E_BLOCK_IRON_DOOR] = true;
g_BlockTransparent[E_BLOCK_LEAVES] = true;
g_BlockTransparent[E_BLOCK_RED_MUSHROOM] = true;
g_BlockTransparent[E_BLOCK_RED_ROSE] = true;
@@ -407,6 +410,7 @@ public:
g_BlockTransparent[E_BLOCK_TORCH] = true;
g_BlockTransparent[E_BLOCK_VINES] = true;
g_BlockTransparent[E_BLOCK_WALLSIGN] = true;
+ g_BlockTransparent[E_BLOCK_WOODEN_DOOR] = true;
g_BlockTransparent[E_BLOCK_YELLOW_FLOWER] = true;
g_BlockTransparent[E_BLOCK_RAIL] = true;
g_BlockTransparent[E_BLOCK_DETECTOR_RAIL] = true;
diff --git a/source/Blocks/BlockDoor.cpp b/source/Blocks/BlockDoor.cpp
index c0d616b37..1976e2f20 100644
--- a/source/Blocks/BlockDoor.cpp
+++ b/source/Blocks/BlockDoor.cpp
@@ -54,15 +54,6 @@ void cBlockDoorHandler::OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY
-void cBlockDoorHandler::OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
-{
- cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
-}
-
-
-
-
-
void cBlockDoorHandler::OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
cDoors::ChangeDoor(a_World, a_BlockX, a_BlockY, a_BlockZ);
@@ -77,7 +68,24 @@ void cBlockDoorHandler::PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLET
if (a_World->GetBlock(a_BlockX, a_BlockY + 1, a_BlockZ) == E_BLOCK_AIR)
{
a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation());
- a_World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, m_BlockType, a_BlockMeta + 8);
+ char a_TopBlockMeta = 8;
+ if((a_BlockMeta == 0) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ - 1) == m_BlockType))
+ {
+ a_TopBlockMeta = 9;
+ }
+ else if((a_BlockMeta == 1) && (a_World->GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == m_BlockType))
+ {
+ a_TopBlockMeta = 9;
+ }
+ else if((a_BlockMeta == 2) && (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == m_BlockType))
+ {
+ a_TopBlockMeta = 9;
+ }
+ else if((a_BlockMeta == 3) && (a_World->GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == m_BlockType))
+ {
+ a_TopBlockMeta = 9;
+ }
+ a_World->SetBlock(a_BlockX, a_BlockY + 1, a_BlockZ, m_BlockType, a_TopBlockMeta);
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, a_BlockMeta);
OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
}
diff --git a/source/Blocks/BlockDoor.h b/source/Blocks/BlockDoor.h
index 7499e9c82..37584895f 100644
--- a/source/Blocks/BlockDoor.h
+++ b/source/Blocks/BlockDoor.h
@@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
+#include "../World.h"
@@ -14,7 +15,6 @@ public:
cBlockDoorHandler(BLOCKTYPE a_BlockType);
virtual void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir) override;
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
- virtual void OnDigging(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual const char * GetStepSound(void) override;
@@ -34,6 +34,11 @@ public:
{
return false;
}
+
+ virtual bool CanBeAt(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override
+ {
+ return a_World->GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ);
+ }
} ;
diff --git a/source/Blocks/BlockFenceGate.h b/source/Blocks/BlockFenceGate.h
new file mode 100644
index 000000000..072eb9c3a
--- /dev/null
+++ b/source/Blocks/BlockFenceGate.h
@@ -0,0 +1,56 @@
+
+#pragma once
+
+#include "BlockHandler.h"
+#include "../Doors.h"
+
+
+
+
+
+class cBlockFenceGateHandler :
+ public cBlockHandler
+{
+public:
+ cBlockFenceGateHandler(BLOCKTYPE a_BlockType)
+ : cBlockHandler(a_BlockType)
+ {
+ }
+
+ void OnPlaced(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, int a_Dir)
+ {
+
+ }
+
+ void PlaceBlock(cWorld * a_World, cPlayer * a_Player, NIBBLETYPE a_BlockMeta, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
+ {
+ a_BlockMeta = cDoors::RotationToMetaData(a_Player->GetRotation() + 270);
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, m_BlockType, a_BlockMeta);
+ OnPlacedByPlayer(a_World, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_Dir);
+ }
+
+ void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
+ {
+ char OldMetaData = a_World->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
+ char NewMetaData = cDoors::RotationToMetaData(a_Player->GetRotation() + 270);
+ OldMetaData ^= 4; //Toggle the gate
+ if((OldMetaData & 1) == (NewMetaData & 1)){
+ //Standing in front of the gate - apply new direction
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, (OldMetaData & 4) | (NewMetaData & 3));
+ }
+ else
+ {
+ //Standing aside - use last direction
+ a_World->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, OldMetaData);
+ }
+ }
+
+ virtual bool IsUseable() override
+ {
+ return true;
+ }
+} ;
+
+
+
+
diff --git a/source/Blocks/BlockHandler.cpp b/source/Blocks/BlockHandler.cpp
index 1572efa9e..13342117e 100644
--- a/source/Blocks/BlockHandler.cpp
+++ b/source/Blocks/BlockHandler.cpp
@@ -49,6 +49,7 @@
#include "BlockRail.h"
#include "BlockGlass.h"
#include "BlockEnderchest.h"
+#include "BlockFenceGate.h"
@@ -104,6 +105,7 @@ cBlockHandler * cBlockHandler::CreateBlockHandler(BLOCKTYPE a_BlockType)
case E_BLOCK_EMERALD_ORE: return new cBlockOreHandler (a_BlockType);
case E_BLOCK_ENDER_CHEST: return new cBlockEnderchestHandler (a_BlockType);
case E_BLOCK_FARMLAND: return new cBlockFarmlandHandler;
+ case E_BLOCK_FENCE_GATE: return new cBlockFenceGateHandler (a_BlockType);
case E_BLOCK_FIRE: return new cBlockFireHandler (a_BlockType);
case E_BLOCK_FURNACE: return new cBlockFurnaceHandler (a_BlockType);
case E_BLOCK_GLOWSTONE: return new cBlockGlowstoneHandler (a_BlockType);