From e48a05bb8fa6fb918ef1abe738a3e02dbdbf3ea4 Mon Sep 17 00:00:00 2001 From: orng Date: Sat, 28 Mar 2026 00:50:56 -0500 Subject: [PATCH] refactor: remove the last `AABB::newTemp` --- Minecraft.World/Blocks/BasePressurePlateTile.cpp | 7 ++++--- Minecraft.World/Blocks/BasePressurePlateTile.h | 2 +- Minecraft.World/Blocks/PressurePlateTile.cpp | 13 ++++++------- .../Blocks/WeightedPressurePlateTile.cpp | 6 ++++-- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Minecraft.World/Blocks/BasePressurePlateTile.cpp b/Minecraft.World/Blocks/BasePressurePlateTile.cpp index 434ce8e56..212fbb914 100644 --- a/Minecraft.World/Blocks/BasePressurePlateTile.cpp +++ b/Minecraft.World/Blocks/BasePressurePlateTile.cpp @@ -40,7 +40,8 @@ int BasePressurePlateTile::getTickDelay(Level* level) { return SharedConstants::TICKS_PER_SECOND; } -std::optional BasePressurePlateTile::getAABB(Level* level, int x, int y, int z) { +std::optional 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, diff --git a/Minecraft.World/Blocks/BasePressurePlateTile.h b/Minecraft.World/Blocks/BasePressurePlateTile.h index e42ff69eb..254f72e1d 100644 --- a/Minecraft.World/Blocks/BasePressurePlateTile.h +++ b/Minecraft.World/Blocks/BasePressurePlateTile.h @@ -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); diff --git a/Minecraft.World/Blocks/PressurePlateTile.cpp b/Minecraft.World/Blocks/PressurePlateTile.cpp index ef1223bb3..48a273f0d 100644 --- a/Minecraft.World/Blocks/PressurePlateTile.cpp +++ b/Minecraft.World/Blocks/PressurePlateTile.cpp @@ -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 >* 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; -} \ No newline at end of file +} diff --git a/Minecraft.World/Blocks/WeightedPressurePlateTile.cpp b/Minecraft.World/Blocks/WeightedPressurePlateTile.cpp index 55e1b5a15..e31a7c451 100644 --- a/Minecraft.World/Blocks/WeightedPressurePlateTile.cpp +++ b/Minecraft.World/Blocks/WeightedPressurePlateTile.cpp @@ -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; -} \ No newline at end of file +}