fix: correct emission copy and cleanup Block code

This commit is contained in:
Maghom1995 2026-09-10 20:34:54 +03:00
parent bb6bd27b94
commit e388fbf4f9
4 changed files with 8 additions and 24 deletions

View file

@ -33,11 +33,11 @@ std::unique_ptr<Content> ContentBuilder::build() {
if (def.variants) { if (def.variants) {
for (auto& variant : def.variants->variants) { for (auto& variant : def.variants->variants) {
variant.rt.solid = isSolid(variant) || def.explictlySolid; variant.rt.solid = isSolid(variant) || def.explicitlySolid;
} }
def.defaults = def.variants->variants.at(0); def.defaults = def.variants->variants.at(0);
} else { } else {
def.defaults.rt.solid = isSolid(def.defaults) || def.explictlySolid; def.defaults.rt.solid = isSolid(def.defaults) || def.explicitlySolid;
} }
def.rt.solid = def.defaults.rt.solid; def.rt.solid = def.defaults.rt.solid;

View file

@ -255,7 +255,7 @@ template<> void ContentUnitLoader<Block>::loadUnit(
root.at("tick-interval").get(def.tickInterval); root.at("tick-interval").get(def.tickInterval);
root.at("overlay-texture").get(def.overlayTexture); root.at("overlay-texture").get(def.overlayTexture);
root.at("translucent").get(def.translucent); root.at("translucent").get(def.translucent);
root.at("solid").get(def.explictlySolid); root.at("solid").get(def.explicitlySolid);
if (root.has("fields")) { if (root.has("fields")) {
def.dataStruct = std::make_unique<StructLayout>(); def.dataStruct = std::make_unique<StructLayout>();

View file

@ -129,13 +129,6 @@ Block::Block(const std::string& name)
Block::~Block() = default; Block::~Block() = default;
Block::Block(std::string name, const std::string& texture)
: name(std::move(name)) {
for (int i = 0; i < defaults.textureFaces.size(); i++) {
defaults.textureFaces[i] = TEXTURE_NOTFOUND;
}
}
void Block::cloneTo(Block& dst) { void Block::cloneTo(Block& dst) {
dst.caption = caption; dst.caption = caption;
dst.defaults = defaults; dst.defaults = defaults;
@ -143,7 +136,7 @@ void Block::cloneTo(Block& dst) {
dst.variants = std::make_unique<Variants>(*variants); dst.variants = std::make_unique<Variants>(*variants);
} }
dst.material = material; dst.material = material;
std::copy(&emission[0], &emission[3], dst.emission); std::copy(&emission[0], &emission[4], dst.emission);
dst.size = size; dst.size = size;
dst.lightPassing = lightPassing; dst.lightPassing = lightPassing;
dst.skyLightPassing = skyLightPassing; dst.skyLightPassing = skyLightPassing;
@ -165,7 +158,7 @@ void Block::cloneTo(Block& dst) {
dst.tickInterval = tickInterval; dst.tickInterval = tickInterval;
dst.overlayTexture = overlayTexture; dst.overlayTexture = overlayTexture;
dst.translucent = translucent; dst.translucent = translucent;
dst.explictlySolid = explictlySolid; dst.explicitlySolid = explicitlySolid;
dst.tags = tags; dst.tags = tags;
if (dataStruct) { if (dataStruct) {
dst.dataStruct = std::make_unique<data::StructLayout>(*dataStruct); dst.dataStruct = std::make_unique<data::StructLayout>(*dataStruct);
@ -174,10 +167,3 @@ void Block::cloneTo(Block& dst) {
dst.particles = std::make_unique<ParticlesPreset>(*particles); dst.particles = std::make_unique<ParticlesPreset>(*particles);
} }
} }
static std::set<std::string, std::less<>> RESERVED_BLOCK_FIELDS {
};
bool Block::isReservedBlockField(std::string_view view) {
return RESERVED_BLOCK_FIELDS.find(view) != RESERVED_BLOCK_FIELDS.end();
}

View file

@ -255,7 +255,7 @@ public:
bool translucent = false; bool translucent = false;
/// @brief Explicitly overriding 'solid' property if true assigned /// @brief Explicitly overriding 'solid' property if true assigned
bool explictlySolid = false; bool explicitlySolid = false;
/// @brief Grounding behaviour /// @brief Grounding behaviour
GroundingBehaviour groundingBehaviour = GroundingBehaviour::PARTIAL; GroundingBehaviour groundingBehaviour = GroundingBehaviour::PARTIAL;
@ -328,7 +328,6 @@ public:
} rt {}; } rt {};
Block(const std::string& name); Block(const std::string& name);
Block(std::string name, const std::string& texture);
Block(const Block&) = delete; Block(const Block&) = delete;
~Block(); ~Block();
@ -349,16 +348,15 @@ public:
} }
const Variant& getVariant(uint8_t index) const { const Variant& getVariant(uint8_t index) const {
if (index == 0) if (index == 0 || variants == nullptr)
return defaults; return defaults;
assert(index < variants->variants.size());
return variants->variants[index]; return variants->variants[index];
} }
const BlockModel& getModel(uint8_t bits) const { const BlockModel& getModel(uint8_t bits) const {
return getVariantByBits(bits).model; return getVariantByBits(bits).model;
} }
static bool isReservedBlockField(std::string_view view);
}; };
inline glm::ivec3 get_ground_direction(const Block& def, int rotation) { inline glm::ivec3 get_ground_direction(const Block& def, int rotation) {