mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Throw exception when a mod returns null from a dispatched capability provider (#5646)
This commit is contained in:
1 parent
201c368325
commit
5f0fd4b706
1 file changed
+12
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user