Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
Release 2.14.0 (LiteLDev#1299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrBox authored Jun 20, 2023
2 parents 6980617 + ac0b8a9 commit 2fb89ca
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 95 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ jobs:
shell: cmd

- name: Build SymDBHelper
run: cmake --build ${{github.workspace}}/build_clang --config ${{env.BUILD_TYPE}} --target SymDBHelper
run: |
cmake --build ${{github.workspace}}/build_clang --config ${{env.BUILD_TYPE}} --target SymDBHelper
cp .\build_clang\sdk\lib\SymDBHelper.lib .\build\sdk\lib\SymDBHelper.lib
- name: Compress resource packs for LiteLoaderBDS
run: |
Expand Down
2 changes: 1 addition & 1 deletion LLPreLoader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CMAKE_BUILD_TYPE Release)
add_definitions(-D"NDEBUG" -D"_WINDOWS" -D"_USRDLL" -D"_WINDLL" -D"_UNICODE" -D"UNICODE")

add_compile_options(
/permissive- /GS /GL /W0 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Zc:inline /fp:precise
/permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Zc:inline /fp:precise
/errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /FC /EHsc /nologo /diagnostics:column
)

Expand Down
2 changes: 0 additions & 2 deletions LLPreLoader/include/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ inline void loadConfig() {
if (std::filesystem::exists("plugins/LiteLoader/LiteLoader.json")) {
try {
LoadConfigFromJson("plugins/LiteLoader/LiteLoader.json");
} catch (std::exception& e) {
ColorLog = true;
} catch (...) {
ColorLog = true;
}
Expand Down
2 changes: 1 addition & 1 deletion LLPreLoader/src/SymDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ extern _declspec(dllexport) std::vector<string> dlsym_reverse(int addr) {
if (!rvaMap)
InitReverseLookup();
// TODO: Fix Narrowing Conversion
addr = addr - imageBaseAddr;
addr = (int)(addr - imageBaseAddr);
auto const iter = rvaMap->equal_range(addr);
std::vector<string> ret;
for (auto it = iter.first; it != iter.second; ++it) {
Expand Down
6 changes: 0 additions & 6 deletions LiteLoader/include/llapi/EventAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,6 @@ class WitherBossDestroyEvent : public EventTemplate<WitherBossDestroyEvent> {
AABB mDestroyRange{{}, {}};
};

class EnderDragonDestroyEvent : public EventTemplate<EnderDragonDestroyEvent> {
public:
EnderDragon* mEnderDragon = nullptr;
BlockLegacy* mBlockLegacy = nullptr;
};

class EntityRideEvent : public EventTemplate<EntityRideEvent> {
public:
Actor* mRider = nullptr;
Expand Down
41 changes: 20 additions & 21 deletions LiteLoader/include/llapi/mc/Biome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,26 @@
// Include Headers or Declare Types Here

enum class VanillaBiomeTypes : int{
Beach = 0x0,
Desert = 0x1,
ExtremeHills = 0x2,
FlatWorld = 0x3,
Forest = 0x4,
Hell = 0x5,
//TODO: confirm IcePlainsSpikes
IcePlainsSpikes = 0x6, // The Ice Plains Spikes Biome is a rare variant of the ice plains biome, containing unique ice structures. It is quite cold, with most water frozen as ice.
Jungle = 0x7,
Mesa = 0x8, // Mesa is a very rare biome which is made up from red sand, cacti, dead bushes and plateaus. The red sand is only one layer thick. Red sand is found in the Mesa itself, not its variants. Water patches are found but are not a variant.
MushroomIsland = 0x9,
Ocean = 0xA,
Plain = 0xB,
River = 0xC,
Savanna = 0xD, // A savanna is a dry biome with scattered acacia trees. It typically generates bordering a desert, forest or plains biome and has three variations total.
RockyBeach = 0xE,
Swamp = 0xF, // The Minecraft Swamp biome is a waterlogged area, consisting of many small islands separated by vast canals of water. In the Bedrock Edition, this water is a murky brown color, and this version also allows for Huge Mushrooms to appear on the islands.
TaigaForest = 0x10,
TheEnd = 0x11,
Custom = 0x12, // Dirve by bahavior pack?
};
Beach = 0x0,
Desert = 0x1,
ExtremeHills = 0x2,
Flat = 0x3,
Forest = 0x4,
Hell = 0x5,
Ice = 0x6,
Jungle = 0x7,
Mesa = 0x8,
MushroomIsland = 0x9,
Ocean = 0xA,
Plain = 0xB,
River = 0xC,
Savanna = 0xD,
StoneBeach = 0xE,
Swamp = 0xF,
Taiga = 0x10,
TheEnd = 0x11,
DataDriven = 0x12,
};

#undef BEFORE_EXTRA

Expand Down
1 change: 1 addition & 0 deletions LiteLoader/include/llapi/mc/BlockActorDataPacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class BlockActorDataPacket : public Packet {

#define AFTER_EXTRA
// Add Member There
char filler[40];

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKACTORDATAPACKET
Expand Down
3 changes: 3 additions & 0 deletions LiteLoader/include/llapi/mc/BlockEventDispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#define BEFORE_EXTRA
// Include Headers or Declare Types Here
#include "llapi/mc/ListenerInfo.hpp"

#undef BEFORE_EXTRA

Expand All @@ -19,6 +20,8 @@ class BlockEventDispatcher {

#define AFTER_EXTRA
// Add Member There
public:
std::unordered_map<int, std::unique_ptr<ListenerInfo>> listeners;

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKEVENTDISPATCHER
Expand Down
5 changes: 5 additions & 0 deletions LiteLoader/include/llapi/mc/BlockEventDispatcherToken.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#define BEFORE_EXTRA
// Include Headers or Declare Types Here
typedef int ListenerHandle;
#include "llapi/mc/BlockEventDispatcher.hpp"

#undef BEFORE_EXTRA

Expand All @@ -19,6 +21,9 @@ class BlockEventDispatcherToken {

#define AFTER_EXTRA
// Add Member There
public:
ListenerHandle mHandle;
BlockEventDispatcher *mDispatcher;

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKEVENTDISPATCHERTOKEN
Expand Down
1 change: 1 addition & 0 deletions LiteLoader/include/llapi/mc/UpdateBlockPacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class UpdateBlockPacket : public Packet {

#define AFTER_EXTRA
// Add Member There
char filler[24];

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_UPDATEBLOCKPACKET
Expand Down
2 changes: 1 addition & 1 deletion LiteLoader/include/llapi/mc/VectorBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class VectorBase {
unrollWithArgs<Component...>([&](size_t iter, auto shit) constexpr {
using axis_type = decltype(shit);
res += std::to_string(static_cast<T const*>(this)->get<axis_type>(iter)) +
((iter < sizeof...(Component)) ? ", " : ")");
((iter < sizeof...(Component) - 1) ? ", " : ")");
});
return res;
}
Expand Down
14 changes: 13 additions & 1 deletion LiteLoader/src/liteloader/BuiltinBugFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ TClasslessInstanceHook(void, "?sendEvent@ActorEventCoordinator@@QEAAXAEBV?$Event
#include "llapi/mc/ExtendedStreamReadResult.hpp"

TInstanceHook(ExtendedStreamReadResult,
"?read@PlayerListPacket@@UEAA?AUExtendedStreamReadResult@@AEAVReadOnlyBinaryStream@@@Z",
"?_read@PlayerListPacket@@EEAA?AUExtendedStreamReadResult@@AEAVReadOnlyBinaryStream@@@Z",
PlayerListPacket, ReadOnlyBinaryStream) {
return ExtendedStreamReadResult{StreamReadResult::Valid, ""};
}
Expand All @@ -538,3 +538,15 @@ TInstanceHook(void, "?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@A
}
pl->sendInventory(1);
}


// fix BlockEventDispatcherToken unregister crash error when stop server
#include <llapi/mc/BlockEventDispatcherToken.hpp>
TInstanceHook(void,"?unregister@BlockEventDispatcherToken@@QEAAXXZ",BlockEventDispatcherToken){
if (this->mHandle != -1 && this->mDispatcher->listeners.size() <= 1 && ll::globalRuntimeConfig.serverStatus == ll::LLServerStatus::Stopping)
{
logger.debug("BlockEventDispatcherToken::unregister with no listeners");
return;
}
original(this);
}
90 changes: 44 additions & 46 deletions LiteLoader/src/llapi/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ DECLARE_EVENT_DATA(MobDieEvent);
DECLARE_EVENT_DATA(EntityExplodeEvent);
DECLARE_EVENT_DATA(ProjectileHitEntityEvent);
DECLARE_EVENT_DATA(WitherBossDestroyEvent);
DECLARE_EVENT_DATA(EnderDragonDestroyEvent);
DECLARE_EVENT_DATA(EntityRideEvent);
DECLARE_EVENT_DATA(EntityStepOnPressurePlateEvent);
DECLARE_EVENT_DATA(NpcCmdEvent);
Expand Down Expand Up @@ -1335,43 +1334,59 @@ TInstanceHook(void*, "?die@ServerPlayer@@UEAAXAEBVActorDamageSource@@@Z", Server
#include "llapi/mc/SurvivalMode.hpp"

/////////////////// PlayerDestroy ///////////////////

TInstanceHook(bool, "?destroyBlock@SurvivalMode@@UEAA_NAEBVBlockPos@@E@Z", GameMode, BlockPos blockPos,
unsigned __int8 uChar) {
IF_LISTENED(PlayerDestroyBlockEvent) {
auto player = getPlayer();
if (player && player->isPlayer()) {
if (player->getPlayerGameType() != GameType::Creative) {
PlayerDestroyBlockEvent ev{};
ev.mPlayer = player;
auto blockInstance = Level::getBlockInstance(blockPos, player->getDimensionId());
ev.mBlockInstance = blockInstance;
if (!ev.call()) {
return false;
}
}
}
}
IF_LISTENED_END(PlayerDestroyBlockEvent)
return original(this, blockPos, uChar);
}

TInstanceHook(bool, "?destroyBlock@GameMode@@UEAA_NAEBVBlockPos@@E@Z", GameMode, BlockPos a3, unsigned __int8 a4) {
auto player = getPlayer();
TInstanceHook(bool,"?playerWillDestroy@BlockLegacy@@UEBA_NAEAVPlayer@@AEBVBlockPos@@AEBVBlock@@@Z", BlockLegacy ,Player *player, const BlockPos *pos, const Block *block){
if (player != nullptr && player->isPlayer()) {
IF_LISTENED(PlayerDestroyBlockEvent) {
PlayerDestroyBlockEvent ev{};
ev.mPlayer = player;
auto bl = Level::getBlockInstance(a3, player->getDimensionId());
ev.mBlockInstance = bl;
ev.mBlockInstance = Level::getBlockInstance(*pos, player->getDimensionId());
if (!ev.call()) {
return false;
}
}
IF_LISTENED_END(PlayerDestroyBlockEvent)
}
return original(this, a3, a4);
}
}
return original(this, player, pos, block);
}

// TInstanceHook(bool, "?destroyBlock@SurvivalMode@@UEAA_NAEBVBlockPos@@E@Z", GameMode, BlockPos blockPos,
// unsigned __int8 uChar) {
// IF_LISTENED(PlayerDestroyBlockEvent) {
// auto player = getPlayer();
// if (player && player->isPlayer()) {
// if (player->getPlayerGameType() != GameType::Creative) {
// PlayerDestroyBlockEvent ev{};
// ev.mPlayer = player;
// auto blockInstance = Level::getBlockInstance(blockPos, player->getDimensionId());
// ev.mBlockInstance = blockInstance;
// if (!ev.call()) {
// return false;
// }
// }
// }
// }
// IF_LISTENED_END(PlayerDestroyBlockEvent)
// return original(this, blockPos, uChar);
// }

// TInstanceHook(bool, "?_creativeDestroyBlock@GameMode@@AEAA_NAEBVBlockPos@@E@Z", GameMode, BlockPos a3, unsigned __int8 a4) {
// auto player = getPlayer();
// if (player != nullptr && player->isPlayer()) {
// IF_LISTENED(PlayerDestroyBlockEvent) {
// PlayerDestroyBlockEvent ev{};
// ev.mPlayer = player;
// auto bl = Level::getBlockInstance(a3, player->getDimensionId());
// ev.mBlockInstance = bl;
// if (!ev.call()) {
// return false;
// }
// }
// IF_LISTENED_END(PlayerDestroyBlockEvent)
// }
// return original(this, a3, a4);
// }



/////////////////// PlayerUseItemOn ///////////////////
TInstanceHook(InteractionResult,
Expand Down Expand Up @@ -1732,23 +1747,6 @@ TInstanceHook(void, "?_destroyBlocks@WitherBoss@@AEAAXAEAVLevel@@AEBVAABB@@AEAVB
original(this, a2, aabb, a4, a5, a6);
}

////////////// EnderDragonDestroy //////////////
#include <llapi/mc/EnderDragon.hpp>
#include <llapi/mc/BlockLegacy.hpp>

TInstanceHook(bool, "?_isDragonImmuneBlock@EnderDragon@@CA_NAEBVBlockLegacy@@@Z", EnderDragon, BlockLegacy* bl) {
IF_LISTENED(EnderDragonDestroyEvent) {
EnderDragonDestroyEvent ev{};
ev.mEnderDragon = (EnderDragon*)this;
ev.mBlockLegacy = bl;
if (!ev.call()) {
return true;
}
}
IF_LISTENED_END(EnderDragonDestroyEvent)
return original(this, bl);
}

////////////// EntityRide //////////////
TInstanceHook(bool, "?canAddPassenger@Actor@@UEBA_NAEAV1@@Z", Actor, Actor* a2) {
auto rtn = original(this, a2);
Expand Down
8 changes: 6 additions & 2 deletions LiteLoader/src/llapi/command/DynamicCommandAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,12 @@ std::unique_ptr<class DynamicCommandInstance> DynamicCommand::createCommand(std:
for (auto& param : params) {
command->newParameter(std::move(param));
}
for (auto& overload : overloads) {
command->addOverload(std::move(overload));
if (overloads.size() > 0) {
for (auto& overload : overloads) {
command->addOverload(std::move(overload));
}
}else{
command->addOverload();
}
command->setCallback(std::move(callback));
return std::move(command);
Expand Down
12 changes: 9 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Release 2.14.0

![BDS 1.20.0.01](https://img.shields.io/badge/BDS-1.20.0.01-blue?style=for-the-badge) ![Protocol 582](https://img.shields.io/badge/Protocol-582-orange?style=for-the-badge)
![BDS 1.20.0.01](https://img.shields.io/badge/BDS-1.20.0.01-blue?style=for-the-badge) ![Protocol 589](https://img.shields.io/badge/Protocol-589-orange?style=for-the-badge)

## Added

- Support 2.14.0 (by @dreamguxiang @OEOTYAN)

[//]: # (## Changed)
## Changed

- Remove EnderDragonDestroy event

## Fixed

- Fix item disappear caused by players throwing items at unloaded chunks (by @timiya)
- Fix item disappear caused by players throwing items at unloaded chunks (by @timiya233)
- Fix empty overloads error (by @OEOTYAN)
- Fix destroy event (by @dofes)
- Fix VectorBase::toString incorrect process of right parenthesis (by @Redbeanw44602)
- Fix stop server crash caused by BDS (by @dofes)
10 changes: 0 additions & 10 deletions ScriptEngine/src/api/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ enum class EVENT_TYPES : int {
onEntityExplode,
onProjectileHitEntity,
onWitherBossDestroy,
onEnderDragonDestroy,
onRide,
onStepOnPressurePlate,
onSpawnProjectile,
Expand Down Expand Up @@ -811,15 +810,6 @@ void EnableEventListener(int eventId) {
});
break;

case EVENT_TYPES::onEnderDragonDestroy:
Event::EnderDragonDestroyEvent::subscribe([](const EnderDragonDestroyEvent& ev) {
IF_LISTENED(EVENT_TYPES::onEnderDragonDestroy) {
CallEvent(EVENT_TYPES::onEnderDragonDestroy, EntityClass::newEntity((Actor*)ev.mEnderDragon), BlockClass::newBlock(*(BlockInstance*)(ev.mBlockLegacy)));
}
IF_LISTENED_END(EVENT_TYPES::onEnderDragonDestroy);
});
break;

case EVENT_TYPES::onMobHurt:
Event::MobHurtEvent::subscribe([](const MobHurtEvent& ev) {
IF_LISTENED(EVENT_TYPES::onMobHurt) {
Expand Down

0 comments on commit 2fb89ca

Please sign in to comment.