mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-23 21:49:46 +00:00
Deprecate passing a class to CapabilityManager::register (#4574)
This commit is contained in:
1 parent
622c17ff04
commit
14a7d66024
5 files changed
+9
-5
No files matched your search
@@ -49,7 +49,11 @@ public enum CapabilityManager
|
||||
* @param type The Interface to be registered
|
||||
* @param storage A default implementation of the storage handler.
|
||||
* @param implementation A default implementation of the interface.
|
||||
* @deprecated Use the overload that takes a factory instead of a class.
|
||||
* You can easily do this by passing a constructor reference
|
||||
* (MyImpl::new instead of MyImpl.class). TODO remove in 1.13.
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> void register(Class<T> type, Capability.IStorage<T> storage, final Class<? extends T> implementation)
|
||||
{
|
||||
Preconditions.checkArgument(implementation != null, "Attempted to register a capability with no default implementation");
|
||||
@@ -173,4 +177,4 @@ public enum CapabilityManager
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class ChunkCapabilityPollutionTest {
|
||||
{
|
||||
if (ENABLE)
|
||||
{
|
||||
CapabilityManager.INSTANCE.register(IPollution.class, new PollutionStorage(), DefaultPollution.class);
|
||||
CapabilityManager.INSTANCE.register(IPollution.class, new PollutionStorage(), DefaultPollution::new);
|
||||
MinecraftForge.EVENT_BUS.register(new EventBusHandler());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class NoBedSleepingTest
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
CapabilityManager.INSTANCE.register(IExtraSleeping.class, new Storage(), DefaultImpl.class);
|
||||
CapabilityManager.INSTANCE.register(IExtraSleeping.class, new Storage(), DefaultImpl::new);
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class TestCapabilityMod
|
||||
// If you are a API, provide register your capability ASAP.
|
||||
// You MUST supply a default save handler and a default implementation
|
||||
// If you are a CONSUMER of the capability DO NOT register it. Only APIs should.
|
||||
CapabilityManager.INSTANCE.register(IExampleCapability.class, new Storage(), DefaultImpl.class);
|
||||
CapabilityManager.INSTANCE.register(IExampleCapability.class, new Storage(), DefaultImpl::new);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class WorldCapabilityRainTimerTest
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
CapabilityManager.INSTANCE.register(IRainTimer.class, new TimerStorage(), DefaultTimer.class);
|
||||
CapabilityManager.INSTANCE.register(IRainTimer.class, new TimerStorage(), DefaultTimer::new);
|
||||
MinecraftForge.EVENT_BUS.register(new NormalEventHandler());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user