From fa1f97d67e9d30e1cb5fa39670145233c28ca47a Mon Sep 17 00:00:00 2001 From: ShrBox Date: Wed, 27 Mar 2024 22:53:38 +0800 Subject: [PATCH] fix: fix IConstBlockSource #1499 --- src/ll/test/EventTest.cpp | 8 ++++++++ src/mc/world/level/IConstBlockSource.h | 22 ++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/ll/test/EventTest.cpp b/src/ll/test/EventTest.cpp index 3300a69c1f..e6489f76f6 100644 --- a/src/ll/test/EventTest.cpp +++ b/src/ll/test/EventTest.cpp @@ -27,12 +27,15 @@ #include "ll/api/event/player/PlayerSwingEvent.h" #include "ll/api/event/player/PlayerUseItemEvent.h" #include "ll/api/event/player/PlayerUseItemOnEvent.h" +#include "ll/api/event/world/BlockChangedEvent.h" #include "ll/api/event/world/SpawnMobEvent.h" #include "ll/api/io/FileUtils.h" #include "mc/codebuilder/MCRESULT.h" #include "mc/nbt/CompoundTag.h" #include "mc/world/actor/ActorDamageSource.h" #include "mc/world/item/registry/ItemStack.h" +#include "mc/world/level/dimension/Dimension.h" + #include "ll/api/base/FixedString.h" @@ -229,4 +232,9 @@ LL_AUTO_TYPE_INSTANCE_HOOK( bus.addListener(dl, getEventId); bus.addListener(dl, getEventId); // bus.addListener(dl, getEventId); + + bus.emplaceListener([](BlockChangedEvent& ev) { + ll::logger + .debug("Block Changed Pos: {} Dimension: {}", ev.pos().toString(), ev.blockSource().getDimensionId().id); + }); } diff --git a/src/mc/world/level/IConstBlockSource.h b/src/mc/world/level/IConstBlockSource.h index 5d5f1a65b2..0b8ef40fc6 100644 --- a/src/mc/world/level/IConstBlockSource.h +++ b/src/mc/world/level/IConstBlockSource.h @@ -61,35 +61,41 @@ class IConstBlockSource { // vIndex: 12, symbol: ?getMaterial@BlockSource@@UEBAAEBVMaterial@@HHH@Z virtual class Material const& getMaterial(int, int, int) const = 0; - // vIndex: 13, symbol: ?hasChunksAt@BlockSource@@UEBA_NAEBUBounds@@_N@Z + // vIndex: 13, symbol: ?hasBorderBlock@BlockSource@@UEBA_NVBlockPos@@@Z + virtual bool hasBorderBlock(class BlockPos pos) const; + + // vIndex: 14, symbol: ?getChunkAt@BlockSource@@UEBAPEAVLevelChunk@@AEBVBlockPos@@@Z + virtual class LevelChunk* getChunkAt(class BlockPos const& pos) const; + + // vIndex: 15, symbol: ?hasChunksAt@BlockSource@@UEBA_NAEBUBounds@@_N@Z virtual bool hasChunksAt(struct Bounds const&, bool) const = 0; - // vIndex: 14, symbol: ?hasChunksAt@BlockSource@@UEBA_NAEBVBlockPos@@H_N@Z + // vIndex: 16, symbol: ?hasChunksAt@BlockSource@@UEBA_NAEBVBlockPos@@H_N@Z virtual bool hasChunksAt(class BlockPos const&, int, bool) const = 0; - // vIndex: 15, symbol: ?hasChunksAt@BlockSource@@UEBA_NAEBVAABB@@_N@Z + // vIndex: 17, symbol: ?hasChunksAt@BlockSource@@UEBA_NAEBVAABB@@_N@Z virtual bool hasChunksAt(class AABB const&, bool) const = 0; - // vIndex: 16, symbol: ?getDimensionId@BlockSource@@UEBA?AV?$AutomaticID@VDimension@@H@@XZ + // vIndex: 18, symbol: ?getDimensionId@BlockSource@@UEBA?AV?$AutomaticID@VDimension@@H@@XZ virtual DimensionType getDimensionId() const = 0; - // vIndex: 17, symbol: + // vIndex: 19, symbol: // ?fetchAABBs@BlockSource@@UEBAXAEAV?$vector@VAABB@@V?$allocator@VAABB@@@std@@@std@@AEBVAABB@@_N@Z virtual void fetchAABBs(std::vector&, class AABB const&, bool) const = 0; - // vIndex: 18, symbol: + // vIndex: 20, symbol: // ?fetchCollisionShapes@BlockSource@@UEBAXAEAV?$vector@VAABB@@V?$allocator@VAABB@@@std@@@std@@AEBVAABB@@_NV?$optional_ref@$$CBVGetCollisionShapeInterface@@@@@Z virtual void fetchCollisionShapes(std::vector&, class AABB const&, bool, class optional_ref) const = 0; - // vIndex: 19, symbol: + // vIndex: 21, symbol: // ?getTallestCollisionShape@BlockSource@@UEBA?AVAABB@@AEBV2@PEAM_NV?$optional_ref@$$CBVGetCollisionShapeInterface@@@@@Z virtual class AABB getTallestCollisionShape(class AABB const&, float*, bool, class optional_ref) const = 0; - // vIndex: 20, symbol: ?getBrightness@BlockSource@@UEBAMAEBVBlockPos@@@Z + // vIndex: 22, symbol: ?getBrightness@BlockSource@@UEBAMAEBVBlockPos@@@Z virtual float getBrightness(class BlockPos const&) const = 0; // symbol: ?checkMaterial@IConstBlockSource@@QEBA_NAEBVAABB@@W4MaterialType@@@Z