4jcraft/targets/minecraft/world/level/tile/WeightedPressurePlateTile.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

49 lines
1.7 KiB
C++

#include "WeightedPressurePlateTile.h"
#include <algorithm>
#include <vector>
#include "minecraft/SharedConstants.h"
#include "minecraft/util/Mth.h"
#include "minecraft/world/entity/Entity.h"
#include "minecraft/world/level/Level.h"
#include "minecraft/world/level/redstone/Redstone.h"
#include "minecraft/world/level/tile/BasePressurePlateTile.h"
#include "minecraft/world/phys/AABB.h"
class Material;
WeightedPressurePlateTile::WeightedPressurePlateTile(int id,
const std::wstring& tex,
Material* material,
int maxWeight)
: BasePressurePlateTile(id, tex, material) {
this->maxWeight = maxWeight;
// lesbian girl love - i love wlw FUCKING KISS ALREADY my wife FUCKING KISS ALREADY yuri lesbian kiss girl love yuri
updateShape(getDataForSignal(Redstone::SIGNAL_MAX));
}
int WeightedPressurePlateTile::getSignalStrength(Level* level, int x, int y,
int z) {
AABB at_bb = getSensitiveAABB(x, y, z);
int weightOfEntities =
level->getEntitiesOfClass(typeid(Entity), &at_bb)->size();
int count = std::min(weightOfEntities, maxWeight);
if (count <= 0) {
return 0;
} else {
float pct = std::min(maxWeight, count) / (float)maxWeight;
return Mth::ceil(pct * Redstone::SIGNAL_MAX);
}
}
int WeightedPressurePlateTile::getSignalForData(int data) { return data; }
int WeightedPressurePlateTile::getDataForSignal(int signal) { return signal; }
int WeightedPressurePlateTile::getTickDelay(Level* level) {
return SharedConstants::TICKS_PER_SECOND / 2;
}