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

Commit

Permalink
From LiteLoader e779876
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Apr 22, 2023
1 parent a49ae23 commit 2821120
Show file tree
Hide file tree
Showing 53 changed files with 1,347 additions and 1,006 deletions.
12 changes: 12 additions & 0 deletions include/llapi/EventAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ copies or substantial portions of the Software.
#include "llapi/mc/AABB.hpp"
#include "llapi/mc/EnderDragon.hpp"
#include "llapi/mc/BlockLegacy.hpp"
#include "llapi/mc/ItemActor.hpp"
#include "llapi/mc/FishingHook.hpp"

class Actor;
class ServerPlayer;
Expand Down Expand Up @@ -229,6 +231,16 @@ class PlayerUseItemOnEvent : public EventTemplate<PlayerUseItemOnEvent> {
Vec3 mClickPos;
};

class PlayerPullFishingHookEvent : public EventTemplate<PlayerPullFishingHookEvent> {
public:

Player* mPlayer = nullptr;
FishingHook* mFishingHook = nullptr;
Actor* mActor = nullptr;
ItemActor* mItemActor = nullptr;
ItemStack* mItemStack = nullptr;
};

/**
* @brief An event that fires as players use bucket.
*
Expand Down
1 change: 1 addition & 0 deletions include/llapi/mc/Abilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Abilities {

#define AFTER_EXTRA
// Add Member There
std::array<Ability,19> mAbilities;

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ABILITIES
Expand Down
51 changes: 34 additions & 17 deletions include/llapi/mc/BaseCircuitComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@

#define BEFORE_EXTRA
// Include Headers or Declare Types Here

#include "BlockPos.hpp"
// clang-format off
enum class CircuitComponentType : uint64_t {
UNDEFINED = 0LL,
CAPACITOR = 1129530177LL,
CONSUMER = 1129530179LL,
POWERED_BLOCK = 1129533506LL,
PRODUCER = 1129533507LL,
BASE = 1129534275LL,
TRANSPORTER = 1129534546LL,
COMPARATOR = 1296253778LL,
PULSE_CAPACITOR = 1296257091LL,
PISTON = 1296257097LL,
RAIL_TRANSPORTER = 1296257106LL,
REPEATER = 1296257618LL,
REDSTONE_TORCH = 1296258115LL,
enum class CircuitComponentType : int64_t {
Unknown = 0x0,
Undefined = 0x1,
Mask = 0xFFFF0000,
BaseCircuitComponent = 0x80000000,
BaseRailTransporter = 0x10000,
ConsumerComponent = 0x20000,
PistonConsumer = 0x20001,
PoweredBlockComponent = 0x40000,
ProducerComponent = 0x80000,
TransporterComponent = 0x100000,
CapacitorComponent = 0x200000,
ComparatorCapacitor = 0x200001,
PulseCapacitor = 0x200002,
RedstoneTorchCapacitor = 0x200003,
RepeaterCapacitor = 0x200004,
};
// clang-format on

Expand All @@ -37,8 +39,23 @@ enum class CircuitComponentType : uint64_t {
class BaseCircuitComponent {

#define AFTER_EXTRA
// Add Member There

// Add Member There
public:
CircuitComponentList mSources;
bool mIgnoreFirstUpdate;
bool mIsFirstTime;
bool mNeedsUpdate;
BlockPos mPos;
BlockPos mChunkPosition;
bool mShouldEvaluate;
int mStrength;
FaceID mDirection;
bool mAllowPowerUp;
bool mAllowPowerDown;
bool mRemoved;
bool mConsumePowerAnyDirection;
CircuitComponentType mCircuitComponentType;
#define ENABLE_VIRTUAL_FAKESYMBOL_BASECIRCUITCOMPONENT
#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BASECIRCUITCOMPONENT
public:
Expand Down
9 changes: 9 additions & 0 deletions include/llapi/mc/BaseRailTransporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ class BaseRailTransporter : public BaseCircuitComponent {
#define AFTER_EXTRA
// Add Member There

public:
enum class RailType {
Activator = 0x0,
Power = 0x1,
} mRailType;

const CircuitComponentType mCircuitComponentType = CircuitComponentType::BaseRailTransporter;

#define DISABLE_CONSTRUCTOR_PREVENTION_BASERAILTRANSPORTER
#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BASERAILTRANSPORTER
public:
Expand Down
24 changes: 23 additions & 1 deletion include/llapi/mc/Biome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@

#define BEFORE_EXTRA
// Include Headers or Declare Types Here
enum class VanillaBiomeTypes;

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?
};

#undef BEFORE_EXTRA

Expand Down
20 changes: 13 additions & 7 deletions include/llapi/mc/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,42 @@ class Block {
#define AFTER_EXTRA
// Add new members to class
public:
LIAPI static Block* create(const string& str, unsigned short tileData);
LIAPI static Block* create(const std::string& str, unsigned short tileData);
LIAPI static Block* create(CompoundTag* nbt);

LIAPI string getTypeName() const;
[[deprecated("Use MCAPI getName() instead.")]]
LIAPI std::string getTypeName() const;
LIAPI int getId() const;
inline unsigned short getTileData(){
return static_cast<unsigned short>(getVariant());
}

/**
* @brief Obtain a copy of the NBT associated with this block. To obtain a reference to the original instance, use block->getSerializationId().
*/
LIAPI std::unique_ptr<CompoundTag> getNbt();
LIAPI bool setNbt(CompoundTag* nbt);

