Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add templates and update StaticVanillaBlocks #1116

Merged
merged 15 commits into from
Mar 9, 2023
1 change: 1 addition & 0 deletions LiteLoader/include/llapi/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#pragma unmanaged
#include <entt/entt.hpp>
#pragma managed

#include <gsl/gsl>
#include <FMT/chrono.h>
#include <FMT/color.h>
Expand Down
2 changes: 2 additions & 0 deletions LiteLoader/include/llapi/mc/Actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
#include "MobEffectInstance.hpp"
#include "Tick.hpp"
#include "ActorDamageSource.hpp"
#include "EntityRegistryRefTraits.hpp"
#include "VehicleUtils.hpp"
#include "Vec3.hpp"
#include "Ref.hpp"
class Actor;
class Player;
class NetworkIdentifier;
Expand Down
5 changes: 3 additions & 2 deletions LiteLoader/include/llapi/mc/BlockTypeRegistry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ class BlockTypeRegistry {

#define AFTER_EXTRA
// Add Member There
public:
struct LookupByNameImplReturnType;
class InhibitModificationsLock;
struct BlockComplexAliasBlockState;
class BlockComplexAliasContent;

inline static std::map<class HashedString, class SharedPtr<class BlockLegacy>, struct std::less<class HashedString>, class std::allocator<struct std::pair<class HashedString const, class SharedPtr<class BlockLegacy>>>>& getBlockLookupMap(){return mBlockLookupMap;}
#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_BLOCKTYPEREGISTRY
public:
Expand Down Expand Up @@ -151,4 +152,4 @@ class BlockTypeRegistry {
*/
MCAPI static class std::shared_ptr<class BlockTypeRegistryRWLock> mRWLock;

};
};
1 change: 1 addition & 0 deletions LiteLoader/include/llapi/mc/CommandRegistry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "typeid_t.hpp"
// Include Headers or Declare Types Here
class CommandParameterData;
#include "RelativeFloat.hpp"
#include "CommandFlag.hpp"
#include "CommandPosition.hpp"
#include "CommandPositionFloat.hpp"
Expand Down
4 changes: 2 additions & 2 deletions LiteLoader/include/llapi/mc/Container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Container {
LIAPI int getSize();

// static??
LIAPI bool hasContainer(Vec3& pos, int dim);
LIAPI bool hasContainer(class Vec3& pos, int dim);
// static??
LIAPI Container* getContainerAt(Vec3& pos, int dim);
LIAPI Container* getContainerAt(class Vec3& pos, int dim);
#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_CONTAINER
public:
Expand Down
10 changes: 4 additions & 6 deletions LiteLoader/include/llapi/mc/EntityContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
*
*/
#pragma once
#define AUTO_GENERATED

#include "llapi/Global.h"

#define BEFORE_EXTRA
// Include Headers or Declare Types Here
template <>
class WeakRefT<struct EntityRefTraits> {
char filler[24];
};
#include "EntityContextBase.hpp"

#undef BEFORE_EXTRA

/**
* @brief MC class EntityContext.
*
*/
class EntityContext {
class EntityContext : public EntityContextBase {

#define AFTER_EXTRA
// Add Member There
Expand Down
2 changes: 2 additions & 0 deletions LiteLoader/include/llapi/mc/EntityContextBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class EntityContextBase {

#define AFTER_EXTRA
// Add Member There
class EntityRegistryBase* mRegistry;
const class EntityId mEntity;

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENTITYCONTEXTBASE
Expand Down
20 changes: 20 additions & 0 deletions LiteLoader/include/llapi/mc/EntityRefTraits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

#pragma once
#include "llapi/Global.h"

#include "EntityContext.hpp"
#include "WeakStorageEntity.hpp"
#include "StackResultStorageEntity.hpp"
#include "OwnerStorageEntity.hpp"
#include "EntityRegistry.hpp"

struct EntityRefTraits {
public:
using StackRef = EntityContext;
using WeakStorage = WeakStorageEntity;
using OwnerStorage = OwnerStorageEntity;
using OwnerStackRef = StackRef;
using StackResultStorage = StackResultStorageEntity;
};

struct EntityConstRefTraits : public EntityRefTraits {};
28 changes: 14 additions & 14 deletions LiteLoader/include/llapi/mc/EntityRegistry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
*
*/
#pragma once
#define AUTO_GENERATED

#include "llapi/Global.h"

#define BEFORE_EXTRA

#include "EntityRegistryBase.hpp"

#undef BEFORE_EXTRA

/**
* @brief MC class EntityRegistry.
*
*/
class EntityRegistry {

class EntityRegistry : public EntityRegistryBase, public std::enable_shared_from_this<EntityRegistry> {
#define AFTER_EXTRA

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENTITYREGISTRY
public:
class EntityRegistry& operator=(class EntityRegistry const &) = delete;
EntityRegistry(class EntityRegistry const &) = delete;
public:
class EntityRegistry& operator=(class EntityRegistry const&) = delete;
EntityRegistry(class EntityRegistry const&) = delete;
EntityRegistry() = delete;
#endif

public:
public:
/**
* @symbol ?getWeakRef\@EntityRegistry\@\@QEAA?AV?$WeakRefT\@UEntityRegistryRefTraits\@\@\@\@XZ
*/
Expand All @@ -36,13 +36,13 @@ class EntityRegistry {
*/
MCAPI ~EntityRegistry();

//protected:
// protected:
/**
* @symbol ??0EntityRegistry\@\@IEAA\@V?$basic_string\@DU?$char_traits\@D\@std\@\@V?$allocator\@D\@2\@\@std\@\@\@Z
*/
MCAPI EntityRegistry(std::string);

//private:
// private:
/**
* @symbol ?_createEntity\@EntityRegistry\@\@AEAA?AVEntityContext\@\@XZ
*/
Expand All @@ -52,8 +52,8 @@ class EntityRegistry {
*/
MCAPI void _destroyEntity(class EntityContext);

protected:

private:
protected:
private:
};

};
#include "EntityRegistryRefTraits.hpp"
6 changes: 6 additions & 0 deletions LiteLoader/include/llapi/mc/EntityRegistryBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class EntityRegistryBase {

#define AFTER_EXTRA
// Add Member There
struct ICanModifyComponentPoolDuringView {};

entt::basic_registry<EntityId, std::allocator<EntityId>>* mRegistry;
std::optional<EntityId> mViewedEntity;
std::unique_ptr<EntityRegistryBase::ICanModifyComponentPoolDuringView> mCanModifyDuringView;
bool mViewUsesViewedContext;

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_ENTITYREGISTRYBASE
Expand Down
20 changes: 20 additions & 0 deletions LiteLoader/include/llapi/mc/EntityRegistryRefTraits.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "llapi/Global.h"
#include "EntityRegistry.hpp"

class EntityRegistryOwned : public EntityRegistry {
public:
entt::basic_registry<EntityId, std::allocator<EntityId>> mOwnedRegistry;
};

struct EntityRegistryRefTraits {
public:
using StackRef = EntityRegistry;
using WeakStorage = WeakStorageSharePtr<StackRef>;
using StackResultStorage = StackResultStorageSharePtr<StackRef>;
using OwnerStackRef = EntityRegistryOwned;
using OwnerStorage = OwnerStorageSharePtr<OwnerStackRef>;
};

struct EntityRegistryConstRefTraits : public EntityRegistryRefTraits {};
15 changes: 12 additions & 3 deletions LiteLoader/include/llapi/mc/HashedString.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 @@ -19,11 +19,11 @@ class HashedString {

#define AFTER_EXTRA
// Add Member There
public:
uint64_t hash;
std::string str;
int64_t unk;

public:
//HashedString(HashedString const& hstr)
// : str(hstr.getString())
// , unk(0)
Expand Down Expand Up @@ -134,4 +134,13 @@ class HashedString {
*/
MCAPI static class HashedString const & getEmptyString();

};
};

namespace std {

template <>
struct hash<HashedString> {
std::size_t operator()(HashedString const& str) const noexcept { return str.getHash(); }
};

} // namespace std
13 changes: 12 additions & 1 deletion LiteLoader/include/llapi/mc/OwnerStorageEntity.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 "EntityContext.hpp"

#undef BEFORE_EXTRA

Expand All @@ -18,7 +19,17 @@
class OwnerStorageEntity {

#define AFTER_EXTRA
// Add Member There
// Add Member There
public:

enum class VariadicInit : int {
NonAmbiguous = 0,
};
enum class EmptyInit : int {
NoValue = 0,
};

std::optional<EntityContext> mContext;

#undef AFTER_EXTRA
#ifndef DISABLE_CONSTRUCTOR_PREVENTION_OWNERSTORAGEENTITY
Expand Down
Loading