Throw exception when a mod returns null from a dispatched capability provider (#5646)

This commit is contained in:
Sargun Vohra 2019-07-08 19:45:10 -07:00 committed by LexManos
parent 201c368325
commit 5f0fd4b706

View file

@ -100,7 +100,18 @@ public final class CapabilityDispatcher implements INBTSerializable<CompoundNBT>
for (ICapabilityProvider c : caps)
{
LazyOptional<T> ret = c.getCapability(cap, side);
if (ret.isPresent()) {
//noinspection ConstantConditions
if (ret == null)
{
throw new RuntimeException(
String.format(
"Provider %s.getCapability() returned null; return LazyOptional.empty() instead!",
c.getClass().getTypeName()
)
);
}
if (ret.isPresent())
{
return ret;
}
}