Removed dependecy of redstone simulator on NoteBlock
This commit is contained in:
parent
06942871dd
commit
9272bd627c
@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "BlockEntity.h"
|
||||
#include "RedstonePoweredEntity.h"
|
||||
|
||||
|
||||
namespace Json
|
||||
@ -29,7 +30,8 @@ enum ENUM_NOTE_INSTRUMENTS
|
||||
// tolua_begin
|
||||
|
||||
class cNoteEntity :
|
||||
public cBlockEntity
|
||||
public cBlockEntity,
|
||||
public cRedstonePoweredEntity
|
||||
{
|
||||
typedef cBlockEntity super;
|
||||
public:
|
||||
@ -38,6 +40,7 @@ public:
|
||||
|
||||
/// Creates a new note entity. a_World may be NULL
|
||||
cNoteEntity(int a_X, int a_Y, int a_Z, cWorld * a_World);
|
||||
virtual ~cNoteEntity() {}
|
||||
|
||||
bool LoadFromJson(const Json::Value & a_Value);
|
||||
virtual void SaveToJson(Json::Value & a_Value) override;
|
||||
@ -53,6 +56,11 @@ public:
|
||||
|
||||
virtual void UsedBy(cPlayer * a_Player) override;
|
||||
virtual void SendTo(cClientHandle &) override {}
|
||||
|
||||
virtual void SetRedstonePower(bool a_Value)
|
||||
{
|
||||
if (a_Value) MakeSound();
|
||||
}
|
||||
|
||||
static const char * GetClassStatic(void) { return "cNoteEntity"; }
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// Interface class representing a blockEntity that responds to redstone
|
||||
class cRedstonePoweredEntity
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~cRedstonePoweredEntity() {};
|
||||
|
||||
/// Sets the internal redstone power flag to "on" or "off", depending on the parameter. Calls Activate() if appropriate
|
||||
virtual void SetRedstonePower(bool a_IsPowered) = 0;
|
||||
};
|
||||
|
@ -2141,6 +2141,7 @@ bool cChunk::DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_Blo
|
||||
{
|
||||
case E_BLOCK_DROPPER:
|
||||
case E_BLOCK_DISPENSER:
|
||||
case E_BLOCK_NOTE_BLOCK:
|
||||
break;
|
||||
default:
|
||||
// There is a block entity here, but of different type. No other block entity can be here, so we can safely bail out
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "IncrementalRedstoneSimulator.h"
|
||||
#include "BoundingBox.h"
|
||||
#include "../BlockEntities/RedstonePoweredEntity.h"
|
||||
#include "../BlockEntities/NoteEntity.h"
|
||||
#include "../BlockEntities/ChestEntity.h"
|
||||
#include "../BlockEntities/CommandBlockEntity.h"
|
||||
#include "../Entities/Pickup.h"
|
||||
@ -1033,25 +1032,21 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_RelBlockX, int a_RelBl
|
||||
if (!AreCoordsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true))
|
||||
{
|
||||
class cSetPowerToNoteBlock :
|
||||
public cNoteBlockCallback
|
||||
public cRedstonePoweredCallback
|
||||
{
|
||||
bool m_IsPowered;
|
||||
public:
|
||||
cSetPowerToNoteBlock(bool a_IsPowered) : m_IsPowered(a_IsPowered) {}
|
||||
cSetPowerToNoteBlock() {}
|
||||
|
||||
virtual bool Item(cNoteEntity * a_NoteBlock) override
|
||||
virtual bool Item(cRedstonePoweredEntity * a_NoteBlock) override
|
||||
{
|
||||
if (m_IsPowered)
|
||||
{
|
||||
a_NoteBlock->MakeSound();
|
||||
}
|
||||
a_NoteBlock->SetRedstonePower(true);
|
||||
return false;
|
||||
}
|
||||
} NoteBlockSP(m_bAreCoordsPowered);
|
||||
} NoteBlockSP;
|
||||
|
||||
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
|
||||
int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
|
||||
m_Chunk->DoWithNoteBlockAt(BlockX, a_RelBlockY, BlockZ, NoteBlockSP);
|
||||
m_Chunk->DoWithRedstonePoweredEntityAt(BlockX, a_RelBlockY, BlockZ, NoteBlockSP);
|
||||
SetPlayerToggleableBlockAsSimulated(a_RelBlockX, a_RelBlockY, a_RelBlockZ, true);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user