mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Clean up null issues, add more annotations (#3590)
This commit is contained in:
1 parent
43efa3cfc4
commit
c545b8ecd4
130 files changed
+629
-262
No files matched your search
@@ -26,6 +26,8 @@ import com.google.common.base.Throwables;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* This is the core holder object Capabilities.
|
||||
* Each capability will have ONE instance of this class,
|
||||
@@ -55,6 +57,7 @@ public class Capability<T>
|
||||
* @param side The side of the object the instance is associated with.
|
||||
* @return a NBT holding the data. Null if no data needs to be stored.
|
||||
*/
|
||||
@Nullable
|
||||
NBTBase writeNBT(Capability<T> capability, T instance, EnumFacing side);
|
||||
|
||||
/**
|
||||
@@ -103,6 +106,7 @@ public class Capability<T>
|
||||
* Quick access to the IStorage's writeNBT.
|
||||
* See {@link IStorage#writeNBT(Capability, Object, EnumFacing)} for documentation.
|
||||
*/
|
||||
@Nullable
|
||||
public NBTBase writeNBT(T instance, EnumFacing side)
|
||||
{
|
||||
return storage.writeNBT(this, instance, side);
|
||||
@@ -117,6 +121,7 @@ public class Capability<T>
|
||||
*
|
||||
* @return A NEW instance of the default implementation.
|
||||
*/
|
||||
@Nullable
|
||||
public T getDefaultInstance()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -54,7 +54,7 @@ public final class CapabilityDispatcher implements INBTSerializable<NBTTagCompou
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public CapabilityDispatcher(Map<ResourceLocation, ICapabilityProvider> list, ICapabilityProvider parent)
|
||||
public CapabilityDispatcher(Map<ResourceLocation, ICapabilityProvider> list, @Nullable ICapabilityProvider parent)
|
||||
{
|
||||
List<ICapabilityProvider> lstCaps = Lists.newArrayList();
|
||||
List<INBTSerializable<NBTBase>> lstWriters = Lists.newArrayList();
|
||||
|
||||
@@ -39,6 +39,8 @@ import net.minecraftforge.common.util.EnumHelper;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public enum CapabilityManager
|
||||
{
|
||||
INSTANCE;
|
||||
@@ -63,11 +65,10 @@ public enum CapabilityManager
|
||||
try {
|
||||
return implementation.newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
Throwables.propagate(e);
|
||||
throw Throwables.propagate(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Throwables.propagate(e);
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -115,6 +116,7 @@ public enum CapabilityManager
|
||||
if (type == null)
|
||||
{
|
||||
FMLLog.log(Level.WARN, "Unable to inject capability at %s.%s (Invalid Annotation)", targetClass, targetName);
|
||||
continue;
|
||||
}
|
||||
final String capabilityName = type.getInternalName().replace('/', '.').intern();
|
||||
|
||||
|
||||
Reference in new issue
Block a user