Skip to content

Commit

Permalink
Merge branch 'support-1.20.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
kbinani committed May 6, 2024
2 parents bd54394 + 927a2af commit f9bd8e9
Show file tree
Hide file tree
Showing 40,654 changed files with 6,740 additions and 1,191 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif()
CPMAddPackage(
NAME libminecraft-file
GITHUB_REPOSITORY kbinani/libminecraft-file
GIT_TAG 6411a9810404d40daad4107b5478c554685934d6)
GIT_TAG ed92e06a8726993df399bf5f03264ef15c9c536a)

CPMAddPackage(
NAME defer
Expand Down Expand Up @@ -204,11 +204,14 @@ set(je2be_src_files
src/_volume.hpp
src/_walk.hpp
src/bedrock-block-data.cpp
src/bedrock-block-entity-before-components-introduced.hpp
src/bedrock-block-entity.cpp
src/bedrock-chunk.cpp
src/bedrock-context.cpp
src/bedrock-converter.cpp
src/bedrock-entity-before-components-introduced.hpp
src/bedrock-entity.cpp
src/bedrock-item-before-components-introduced.hpp
src/bedrock-item.cpp
src/bedrock-region.cpp
src/bedrock-sub-chunk.cpp
Expand Down Expand Up @@ -237,6 +240,7 @@ set(je2be_src_files
src/bedrock/terraform/_tripwire.hpp
src/bedrock/terraform/_twisting-vines.hpp
src/bedrock/terraform/_weeping-vines.hpp
src/block/_trial-spawner.hpp
src/color/_lab.hpp
src/color/_rgba.hpp
src/color/_sign-color.hpp
Expand All @@ -260,6 +264,7 @@ set(je2be_src_files
src/entity/_painting.hpp
src/entity/_panda.hpp
src/entity/_tropical-fish.hpp
src/entity/_wolf.hpp
src/enums/_banner-color-code-bedrock.hpp
src/enums/_chunk-conversion-mode.hpp
src/enums/_color-code-java.hpp
Expand Down Expand Up @@ -300,6 +305,7 @@ set(je2be_src_files
src/java/_chunk-data-package.hpp
src/java/_chunk-data.hpp
src/java/_chunk.hpp
src/java/_components.hpp
src/java/_context.hpp
src/java/_datapacks.hpp
src/java/_enchant-data.hpp
Expand Down
34 changes: 17 additions & 17 deletions include/je2be/uuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ struct Uuid {
return u;
}

static std::optional<Uuid> FromIntArray(IntArrayTag const &tag) {
auto const &values = tag.value();
if (values.size() != 4) {
return std::nullopt;
}
i32 f1 = values[0];
i32 f2 = values[1];
i32 f3 = values[2];
i32 f4 = values[3];
Uuid u;
*(i32 *)u.fData = mcfile::I32FromBE(f1);
*((i32 *)u.fData + 1) = mcfile::I32FromBE(f2);
*((i32 *)u.fData + 2) = mcfile::I32FromBE(f3);
*((i32 *)u.fData + 3) = mcfile::I32FromBE(f4);
return u;
}

static std::optional<Uuid> FromString(std::u8string const &str) {
using namespace std;
u8string uuid = strings::Replace(str, u8"-", u8"");
Expand Down Expand Up @@ -149,23 +166,6 @@ struct Uuid {
std::vector<i32> uuidValues({v1, v2, v3, v4});
return std::make_shared<IntArrayTag>(uuidValues);
}

static std::optional<Uuid> FromIntArrayTag(IntArrayTag const &tag) {
auto const &values = tag.value();
if (values.size() != 4) {
return std::nullopt;
}
i32 f1 = values[0];
i32 f2 = values[1];
i32 f3 = values[2];
i32 f4 = values[3];
Uuid u;
*(i32 *)u.fData = mcfile::I32FromBE(f1);
*((i32 *)u.fData + 1) = mcfile::I32FromBE(f2);
*((i32 *)u.fData + 2) = mcfile::I32FromBE(f3);
*((i32 *)u.fData + 3) = mcfile::I32FromBE(f4);
return u;
}
};

struct UuidHasher {
Expand Down
38 changes: 38 additions & 0 deletions src/_nbt-ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,42 @@ static inline void CopyStringValues(CompoundTag const &src, CompoundTag &dest, s
}
}
}

template <class NbtTag>
inline std::shared_ptr<NbtTag> FallbackPtr(CompoundTag const &c, std::initializer_list<std::u8string> names) {
for (auto const &name : names) {
if (auto v = c.get<NbtTag>(name); v) {
return v;
}
}
return nullptr;
}

template <class NbtTag>
inline std::shared_ptr<NbtTag> FallbackPtr(CompoundTagPtr const &c, std::initializer_list<std::u8string> names) {
if (!c) {
return nullptr;
}
return FallbackPtr<NbtTag>(*c, names);
}

inline Tag const *FallbackQuery(CompoundTag const &c, std::initializer_list<std::u8string> queries) {
for (auto const &query : queries) {
if (auto v = c.query(query); v && v->type() != Tag::Type::End) {
return v;
}
}
return mcfile::nbt::EndTag::Instance();
}

template <class T>
inline std::optional<T> FallbackValue(CompoundTag const &c, std::initializer_list<std::u8string> names) {
for (auto const &name : names) {
if (auto v = c.value<T>(name); v) {
return v;
}
}
return std::nullopt;
}

} // namespace je2be
114 changes: 101 additions & 13 deletions src/bedrock-block-data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "_closed-range.hpp"
#include "_namespace.hpp"
#include "bedrock/_legacy-block.hpp"
#include "block/_trial-spawner.hpp"
#include "enums/_color-code-java.hpp"
#include "enums/_facing4.hpp"
#include "enums/_facing6.hpp"
Expand Down Expand Up @@ -542,6 +543,13 @@ class BlockData::Impl {
}

static String CoralFan(String const &bName, CompoundTag const &s, Props &p) {
// coral_fan_direction always 1
// auto direction = s.int32(u8"coral_fan_direction", 1);
Submergible(s, p);
return bName;
}

static String CoralFanLegacy(String const &bName, CompoundTag const &s, Props &p) {
auto color = s.string(u8"coral_color", u8"pink");
auto dead = bName.ends_with(u8"_dead");
auto type = CoralTypeFromCoralColor(color);
Expand Down Expand Up @@ -807,7 +815,7 @@ class BlockData::Impl {
return Ns() + u8"powered_rail";
}

static String Grass(String const &bName, CompoundTag const &s, Props &p) {
static String GrassBlock(String const &bName, CompoundTag const &s, Props &p) {
p[u8"snowy"] = u8"false";
return Ns() + u8"grass_block";
}
Expand Down Expand Up @@ -925,7 +933,7 @@ class BlockData::Impl {
return bName;
}

static String Leaves(String const &bName, CompoundTag const &s, Props &p) {
static String LeavesLegacy(String const &bName, CompoundTag const &s, Props &p) {
auto leafType = s.string(u8"old_leaf_type", u8"oak");
PersistentFromPersistentBit(s, p);
Submergible(s, p);
Expand Down Expand Up @@ -1325,7 +1333,7 @@ class BlockData::Impl {
return Ns() + name;
}

static String Sapling(String const &bName, CompoundTag const &s, Props &p) {
static String SaplingLegacy(String const &bName, CompoundTag const &s, Props &p) {
auto saplingType = s.string(u8"sapling_type", u8"acacia");
StageFromAgeBit(s, p);
return Ns() + saplingType + u8"_sapling";
Expand Down Expand Up @@ -1588,6 +1596,16 @@ class BlockData::Impl {
}
}

static String TrialSpawner(String const &bName, CompoundTag const &s, Props &p) {
auto stateB = s.int32(u8"trial_spawner_state", 0);
auto stateJ = TrialSpawner::JavaTrialSpawnerStateFromBedrock(stateB);
p[u8"trial_spawner_state"] = stateJ;
if (auto ominous = s.boolean(u8"ominous"); ominous) {
p[u8"ominous"] = Bool(*ominous);
}
return bName;
}

static String Tripwire(String const &bName, CompoundTag const &s, Props &p) {
auto attached = s.boolean(u8"attached_bit", false);
auto disarmed = s.boolean(u8"disarmed_bit", false);
Expand Down Expand Up @@ -1630,6 +1648,19 @@ class BlockData::Impl {
}
#pragma endregion

#pragma region Converters : V
static String Vault(String const &bName, CompoundTag const &s, Props &p) {
FacingFromCardinalDirection(s, p);
auto ominous = s.boolean(u8"ominous");
if (ominous) {
p[u8"ominous"] = Bool(*ominous);
}
auto vaultState = s.string(u8"vault_state", u8"inactive");
p[u8"vault_state"] = vaultState;
return bName;
}
#pragma endregion

#pragma region Converters : W
static String WallWithBlockType(String const &bName, CompoundTag const &s, Props &p) {
auto type = s.string(u8"wall_block_type", u8"andesite");
Expand All @@ -1642,7 +1673,7 @@ class BlockData::Impl {
return Ns() + name + u8"_wall";
}

static String Wood(String const &bName, CompoundTag const &s, Props &p) {
static String WoodLegacy(String const &bName, CompoundTag const &s, Props &p) {
auto stripped = s.boolean(u8"stripped_bit", false);
auto woodType = s.string(u8"wood_type", u8"oak");
auto name = stripped ? u8"stripped_" + woodType + u8"_wood" : woodType + u8"_wood";
Expand All @@ -1651,7 +1682,7 @@ class BlockData::Impl {
}

static String WoodenPressurePlate(String const &bName, CompoundTag const &s, Props &p) {
auto signal = s.int32(u8"restone_signal", 0);
auto signal = s.int32(u8"redstone_signal", 0);
p[u8"powered"] = Bool(signal > 0);
return Ns() + u8"oak_pressure_plate";
}
Expand Down Expand Up @@ -2254,8 +2285,14 @@ class BlockData::Impl {
E(spruce_fence_gate, BlockWithDirection);
E(warped_fence_gate, BlockWithDirection);

E(leaves, Leaves);
E(leaves, LeavesLegacy);
E(leaves2, Leaves2);
E(oak_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(birch_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(spruce_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(acacia_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(jungle_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(dark_oak_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(log2, Log2Legacy);
E(log, LogLegacy);
E(oak_log, BlockWithAxisFromPillarAxis);
Expand All @@ -2276,7 +2313,14 @@ class BlockData::Impl {
E(stone_pressure_plate, PressurePlate);
E(warped_pressure_plate, PressurePlate);

E(sapling, Sapling);
E(sapling, SaplingLegacy);
C sapling(Same, StageFromAgeBit);
E(oak_sapling, sapling);
E(birch_sapling, sapling);
E(spruce_sapling, sapling);
E(acacia_sapling, sapling);
E(jungle_sapling, sapling);
E(dark_oak_sapling, sapling);

E(acacia_standing_sign, StandingSign);
E(birch_standing_sign, StandingSign);
Expand All @@ -2286,8 +2330,20 @@ class BlockData::Impl {
E(spruce_standing_sign, StandingSign);
E(warped_standing_sign, StandingSign);

E(wooden_slab, WoodenSlab);
E(wooden_slab, WoodenSlab); // legacy
E(oak_slab, Slab);
E(birch_slab, Slab);
E(spruce_slab, Slab);
E(acacia_slab, Slab);
E(jungle_slab, Slab);
E(dark_oak_slab, Slab);
E(double_wooden_slab, DoubleWoodenSlab);
E(oak_double_slab, DoubleSlab(u8"oak_slab"));
E(birch_double_slab, DoubleSlab(u8"birch_slab"));
E(spruce_double_slab, DoubleSlab(u8"spruce_slab"));
E(acacia_double_slab, DoubleSlab(u8"acacia_slab"));
E(jungle_double_slab, DoubleSlab(u8"jungle_slab"));
E(dark_oak_double_slab, DoubleSlab(u8"dark_oak_slab"));

E(acacia_stairs, Stairs);
E(andesite_stairs, Stairs);
Expand Down Expand Up @@ -2355,7 +2411,20 @@ class BlockData::Impl {
E(spruce_wall_sign, BlockWithFacing4FromFacingDirectionASubmergible);
E(warped_wall_sign, BlockWithFacing4FromFacingDirectionASubmergible);

E(wood, Wood);
E(wood, WoodLegacy);
E(oak_wood, BlockWithAxisFromPillarAxis);
E(birch_wood, BlockWithAxisFromPillarAxis);
E(spruce_wood, BlockWithAxisFromPillarAxis);
E(acacia_wood, BlockWithAxisFromPillarAxis);
E(jungle_wood, BlockWithAxisFromPillarAxis);
E(dark_oak_wood, BlockWithAxisFromPillarAxis);
E(stripped_oak_wood, BlockWithAxisFromPillarAxis);
E(stripped_birch_wood, BlockWithAxisFromPillarAxis);
E(stripped_spruce_wood, BlockWithAxisFromPillarAxis);
E(stripped_acacia_wood, BlockWithAxisFromPillarAxis);
E(stripped_jungle_wood, BlockWithAxisFromPillarAxis);
E(stripped_dark_oak_wood, BlockWithAxisFromPillarAxis);

E(activator_rail, RailCanBePowered);
E(detector_rail, RailCanBePowered);
E(red_flower, RedFlower);
Expand Down Expand Up @@ -2516,11 +2585,23 @@ class BlockData::Impl {
E(dead_fire_coral, BlockWithSubmergible);
E(dead_horn_coral, BlockWithSubmergible);
E(coral_block, CoralBlock);

E(coral_fan_hang, CoralFanHang);
E(coral_fan_hang2, CoralFanHang);
E(coral_fan_hang3, CoralFanHang);
E(coral_fan, CoralFan);
E(coral_fan_dead, CoralFan);
E(coral_fan, CoralFanLegacy); // legacy
E(coral_fan_dead, CoralFanLegacy); // legacy
E(tube_coral_fan, CoralFan);
E(brain_coral_fan, CoralFan);
E(bubble_coral_fan, CoralFan);
E(fire_coral_fan, CoralFan);
E(horn_coral_fan, CoralFan);
E(dead_tube_coral_fan, CoralFan);
E(dead_brain_coral_fan, CoralFan);
E(dead_bubble_coral_fan, CoralFan);
E(dead_fire_coral_fan, CoralFan);
E(dead_horn_coral_fan, CoralFan);

E(brewing_stand, BrewingStand);
E(brick_block, Rename(u8"bricks"));
E(stone_slab, StoneSlab); // legacy, < 1.19
Expand Down Expand Up @@ -2611,7 +2692,9 @@ class BlockData::Impl {
E(lit_furnace, FurnaceAndSimilar);
E(glass_pane, BlockWithSubmergible);
E(glow_lichen, BlockWithMultiFaceDirectionBitsSubmergible);
E(grass, Grass);
E(grass, GrassBlock); // legacy
E(grass_block, GrassBlock);

E(grindstone, Grindstone);
E(hanging_roots, BlockWithSubmergible);
E(hay_block, BlockWithAxisFromPillarAxis);
Expand Down Expand Up @@ -2837,7 +2920,7 @@ class BlockData::Impl {
E(cherry_fence_gate, BlockWithDirection);
E(cherry_fence, BlockWithSubmergible);
E(cherry_trapdoor, Trapdoor);
E(cherry_sapling, C(Same, StageFromAgeBit));
E(cherry_sapling, sapling);
E(cherry_pressure_plate, PressurePlate);
E(cherry_leaves, BlockWithPersistentFromPersistentBitSubmergible);
E(pitcher_crop, C(Same, AgeFromGrowth, HalfFromUpperBlockBit));
Expand Down Expand Up @@ -2893,6 +2976,11 @@ class BlockData::Impl {
E(waxed_weathered_copper_bulb, CopperBulb);
E(waxed_oxidized_copper_bulb, CopperBulb);
E(crafter, Crafter);

// 1.21
E(vault, Vault);
E(heavy_core, BlockWithSubmergible);
E(trial_spawner, TrialSpawner);
#undef E

return table;
Expand Down
Loading

0 comments on commit f9bd8e9

Please sign in to comment.