mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-27 17:36:49 +00:00
refactor: remove the last AABB::newTemp
This commit is contained in:
parent
ddfe9b3d48
commit
e48a05bb8f
|
|
@ -40,7 +40,8 @@ int BasePressurePlateTile::getTickDelay(Level* level) {
|
|||
return SharedConstants::TICKS_PER_SECOND;
|
||||
}
|
||||
|
||||
std::optional<AABB> BasePressurePlateTile::getAABB(Level* level, int x, int y, int z) {
|
||||
std::optional<AABB> BasePressurePlateTile::getAABB(Level* level, int x, int y,
|
||||
int z) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
|
@ -113,9 +114,9 @@ void BasePressurePlateTile::checkPressed(Level* level, int x, int y, int z,
|
|||
}
|
||||
}
|
||||
|
||||
AABB* BasePressurePlateTile::getSensitiveAABB(int x, int y, int z) {
|
||||
AABB BasePressurePlateTile::getSensitiveAABB(int x, int y, int z) {
|
||||
float b = 2 / 16.0f;
|
||||
return AABB::newTemp(x + b, y, z + b, x + 1 - b, y + 0.25, z + 1 - b);
|
||||
return AABB(x + b, y, z + b, x + 1 - b, y + 0.25, z + 1 - b);
|
||||
}
|
||||
|
||||
void BasePressurePlateTile::onRemove(Level* level, int x, int y, int z, int id,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void checkPressed(Level* level, int x, int y, int z, int oldSignal);
|
||||
virtual AABB* getSensitiveAABB(int x, int y, int z);
|
||||
virtual AABB getSensitiveAABB(int x, int y, int z);
|
||||
|
||||
public:
|
||||
virtual void onRemove(Level* level, int x, int y, int z, int id, int data);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#include "../Headers/net.minecraft.world.level.h"
|
||||
#include "../Headers/net.minecraft.world.level.redstone.h"
|
||||
#include "PressurePlateTile.h"
|
||||
#include "Util/AABB.h"
|
||||
|
||||
PressurePlateTile::PressurePlateTile(int id, const std::wstring& tex,
|
||||
Material* material,
|
||||
|
|
@ -23,15 +24,13 @@ int PressurePlateTile::getSignalForData(int data) {
|
|||
|
||||
int PressurePlateTile::getSignalStrength(Level* level, int x, int y, int z) {
|
||||
std::vector<std::shared_ptr<Entity> >* entities = NULL;
|
||||
|
||||
AABB at_bb = getSensitiveAABB(x, y, z);
|
||||
if (sensitivity == everything)
|
||||
entities = level->getEntities(nullptr, getSensitiveAABB(x, y, z));
|
||||
entities = level->getEntities(nullptr, &at_bb);
|
||||
else if (sensitivity == mobs)
|
||||
entities = level->getEntitiesOfClass(typeid(LivingEntity),
|
||||
getSensitiveAABB(x, y, z));
|
||||
entities = level->getEntitiesOfClass(typeid(LivingEntity), &at_bb);
|
||||
else if (sensitivity == players)
|
||||
entities = level->getEntitiesOfClass(typeid(Player),
|
||||
getSensitiveAABB(x, y, z));
|
||||
entities = level->getEntitiesOfClass(typeid(Player), &at_bb);
|
||||
else
|
||||
__debugbreak(); // 4J-JEV: We're going to delete something at a random
|
||||
// location.
|
||||
|
|
@ -48,4 +47,4 @@ int PressurePlateTile::getSignalStrength(Level* level, int x, int y, int z) {
|
|||
|
||||
if (sensitivity != everything) delete entities;
|
||||
return Redstone::SIGNAL_NONE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include "../Headers/net.minecraft.world.item.h"
|
||||
#include "../Entities/Entity.h"
|
||||
#include "WeightedPressurePlateTile.h"
|
||||
#include "Util/AABB.h"
|
||||
|
||||
WeightedPressurePlateTile::WeightedPressurePlateTile(int id,
|
||||
const std::wstring& tex,
|
||||
|
|
@ -19,8 +20,9 @@ WeightedPressurePlateTile::WeightedPressurePlateTile(int id,
|
|||
|
||||
int WeightedPressurePlateTile::getSignalStrength(Level* level, int x, int y,
|
||||
int z) {
|
||||
AABB at_bb = getSensitiveAABB(x, y, z);
|
||||
int weightOfEntities =
|
||||
level->getEntitiesOfClass(typeid(Entity), getSensitiveAABB(x, y, z))
|
||||
level->getEntitiesOfClass(typeid(Entity), &at_bb)
|
||||
->size();
|
||||
int count = std::min(weightOfEntities, maxWeight);
|
||||
|
||||
|
|
@ -38,4 +40,4 @@ int WeightedPressurePlateTile::getDataForSignal(int signal) { return signal; }
|
|||
|
||||
int WeightedPressurePlateTile::getTickDelay(Level* level) {
|
||||
return SharedConstants::TICKS_PER_SECOND / 2;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue