1
0

Fix rotation metas on blocks

This commit is contained in:
Alexander Harkness 2020-04-11 00:20:51 +01:00
parent f38ad5efb5
commit 8914355895
8 changed files with 31 additions and 31 deletions

View File

@ -2,6 +2,7 @@
#pragma once
#include "BlockHandler.h"
#include "Mixins.h"
#include "../Entities/Player.h"
#include "../UI/AnvilWindow.h"
@ -10,11 +11,13 @@
class cBlockAnvilHandler :
public cBlockHandler
public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>
{
public:
using super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>;
cBlockAnvilHandler(BLOCKTYPE a_BlockType)
: cBlockHandler(a_BlockType)
: super(a_BlockType)
{
}
@ -45,21 +48,12 @@ public:
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) override
{
a_BlockType = m_BlockType;
NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
int Direction = static_cast<int>(floor(a_Player.GetYaw() * 4.0 / 360.0 + 1.5)) & 0x3;
switch (Direction)
if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
{
case 0: a_BlockMeta = static_cast<NIBBLETYPE>(0x2 | Meta << 2); break;
case 1: a_BlockMeta = static_cast<NIBBLETYPE>(0x3 | Meta << 2); break;
case 2: a_BlockMeta = static_cast<NIBBLETYPE>(0x0 | Meta << 2); break;
case 3: a_BlockMeta = static_cast<NIBBLETYPE>(0x1 | Meta << 2); break;
default:
{
return false;
}
return false;
}
a_BlockMeta = a_BlockMeta | static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage << 2);
return true;
}

View File

@ -11,9 +11,9 @@
class cBlockChestHandler :
public cYawRotator<cContainerEntityHandler<cBlockEntityHandler>>
public cYawRotator<cContainerEntityHandler<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>
{
using super = cYawRotator<cContainerEntityHandler<cBlockEntityHandler>>;
using super = cYawRotator<cContainerEntityHandler<cBlockEntityHandler>, 0x07, 0x03, 0x04, 0x02, 0x05>;
public:

View File

@ -12,9 +12,9 @@
class cBlockDoorHandler :
public cYawRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true>
public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>
{
using super = cYawRotator<cBlockHandler, 0x03, 0x01, 0x02, 0x03, 0x00, true>;
using super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>;
public:

View File

@ -14,9 +14,9 @@
class cBlockDropSpenserHandler :
public cPitchYawRotator<cBlockEntityHandler>
public cPitchYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>
{
using super = cPitchYawRotator<cBlockEntityHandler>;
using super = cPitchYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>;
public:

View File

@ -9,9 +9,9 @@
class cBlockFurnaceHandler :
public cYawRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>
public cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05>
{
using super = cYawRotator<cBlockEntityHandler, 0x07, 0x02, 0x05, 0x03, 0x04>;
using super = cYawRotator<cBlockEntityHandler, 0x07, 0x03, 0x04, 0x02, 0x05>;
public:

View File

@ -17,9 +17,9 @@ class cWorld;
class cBlockPistonHandler:
public cClearMetaOnDrop<cPitchYawRotator<cBlockHandler>>
public cClearMetaOnDrop<cPitchYawRotator<cBlockHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>>
{
using super = cClearMetaOnDrop<cPitchYawRotator<cBlockHandler>>;
using super = cClearMetaOnDrop<cPitchYawRotator<cBlockHandler, 0x07, 0x03, 0x04, 0x02, 0x05, 0x01, 0x00>>;
public:

View File

@ -6,9 +6,9 @@
class cBlockPumpkinHandler :
public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01>>
public cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>>
{
using super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x07, 0x02, 0x03, 0x00, 0x01>>;
using super = cClearMetaOnDrop<cYawRotator<cBlockHandler, 0x03, 0x00, 0x01, 0x02, 0x03>>;
public:
cBlockPumpkinHandler(BLOCKTYPE a_BlockType) :

View File

@ -203,7 +203,10 @@ public:
) override
{
NIBBLETYPE BaseMeta;
super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta);
if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta))
{
return false;
}
a_BlockMeta = (BaseMeta & ~BitMask) | YawToMetaData(a_Player.GetYaw());
return true;
@ -249,8 +252,8 @@ template <
NIBBLETYPE East = 0x05,
NIBBLETYPE South = 0x03,
NIBBLETYPE West = 0x04,
NIBBLETYPE Up = 0x01,
NIBBLETYPE Down = 0x00
NIBBLETYPE Up = 0x00,
NIBBLETYPE Down = 0x01
>
class cPitchYawRotator:
public cYawRotator<Base, BitMask, North, East, South, West>
@ -274,7 +277,10 @@ public:
) override
{
NIBBLETYPE BaseMeta;
super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta);
if (!super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, BaseMeta))
{
return false;
}
a_BlockMeta = (BaseMeta & ~BitMask) | PitchYawToMetaData(a_Player.GetYaw(), a_Player.GetPitch());
return true;