Throw exception when a mod returns null from a dispatched capability provider (#5646)
This commit is contained in:
parent
201c368325
commit
5f0fd4b706
1 changed files with 12 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue