Handle invalid local palette block states
This commit is contained in:
parent
ea2ff1b8fd
commit
2db8c240c1
|
@ -36,7 +36,7 @@ namespace Feather
|
||||||
AddMapping(m_NextID, value);
|
AddMapping(m_NextID, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int GetID(T& value) const
|
inline int GetID(const T& value) const
|
||||||
{
|
{
|
||||||
return m_ValueToID.at(value);
|
return m_ValueToID.at(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@ namespace Feather
|
||||||
}
|
}
|
||||||
catch (std::out_of_range& err) {
|
catch (std::out_of_range& err) {
|
||||||
(void)err;
|
(void)err;
|
||||||
|
int defaultId = World::GLOBAL_PALETTE.GetDefaultID();
|
||||||
|
section->localPalette.AddMapping(i, defaultId);
|
||||||
Log::Warn("Chunk Section Palette maps id {} to invalid block state with name '{}'", i, name);
|
Log::Warn("Chunk Section Palette maps id {} to invalid block state with name '{}'", i, name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Feather
|
||||||
m_registry(registry)
|
m_registry(registry)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual int GetID(T& value) const = 0;
|
virtual int GetID(const T& value) const = 0;
|
||||||
|
|
||||||
virtual const T& ByID(int id) const = 0;
|
virtual const T& ByID(int id) const = 0;
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,10 @@ namespace Feather
|
||||||
m_defaultValue(defaultValue)
|
m_defaultValue(defaultValue)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline virtual int GetID(T& value) const final { return m_registry.GetID(value); }
|
inline const T& GetDefault() const { return *m_defaultValue; }
|
||||||
|
inline int GetDefaultID() const { return GetID(GetDefault()); }
|
||||||
|
|
||||||
|
inline virtual int GetID(const T& value) const final { return m_registry.GetID(value); }
|
||||||
inline virtual const T& ByID(int id) const final { return m_registry.ByID(id); }
|
inline virtual const T& ByID(int id) const final { return m_registry.ByID(id); }
|
||||||
};
|
};
|
||||||
}
|
}
|
Loading…
Reference in New Issue