mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
Added Capability.cast, to allow avoiding unchecked casts in ICapabilityProvider.getCapability
This commit is contained in:
1 parent
a4d5760539
commit
08663587d4
13 files changed
+33
-20
No files matched your search
@@ -92,6 +92,17 @@ public class Capability<T>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this inside ICapabilityProvider.getCapability to avoid unchecked cast warnings.
|
||||
* Example: return SOME_CAPABILITY.cast(instance);
|
||||
* Use with caution;
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R> R cast(T instance)
|
||||
{
|
||||
return (R)instance;
|
||||
}
|
||||
|
||||
// INTERNAL
|
||||
private final String name;
|
||||
private final IStorage<T> storage;
|
||||
|
||||
Reference in new issue
Block a user