-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 1.20.5 components to protocolcraft
- Loading branch information
Showing
58 changed files
with
4,363 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
protocolCraft/include/protocolCraft/Types/Components/DataComponentPatch.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#pragma once | ||
#if PROTOCOL_VERSION > 765 /* > 1.20.4 */ | ||
#include "protocolCraft/NetworkType.hpp" | ||
|
||
// Use map instead of unordered to avoid another include everywhere | ||
#include <map> | ||
#include <memory> | ||
#include <string_view> | ||
|
||
namespace ProtocolCraft | ||
{ | ||
namespace Components | ||
{ | ||
enum class DataComponentTypes | ||
{ | ||
None = -1, | ||
CustomData, | ||
MaxStackSize, | ||
MaxDamage, | ||
Damage, | ||
Unbreakable, | ||
CustomName, | ||
ItemName, | ||
Lore, | ||
Rarity, | ||
Enchantments, | ||
CanPlaceOn, | ||
CanBreak, | ||
AttributeModifiers, | ||
CustomModelData, | ||
HideAdditionalTooltip, | ||
HideTooltip, | ||
RepairCost, | ||
CreativeSlotLock, | ||
EnchantmentGlintOverride, | ||
IntangibleProjectile, | ||
Food, | ||
FireResistant, | ||
Tool, | ||
StoredEnchantments, | ||
DyedColor, | ||
MapColor, | ||
MapId, | ||
MapDecorations, | ||
MapPostProcessing, | ||
ChargedProjectiles, | ||
BundleContents, | ||
PotionContents, | ||
SuspiciousStewEffects, | ||
WritableBookContent, | ||
WrittenBookContent, | ||
Trim, | ||
DebugStickState, | ||
EntityData, | ||
BucketEntityData, | ||
BlockEntityData, | ||
Instrument, | ||
OminousBottleAmplifier, | ||
Recipes, | ||
LodestoneTracker, | ||
FireworkExplosion, | ||
Fireworks, | ||
Profile, | ||
NoteBlockSound, | ||
BannerPatterns, | ||
BaseColor, | ||
PotDecorations, | ||
Container, | ||
BlockState, | ||
Bees, | ||
Lock, | ||
ContainerLoot, | ||
NUM_DATA_COMPONENT_TYPES | ||
}; | ||
|
||
std::string_view DataComponentTypesToString(const DataComponentTypes type); | ||
|
||
class DataComponentType; | ||
|
||
class DataComponentPatch : public NetworkType | ||
{ | ||
public: | ||
virtual ~DataComponentPatch() override; | ||
|
||
const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& GetMap() const; | ||
void SetMap(const std::map<DataComponentTypes, std::shared_ptr<DataComponentType>>& map_); | ||
|
||
protected: | ||
virtual void ReadImpl(ReadIterator& iter, size_t& length) override; | ||
virtual void WriteImpl(WriteContainer& container) const override; | ||
virtual Json::Value SerializeImpl() const override; | ||
|
||
private: | ||
std::map<DataComponentTypes, std::shared_ptr<DataComponentType>> map; | ||
|
||
}; | ||
} | ||
} | ||
#endif |
20 changes: 20 additions & 0 deletions
20
protocolCraft/include/protocolCraft/Types/Components/DataComponentType.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
#if PROTOCOL_VERSION > 765 /* > 1.20.4 */ | ||
#include "protocolCraft/NetworkType.hpp" | ||
|
||
namespace ProtocolCraft | ||
{ | ||
namespace Components | ||
{ | ||
class DataComponentType : public NetworkType | ||
{ | ||
public: | ||
virtual ~DataComponentType() | ||
{ | ||
|
||
}; | ||
|
||
}; | ||
} | ||
} | ||
#endif |
72 changes: 72 additions & 0 deletions
72
...lCraft/include/protocolCraft/Types/Components/DataComponentTypeAdventureModePredicate.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#pragma once | ||
#if PROTOCOL_VERSION > 765 /* > 1.20.4 */ | ||
#include "protocolCraft/Types/Components/DataComponentType.hpp" | ||
#include "protocolCraft/Types/Components/Subtypes/BlockPredicate.hpp" | ||
|
||
#include <vector> | ||
|
||
namespace ProtocolCraft | ||
{ | ||
namespace Components | ||
{ | ||
class DataComponentTypeAdventureModePredicate : public DataComponentType | ||
{ | ||
public: | ||
virtual ~DataComponentTypeAdventureModePredicate() | ||
{ | ||
|
||
} | ||
|
||
|
||
const std::vector<BlockPredicate>& GetPredicates() const | ||
{ | ||
return predicates; | ||
} | ||
|
||
bool GetShowInTooltip() const | ||
{ | ||
return show_in_tooltip; | ||
} | ||
|
||
|
||
void SetPredicates(const std::vector<BlockPredicate>& predicates_) | ||
{ | ||
predicates = predicates_; | ||
} | ||
|
||
void SetShowInTooltip(const bool show_in_tooltip_) | ||
{ | ||
show_in_tooltip = show_in_tooltip_; | ||
} | ||
|
||
protected: | ||
virtual void ReadImpl(ReadIterator& iter, size_t& length) override | ||
{ | ||
predicates = ReadVector<BlockPredicate>(iter, length); | ||
show_in_tooltip = ReadData<bool>(iter, length); | ||
} | ||
|
||
virtual void WriteImpl(WriteContainer& container) const override | ||
{ | ||
WriteVector<BlockPredicate>(predicates, container); | ||
WriteData<bool>(show_in_tooltip, container); | ||
} | ||
|
||
virtual Json::Value SerializeImpl() const override | ||
{ | ||
Json::Value output; | ||
|
||
output["predicates"] = predicates; | ||
output["show_in_tooltip"] = show_in_tooltip; | ||
|
||
return output; | ||
} | ||
|
||
private: | ||
std::vector<BlockPredicate> predicates; | ||
bool show_in_tooltip = true; | ||
|
||
}; | ||
} | ||
} | ||
#endif |
83 changes: 83 additions & 0 deletions
83
protocolCraft/include/protocolCraft/Types/Components/DataComponentTypeArmorTrim.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#pragma once | ||
#if PROTOCOL_VERSION > 765 /* > 1.20.4 */ | ||
#include "protocolCraft/Types/Components/DataComponentType.hpp" | ||
|
||
namespace ProtocolCraft | ||
{ | ||
namespace Components | ||
{ | ||
class DataComponentTypeArmorTrim : public DataComponentType | ||
{ | ||
public: | ||
virtual ~DataComponentTypeArmorTrim() | ||
{ | ||
|
||
} | ||
|
||
|
||
int GetMaterial() const | ||
{ | ||
return material; | ||
} | ||
|
||
int GetPattern() const | ||
{ | ||
return pattern; | ||
} | ||
|
||
bool GetShowInTooltip() const | ||
{ | ||
return show_in_tooltip; | ||
} | ||
|
||
|
||
void SetMaterial(const int material_) | ||
{ | ||
material = material_; | ||
} | ||
|
||
void SetPattern(const int pattern_) | ||
{ | ||
pattern = pattern_; | ||
} | ||
|
||
void SetShowInTooltip(const bool show_in_tooltip_) | ||
{ | ||
show_in_tooltip = show_in_tooltip_; | ||
} | ||
|
||
protected: | ||
virtual void ReadImpl(ReadIterator& iter, size_t& length) override | ||
{ | ||
material = ReadData<VarInt>(iter, length); | ||
pattern = ReadData<VarInt>(iter, length); | ||
show_in_tooltip = ReadData<bool>(iter, length); | ||
} | ||
|
||
virtual void WriteImpl(WriteContainer& container) const override | ||
{ | ||
WriteData<VarInt>(material, container); | ||
WriteData<VarInt>(pattern, container); | ||
WriteData<bool>(show_in_tooltip, container); | ||
} | ||
|
||
virtual Json::Value SerializeImpl() const override | ||
{ | ||
Json::Value output; | ||
|
||
output["material"] = material; | ||
output["pattern"] = pattern; | ||
output["show_in_tooltip"] = show_in_tooltip; | ||
|
||
return output; | ||
} | ||
|
||
private: | ||
int material = 0; | ||
int pattern = 0; | ||
bool show_in_tooltip = true; | ||
|
||
}; | ||
} | ||
} | ||
#endif |
Oops, something went wrong.