Skip to content

Commit

Permalink
Added mechanics placeable on halfslabs
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Laubstein committed Oct 19, 2014
1 parent 3ee47df commit 403f858
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 14 deletions.
9 changes: 5 additions & 4 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ BasedDoge (Donated AlchemistVillage prefabs)
bearbin (Alexander Harkness)
derouinw
Diusrex
Duralex
Duralex
FakeTruth (founder)
Howaner
keyboard
Lapayo
Luksor
marmot21
Masy98
mborland
mgueydan
MikeHunsinger
Expand All @@ -18,18 +20,17 @@ nesco
rs2k
SamJBarney
Sofapriester
SphinxC0re
STR_Warrior
structinf (xdot)
Sxw1212
Taugeshtu
tigerw (Tiger Wang)
tonibm19
UltraCoderRU
WebFreak001
worktycho
xoft
Yeeeeezus (Donated AlchemistVillage prefabs)
Howaner
Masy98
WebFreak001

Please add yourself to this list if you contribute to MCServer.
36 changes: 29 additions & 7 deletions src/Blocks/BlockLever.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#pragma once

#include "BlockHandler.h"
#include "../Chunk.h"
#include "MetaRotator.h"


#include "BlockSlab.h"


class cBlockLeverHandler :
Expand Down Expand Up @@ -93,13 +93,35 @@ class cBlockLeverHandler :

virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
NIBBLETYPE Meta;
a_Chunk.UnboundedRelGetBlockMeta(a_RelX, a_RelY, a_RelZ, Meta);
NIBBLETYPE Meta = a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ);

eBlockFace Face = BlockMetaDataToBlockFace(Meta);

AddFaceDirection(a_RelX, a_RelY, a_RelZ, Face, true);

if ((a_RelY < 0) || (a_RelY >= cChunkDef::Height -1))
{
return false;
}

BLOCKTYPE BlockIsOn;
a_Chunk.UnboundedRelGetBlock(a_RelX, a_RelY, a_RelZ, BlockIsOn, Meta);

AddFaceDirection(a_RelX, a_RelY, a_RelZ, BlockMetaDataToBlockFace(Meta), true);
BLOCKTYPE BlockIsOn; a_Chunk.UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, BlockIsOn);

return (a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(BlockIsOn);
if (cBlockInfo::FullyOccupiesVoxel(BlockIsOn))
{
return true;
}
else if (cBlockSlabHandler::IsAnySlabType(BlockIsOn))
{
// Check if the slab is turned up side down
if (((Meta & 0x08) == 0x08) && (Face == BLOCK_FACE_TOP))
{
return true;
}
}

return false;
}


Expand Down
27 changes: 25 additions & 2 deletions src/Blocks/BlockRedstone.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "BlockHandler.h"
#include "../World.h"
#include "BlockSlab.h"



Expand All @@ -16,11 +17,33 @@ class cBlockRedstoneHandler :
: cBlockHandler(a_BlockType)
{
}




virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && cBlockInfo::FullyOccupiesVoxel(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
if (a_RelY <= 0)
{
return false;
}

BLOCKTYPE BelowBlock;
NIBBLETYPE BelowBlockMeta;
a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY - 1, a_RelZ, BelowBlock, BelowBlockMeta);

if (cBlockInfo::FullyOccupiesVoxel(BelowBlock))
{
return true;
}
else if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
{
// Check if the slab is turned up side down
if ((BelowBlockMeta & 0x08) == 0x08)
{
return true;
}
}
return false;
}


Expand Down
25 changes: 24 additions & 1 deletion src/Blocks/BlockRedstoneRepeater.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Chunk.h"
#include "MetaRotator.h"
#include "ChunkInterface.h"
#include "BlockSlab.h"



Expand Down Expand Up @@ -44,6 +45,7 @@ class cBlockRedstoneRepeaterHandler :
}



virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
{
// Reset meta to zero
Expand All @@ -59,7 +61,28 @@ class cBlockRedstoneRepeaterHandler :

virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
{
return ((a_RelY > 0) && cBlockInfo::IsSolid(a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ)));
if (a_RelY <= 0)
{
return false;
}

BLOCKTYPE BelowBlock;
NIBBLETYPE BelowBlockMeta;
a_Chunk.GetBlockTypeMeta(a_RelX, a_RelY - 1, a_RelZ, BelowBlock, BelowBlockMeta);

if (cBlockInfo::FullyOccupiesVoxel(BelowBlock))
{
return true;
}
else if (cBlockSlabHandler::IsAnySlabType(BelowBlock))
{
// Check if the slab is turned up side down
if ((BelowBlockMeta & 0x08) == 0x08)
{
return true;
}
}
return false;
}


Expand Down
1 change: 1 addition & 0 deletions src/Blocks/BlockSlab.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "../Items/ItemHandler.h"
#include "Root.h"
#include "ChunkInterface.h"
#include "../Entities/Player.h"



Expand Down

0 comments on commit 403f858

Please sign in to comment.