mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-04-30 10:55:04 +00:00
Some checks failed
Nightly Server Release / build (Windows64) (push) Has been cancelled
Nightly Release / build (Windows64) (push) Has been cancelled
Nightly Server Release / release (push) Has been cancelled
Nightly Server Release / Build and Push Docker Image (push) Has been cancelled
Nightly Server Release / cleanup (push) Has been cancelled
Nightly Release / release (push) Has been cancelled
Nightly Release / cleanup (push) Has been cancelled
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
#include "stdafx.h"
|
|
#include "net.minecraft.world.level.h"
|
|
#include "net.minecraft.world.level.redstone.h"
|
|
#include "PressurePlateTile.h"
|
|
|
|
PressurePlateTile::PressurePlateTile(int id, const wstring &tex, Material *material, Sensitivity sensitivity) : BasePressurePlateTile(id, tex, material)
|
|
{
|
|
this->sensitivity = sensitivity;
|
|
|
|
// 4J Stu - Move this from base class to use virtual function
|
|
updateShape(getDataForSignal(Redstone::SIGNAL_MAX));
|
|
}
|
|
|
|
int PressurePlateTile::getDataForSignal(int signal)
|
|
{
|
|
return signal > 0 ? 1 : 0;
|
|
}
|
|
|
|
int PressurePlateTile::getSignalForData(int data)
|
|
{
|
|
return data == 1 ? Redstone::SIGNAL_MAX : 0;
|
|
}
|
|
|
|
int PressurePlateTile::getSignalStrength(Level *level, int x, int y, int z)
|
|
{
|
|
vector< shared_ptr<Entity> > *entities = nullptr;
|
|
|
|
if (sensitivity == everything) entities = level->getEntities(nullptr, getSensitiveAABB(x, y, z));
|
|
else if (sensitivity == mobs) entities = level->getEntitiesOfClass(typeid(LivingEntity), getSensitiveAABB(x, y, z));
|
|
else if (sensitivity == players) entities = level->getEntitiesOfClass(typeid(Player), getSensitiveAABB(x, y, z));
|
|
else DEBUG_BREAK(); // 4J-JEV: We're going to delete something at a random location.
|
|
|
|
if (entities != nullptr && !entities->empty())
|
|
{
|
|
for (auto& e : *entities)
|
|
{
|
|
if (!e->isIgnoringTileTriggers())
|
|
{
|
|
if (sensitivity != everything) delete entities;
|
|
return Redstone::SIGNAL_MAX;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (sensitivity != everything) delete entities;
|
|
return Redstone::SIGNAL_NONE;
|
|
} |