summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h9
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h9
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h9
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h1
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h9
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp1
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h16
7 files changed, 39 insertions, 15 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
index c216d12bc..0a5ffe136 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/CommandBlockHandler.h
@@ -31,9 +31,14 @@ namespace CommandBlockHandler
return;
}
- a_Chunk.DoWithCommandBlockAt(a_Position, [](cCommandBlockEntity & a_CommandBlock)
+ a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity)
{
- a_CommandBlock.Activate();
+ if (a_BlockEntity.GetBlockType() != E_BLOCK_COMMAND_BLOCK)
+ {
+ return false;
+ }
+
+ static_cast<cCommandBlockEntity &>(a_BlockEntity).Activate();
return false;
});
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h b/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h
index 309fa757a..4dd87e972 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/DropSpenserHandler.h
@@ -46,9 +46,14 @@ namespace DropSpenserHandler
if (IsPoweredNow && !WasPoweredPreviously)
{
- a_Chunk.DoWithDropSpenserAt(a_Position, [](cDropSpenserEntity & a_DropSpenser)
+ a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity)
{
- a_DropSpenser.Activate();
+ if ((a_BlockEntity.GetBlockType() != E_BLOCK_DISPENSER) && (a_BlockEntity.GetBlockType() != E_BLOCK_DROPPER))
+ {
+ return false;
+ }
+
+ static_cast<cDropSpenserEntity &>(a_BlockEntity).Activate();
return false;
});
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h b/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h
index 998a98677..379f7c7d8 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/HopperHandler.h
@@ -30,9 +30,14 @@ namespace HopperHandler
return;
}
- a_Chunk.DoWithHopperAt(a_Position, [Power](cHopperEntity & a_Hopper)
+ a_Chunk.DoWithBlockEntityAt(a_Position, [Power](cBlockEntity & a_BlockEntity)
{
- a_Hopper.SetLocked(Power != 0);
+ if (a_BlockEntity.GetBlockType() != E_BLOCK_HOPPER)
+ {
+ return false;
+ }
+
+ static_cast<cHopperEntity &>(a_BlockEntity).SetLocked(Power != 0);
return false;
});
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
index e8cd4bf5d..b13d1f6f5 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/IncrementalRedstoneSimulator.h
@@ -1,6 +1,7 @@
#pragma once
+#include "BlockType.h"
#include "../RedstoneSimulator.h"
#include "RedstoneSimulatorChunkData.h"
diff --git a/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h b/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h
index 6a2f66737..8bd639357 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/NoteBlockHandler.h
@@ -31,9 +31,14 @@ namespace NoteBlockHandler
return;
}
- a_Chunk.DoWithNoteBlockAt(a_Position, [](cNoteEntity & a_NoteBlock)
+ a_Chunk.DoWithBlockEntityAt(a_Position, [](cBlockEntity & a_BlockEntity)
{
- a_NoteBlock.MakeSound();
+ if (a_BlockEntity.GetBlockType() != E_BLOCK_NOTE_BLOCK)
+ {
+ return false;
+ }
+
+ static_cast<cNoteEntity &>(a_BlockEntity).MakeSound();
return false;
});
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp b/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp
index 63da4c0dc..ab6b35c0b 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator/RedstoneHandler.cpp
@@ -5,6 +5,7 @@
#include "RedstoneDataHelper.h"
#include "ForEachSourceCallback.h"
+#include "BlockType.h"
#include "CommandBlockHandler.h"
#include "DaylightSensorHandler.h"
#include "DoorHandler.h"
diff --git a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h
index 619401d80..145c5dc83 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h
+++ b/src/Simulator/IncrementalRedstoneSimulator/TrappedChestHandler.h
@@ -22,14 +22,16 @@ namespace TrappedChestHandler
static unsigned char GetPowerLevel(cChunk & a_Chunk, Vector3i a_Position)
{
int NumberOfPlayers = 0;
- VERIFY(
- !a_Chunk.DoWithChestAt(a_Position, [&](cChestEntity & a_Chest)
+ a_Chunk.DoWithBlockEntityAt(a_Position, [&NumberOfPlayers](cBlockEntity & a_BlockEntity)
+ {
+ if (a_BlockEntity.GetBlockType() != E_BLOCK_TRAPPED_CHEST)
{
- ASSERT(a_Chest.GetBlockType() == E_BLOCK_TRAPPED_CHEST);
- NumberOfPlayers = a_Chest.GetNumberOfPlayers();
- return true;
- })
- );
+ return false;
+ }
+
+ NumberOfPlayers = static_cast<cChestEntity &>(a_BlockEntity).GetNumberOfPlayers();
+ return false;
+ });
return static_cast<unsigned char>(std::min(NumberOfPlayers, 15));
}