inline unsigned short getData() const {
return dAccess<unsigned short, 8>(this);
}

[[deprecated("Use MCAPI getLegacyBlock() instead.")]]
inline class BlockLegacy const* getLegacyBlockPtr() const {
return &dAccess<BlockLegacy, 16>(this);
return reinterpret_cast<class BlockLegacy const*>(&this->getLegacyBlock());
}

inline bool operator==(class Block const& block) const {
class BlockLegacy const* p1 = getLegacyBlockPtr();
class BlockLegacy const* p2 = block.getLegacyBlockPtr();
class BlockLegacy const* p1 = &this->getLegacyBlock();
class BlockLegacy const* p2 = &block.getLegacyBlock();
if (!p1 || !p2)
return false;
return p1 == p2 && getData() == block.getData();
}

inline bool operator!=(class Block const& block) const {
class BlockLegacy const* p1 = getLegacyBlockPtr();
class BlockLegacy const* p2 = block.getLegacyBlockPtr();
class BlockLegacy const* p1 = &this->getLegacyBlock();
class BlockLegacy const* p2 = &block.getLegacyBlock();
if (!p1 || !p2)
return false;
return p1 != p2 || getData() != block.getData();
Expand Down
37 changes: 6 additions & 31 deletions include/llapi/mc/BlockPos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Vec3;

class BlockPos {
class BlockPos : public VectorBase<BlockPos, int, int, int> {
public:
int x, y, z;
inline BlockPos() : BlockPos(0, 0, 0){};
Expand Down Expand Up @@ -33,7 +33,8 @@ class BlockPos {

MCAPI static void bindType();

[[nodiscard]] constexpr int& operator[](size_t index) {
template <typename T>
[[nodiscard]] constexpr T& get(size_t index) {
switch (index) {
case 1:
return y;
Expand All @@ -44,7 +45,8 @@ class BlockPos {
}
}

[[nodiscard]] constexpr int operator[](size_t index) const {
template <typename T>
[[nodiscard]] constexpr T get(size_t index) const {
switch (index) {
case 1:
return y;
Expand All @@ -65,41 +67,14 @@ class BlockPos {
[[nodiscard]] LIAPI Vec3 bottomCenter() const;
[[nodiscard]] LIAPI Vec3 center() const;
[[nodiscard]] LIAPI bool containedWithin(class BoundingBox const&) const;

FAKE_CRTP(BlockPos, int, 3);
};

namespace std {

template <>
struct hash<BlockPos> {
std::size_t operator()(BlockPos const& pos) const noexcept {
//??$hash3@HHH@Math@mce@@SA_KAEBH00@Z
unsigned __int64 t1; // r8
unsigned __int64 t2; // r8

t1 = *((unsigned __int8*)&pos.x + 3) ^
(0x100000001B3i64 *
(*((unsigned __int8*)&pos.x + 2) ^
(0x100000001B3i64 * (*((unsigned __int8*)&pos.x + 1) ^
(0x100000001B3i64 * (*(unsigned __int8*)&pos.x ^ 0xCBF29CE484222325ui64))))));
t2 =
(((0x100000001B3i64 * t1 + 2654435769u) >> 2) + 2654435769u + ((0x100000001B3i64 * t1 + 2654435769u) << 6) +
0x100000001B3i64 * (*((unsigned __int8*)&pos.y + 3) ^
(0x100000001B3i64 *
(*((unsigned __int8*)&pos.y + 2) ^
(0x100000001B3i64 *
(*((unsigned __int8*)&pos.y + 1) ^
(0x100000001B3i64 * (*(unsigned __int8*)&pos.y ^ 0xCBF29CE484222325ui64)))))))) ^
(0x100000001B3i64 * t1 + 2654435769u);
return t2 ^ ((t2 << 6) +
0x100000001B3i64 *
(*((unsigned __int8*)&pos.z + 3) ^
(0x100000001B3i64 * (*((unsigned __int8*)&pos.z + 2) ^
(0x100000001B3i64 * (*((unsigned __int8*)&pos.z + 1) ^
(0x100000001B3i64 * (*(unsigned __int8*)&pos.z ^
0xCBF29CE484222325ui64))))))) +
(t2 >> 2) + 2654435769u);
return pos.hash();
}
};

Expand Down
4 changes: 4 additions & 0 deletions include/llapi/mc/CapacitorComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ class CapacitorComponent : public ProducerComponent {

#define AFTER_EXTRA

public:
const CircuitComponentType mCircuitComponentType = CircuitComponentType::CapacitorComponent;

#define DISABLE_CONSTRUCTOR_PREVENTION_CAPACITORCOMPONENT
#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_CAPACITORCOMPONENT
public:
Expand Down
49 changes: 37 additions & 12 deletions include/llapi/mc/ChunkBlockPos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
*/
#pragma once
#define AUTO_GENERATED

#include "llapi/Global.h"

#define BEFORE_EXTRA
Expand All @@ -23,8 +23,7 @@ class ChunkLocalHeight {
* @brief MC class ChunkBlockPos.
*
*/
class ChunkBlockPos {

class ChunkBlockPos : public VectorBase<ChunkBlockPos, char, short, char> {
#define AFTER_EXTRA
// Add Member There
#define DISABLE_CONSTRUCTOR_PREVENTION_CHUNKBLOCKPOS
Expand All @@ -40,13 +39,29 @@ class ChunkBlockPos {
return (y.mVal & 0xF) + 16 * (z + 16 * x);
}

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_CHUNKBLOCKPOS
public:
class ChunkBlockPos& operator=(class ChunkBlockPos const &) = delete;
ChunkBlockPos(class ChunkBlockPos const &) = delete;
ChunkBlockPos() = delete;
#endif
template <typename T>
[[nodiscard]] constexpr T& get(size_t index) {
switch (index) {
case 1:
return (T&)y.mVal;
case 2:
return (T&)z;
default:
return (T&)x;
}
}

template <typename T>
[[nodiscard]] constexpr T get(size_t index) const {
switch (index) {
case 1:
return (T)y.mVal;
case 2:
return (T)z;
default:
return (T)x;
}
}

public:
/**
Expand All @@ -56,11 +71,11 @@ class ChunkBlockPos {
/**
* @symbol ??0ChunkBlockPos\@\@QEAA\@AEBVBlockPos\@\@F\@Z
*/
MCAPI ChunkBlockPos(class BlockPos const &, short);
MCAPI ChunkBlockPos(class BlockPos const&, short);
/**
* @symbol ?toPos\@ChunkBlockPos\@\@QEBA?AVPos\@\@XZ
*/
MCAPI class Pos toPos() const;
// MCAPI class Pos toPos() const;
/**
* @symbol ?from2D\@ChunkBlockPos\@\@SA?AV1\@EE\@Z
*/
Expand All @@ -69,5 +84,15 @@ class ChunkBlockPos {
* @symbol ?fromLegacyIndex\@ChunkBlockPos\@\@SA?AV1\@G\@Z
*/
MCAPI static class ChunkBlockPos fromLegacyIndex(unsigned short);
};

namespace std {

template <>
struct hash<ChunkBlockPos> {
std::size_t operator()(ChunkBlockPos const& pos) const noexcept {
return pos.hash();
}
};

} // namespace std
Loading

0 comments on commit 2821120

Please sign in to comment.