Files
MinecraftConsoles/Minecraft.World/PressurePlateTile.cpp
ModMaker101 a9be52c41a Project modernization (#630)
* Fixed boats falling and a TP glitch #266

* Replaced every C-style cast with C++ ones

* Replaced every C-style cast with C++ ones

* Fixed boats falling and a TP glitch #266

* Updated NULL to nullptr and fixing some type issues

* Modernized and fixed a few bugs

- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.

* Fixing more conflicts

* Replace int loops with size_t and start work on overrides
2026-03-08 09:56:03 +07:00

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 __debugbreak(); // 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;
}