Clean up null issues, add more annotations (#3590)

This commit is contained in:
James Mitchell authored and LexManos committed 2017-01-11 15:17:56 -08:00
1 parent 43efa3cfc4
commit c545b8ecd4
130 files changed
+629 -262

No files matched your search

@@ -36,7 +36,7 @@
+ return super.removedByPlayer(state, world, pos, player, willHarvest);
+ }
+ @Override
+ public void func_180657_a(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack tool)
+ public void func_180657_a(World world, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack tool)
+ {
+ super.func_180657_a(world, player, pos, state, te, tool);
+ world.func_175698_g(pos);
@@ -8,7 +8,7 @@
+ this(p_i45663_1_, p_i45663_2_, null);
+ }
+
+ protected StateImplementation createState(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, ImmutableMap<net.minecraftforge.common.property.IUnlistedProperty<?>, com.google.common.base.Optional<?>> unlistedProperties)
+ protected StateImplementation createState(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<net.minecraftforge.common.property.IUnlistedProperty<?>, com.google.common.base.Optional<?>> unlistedProperties)
+ {
+ return new StateImplementation(block, properties);
+ }
@@ -8,10 +8,11 @@
}
public int func_190736_dl()
@@ -85,6 +86,19 @@
@@ -85,6 +86,21 @@
return super.func_180482_a(p_180482_1_, p_180482_2_);
}
+ @Nullable
+ private net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof;
+ public void setForgeProfession(net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof)
+ {
@@ -19,6 +20,7 @@
+ this.func_190733_a(net.minecraftforge.fml.common.registry.VillagerRegistry.getId(prof));
+ }
+
+ @Nullable
+ public net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession getForgeProfession()
+ {
+ return this.prof;
@@ -65,7 +65,7 @@
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
+ {
+ if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ {
@@ -16,7 +16,7 @@
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable net.minecraft.util.EnumFacing facing)
+ {
+ if (capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ {
@@ -107,7 +107,7 @@
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing)
+ public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @javax.annotation.Nullable net.minecraft.util.EnumFacing facing)
+ {
+ if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
+ if (facing == EnumFacing.DOWN)
@@ -7,8 +7,8 @@
+
+ //Bypass functions to allow querying this registry WITHOUT getting the defaulted value.
+ // MODDERS DO NOT USE THIS IS FOR FORGE INTERNAL CHECKS
+ public int getIDForObjectBypass(V bypass) { return super.func_148757_b(bypass); }
+ public K getNameForObjectBypass(V value) { return super.func_177774_c(value); }
+ public V getObjectBypass(K name) { return super.func_82594_a(name); }
+ public V getObjectByIdBypass(int id){ return super.func_148754_a(id); }
+ public int getIDForObjectBypass(@Nullable V bypass) { return super.func_148757_b(bypass); }
+ @Nullable public K getNameForObjectBypass(V value) { return super.func_177774_c(value); }
+ @Nullable public V getObjectBypass(K name) { return super.func_82594_a(name); }
+ @Nullable public V getObjectByIdBypass(int id){ return super.func_148754_a(id); }
}
@@ -1,8 +1,8 @@
--- ../src-base/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
+++ ../src-work/minecraft/net/minecraft/world/chunk/storage/RegionFile.java
@@ -97,6 +97,39 @@
@Nullable
@@ -95,6 +95,39 @@
}
}
+ // This is a copy (sort of) of the method below it, make sure they stay in sync
+ public synchronized boolean chunkExists(int x, int z)
@@ -37,6 +37,6 @@
+ return false;
+ }
+
@Nullable
public synchronized DataInputStream func_76704_a(int p_76704_1_, int p_76704_2_)
{
if (this.func_76705_d(p_76704_1_, p_76704_2_))
@@ -24,6 +24,8 @@ import java.util.Map;
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
import javax.annotation.Nullable;
public class FMLForgePlugin implements IFMLLoadingPlugin
{
public static boolean RUNTIME_DEOBF = false;
@@ -42,6 +44,7 @@ public class FMLForgePlugin implements IFMLLoadingPlugin
}
@Override
@Nullable
public String getSetupClass()
{
return null;
@@ -134,7 +134,7 @@ public class ClientCommandHandler extends CommandHandler
if (mc.currentScreen instanceof GuiChat)
{
List<String> commands = getTabCompletions(mc.player, leftOfCursor, mc.player.getPosition());
if (commands != null && !commands.isEmpty())
if (!commands.isEmpty())
{
if (leftOfCursor.indexOf(' ') == -1)
{
@@ -24,6 +24,8 @@ import net.minecraft.world.GameType;
import net.minecraft.client.settings.GameSettings.Options;
import net.minecraftforge.common.util.EnumHelper;
import javax.annotation.Nullable;
public class EnumHelperClient extends EnumHelper
{
private static Class<?>[][] clientTypes =
@@ -33,16 +35,19 @@ public class EnumHelperClient extends EnumHelper
{EnumOS.class}
};
@Nullable
public static GameType addGameType(String name, int id, String displayName, String shortName)
{
return addEnum(GameType.class, name, id, displayName, shortName);
}
@Nullable
public static Options addOptions(String name, String langName, boolean isSlider, boolean isToggle)
{
return addEnum(Options.class, name, langName, isSlider, isToggle);
}
@Nullable
public static Options addOptions(String name, String langName, boolean isSlider, boolean isToggle, float valMin, float valMax, float valStep)
{
return addEnum(Options.class, name,
@@ -50,11 +55,13 @@ public class EnumHelperClient extends EnumHelper
langName, isSlider, isToggle, valMin, valMax, valStep);
}
@Nullable
public static EnumOS addOS2(String name)
{
return addEnum(EnumOS.class, name);
}
@Nullable
private static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Object... paramValues)
{
return addEnum(clientTypes, enumType, enumName, paramValues);
@@ -25,6 +25,8 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerEvent;
import javax.annotation.Nonnull;
public abstract class RenderPlayerEvent extends PlayerEvent
{
private final RenderPlayer renderer;
@@ -99,8 +101,9 @@ public abstract class RenderPlayerEvent extends PlayerEvent
{
private int result = -1;
private final int slot;
@Nonnull
private final ItemStack stack;
public SetArmorModel(EntityPlayer player, RenderPlayer renderer, int slot, float partialTick, ItemStack stack)
public SetArmorModel(EntityPlayer player, RenderPlayer renderer, int slot, float partialTick, @Nonnull ItemStack stack)
{
super(player, renderer, partialTick, 0D, 0D, 0D);
this.slot = slot;
@@ -126,6 +129,7 @@ public abstract class RenderPlayerEvent extends PlayerEvent
return slot;
}
@Nonnull
public ItemStack getStack()
{
return stack;
@@ -6,7 +6,6 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}
@@ -22,6 +21,7 @@ public class RenderSpecificHandEvent extends Event
private final float interpolatedPitch;
private final float swingProgress;
private final float equipProgress;
@Nonnull
private final ItemStack stack;
public RenderSpecificHandEvent(EnumHand hand, float partialTicks, float interpolatedPitch, float swingProgress, float equipProgress, @Nonnull ItemStack stack)
@@ -4,7 +4,6 @@ import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
@@ -26,6 +25,7 @@ import net.minecraftforge.fml.common.eventhandler.Event;
*/
public abstract class RenderTooltipEvent extends Event
{
@Nonnull
protected final ItemStack stack;
protected final List<String> lines;
protected int x;
@@ -42,7 +42,7 @@ public abstract class RenderTooltipEvent extends Event
}
/**
* @return The stack which the tooltip is being rendered for. As tooltips can be drawn without itemstacks, this return is {@link Nullable}.
* @return The stack which the tooltip is being rendered for. As tooltips can be drawn without itemstacks, this stack may be empty.
*/
@Nonnull
public ItemStack getStack()
@@ -98,7 +98,7 @@ public abstract class RenderTooltipEvent extends Event
private int screenHeight;
private int maxWidth;
public Pre(@Nullable ItemStack stack, @Nonnull List<String> lines, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull FontRenderer fr)
public Pre(@Nonnull ItemStack stack, @Nonnull List<String> lines, int x, int y, int screenWidth, int screenHeight, int maxWidth, @Nonnull FontRenderer fr)
{
super(stack, lines, x, y, fr);
this.screenWidth = screenWidth;
@@ -181,7 +181,7 @@ public abstract class RenderTooltipEvent extends Event
private final int width;
private final int height;
public Post(@Nullable ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
public Post(@Nonnull ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
{
super(stack, textLines, x, y, fr);
this.width = width;
@@ -210,7 +210,7 @@ public abstract class RenderTooltipEvent extends Event
*/
public static class PostBackground extends Post
{
public PostBackground(@Nullable ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
public PostBackground(@Nonnull ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
{ super(stack, textLines, x, y, fr, width, height); }
}
@@ -219,7 +219,7 @@ public abstract class RenderTooltipEvent extends Event
*/
public static class PostText extends Post
{
public PostText(@Nullable ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
public PostText(@Nonnull ItemStack stack, @Nonnull List<String> textLines, int x, int y, @Nonnull FontRenderer fr, int width, int height)
{ super(stack, textLines, x, y, fr, width, height); }
}
}
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nullable;
import javax.vecmath.AxisAngle4d;
import javax.vecmath.Matrix4f;
import javax.vecmath.Quat4f;
@@ -218,7 +219,7 @@ public class ForgeBlockStateV1 extends Marker
return ret;
}
private Multimap<String, ForgeBlockStateV1.Variant> getPermutations(List<String> sorted, Map<String, Map<String, ForgeBlockStateV1.Variant>> base, int depth, String prefix, Multimap<String, ForgeBlockStateV1.Variant> ret, ForgeBlockStateV1.Variant parent)
private Multimap<String, ForgeBlockStateV1.Variant> getPermutations(List<String> sorted, Map<String, Map<String, ForgeBlockStateV1.Variant>> base, int depth, String prefix, Multimap<String, ForgeBlockStateV1.Variant> ret, @Nullable ForgeBlockStateV1.Variant parent)
{
if (depth == sorted.size())
{
@@ -24,6 +24,7 @@ import java.util.BitSet;
import java.util.Collection;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector4f;
@@ -140,7 +141,7 @@ public final class ItemLayerModel implements IRetexturableModel
private final boolean isCulled;
private final ItemOverrideList overrides;
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TRSRTransformation> transforms, ItemOverrideList overrides, IBakedModel otherModel)
public BakedItemModel(ImmutableList<BakedQuad> quads, TextureAtlasSprite particle, ImmutableMap<TransformType, TRSRTransformation> transforms, ItemOverrideList overrides, @Nullable IBakedModel otherModel)
{
this.quads = quads;
this.particle = particle;
@@ -75,10 +75,13 @@ public final class ModelDynBucket implements IModel, IModelCustomData, IRetextur
public static final IModel MODEL = new ModelDynBucket();
@Nullable
private final ResourceLocation baseLocation;
@Nullable
private final ResourceLocation liquidLocation;
@Nullable
private final ResourceLocation coverLocation;
@Nullable
private final Fluid fluid;
private final boolean flipGas;
@@ -87,7 +90,7 @@ public final class ModelDynBucket implements IModel, IModelCustomData, IRetextur
this(null, null, null, null, false);
}
public ModelDynBucket(ResourceLocation baseLocation, ResourceLocation liquidLocation, ResourceLocation coverLocation, Fluid fluid, boolean flipGas)
public ModelDynBucket(@Nullable ResourceLocation baseLocation, @Nullable ResourceLocation liquidLocation, @Nullable ResourceLocation coverLocation, @Nullable Fluid fluid, boolean flipGas)
{
this.baseLocation = baseLocation;
this.liquidLocation = liquidLocation;
@@ -121,6 +121,8 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.Sets;
import javax.annotation.Nonnull;
public final class ModelLoader extends ModelBakery
{
private final Map<ModelResourceLocation, IModel> stateModels = Maps.newHashMap();
@@ -1167,7 +1169,7 @@ public final class ModelLoader extends ModelBakery
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
{
@Override
public ModelResourceLocation getModelLocation(ItemStack stack)
public ModelResourceLocation getModelLocation(@Nonnull ItemStack stack)
{
return ModelDynBucket.LOCATION;
}
@@ -22,6 +22,7 @@ package net.minecraftforge.client.model;
import java.util.Collection;
import java.util.List;
import javax.annotation.Nonnull;
import javax.vecmath.Matrix4f;
import net.minecraft.block.state.IBlockState;
@@ -177,6 +178,7 @@ public final class MultiLayerModel implements IModelCustomData
return builder.build();
}
@Nonnull
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand)
{
@@ -67,10 +67,10 @@ public final class AnimationItemOverrideList extends ItemOverrideList
@Override
public IBakedModel handleItemState(@Nonnull IBakedModel originalModel, @Nonnull ItemStack stack, @Nullable World world, @Nullable EntityLivingBase entity)
{
if(stack.hasCapability(net.minecraftforge.common.model.animation.CapabilityAnimation.ANIMATION_CAPABILITY, null))
IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
if (asm != null)
{
// TODO: caching?
IAnimationStateMachine asm = stack.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
if(world == null && entity != null)
{
world = entity.world;
@@ -44,6 +44,7 @@ import net.minecraftforge.common.animation.IEventHandler;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.animation.CapabilityAnimation;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.opengl.GL11;
@@ -67,12 +68,12 @@ public class AnimationModelBase<T extends Entity> extends ModelBase implements I
@Override
public void render(Entity entity, float limbSwing, float limbSwingSpeed, float timeAlive, float yawHead, float rotationPitch, float scale)
{
if(!(entity.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)))
IAnimationStateMachine capability = entity.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
if (capability == null)
{
return;
}
Pair<IModelState, Iterable<Event>> pair = entity.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(timeAlive / 20);
Pair<IModelState, Iterable<Event>> pair = capability.apply(timeAlive / 20);
handleEvents((T)entity, timeAlive / 20, pair.getRight());
IModel model = ModelLoaderRegistry.getModelOrMissing(modelLocation);
IBakedModel bakedModel = model.bake(pair.getLeft(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
@@ -32,11 +32,14 @@ import net.minecraftforge.common.animation.Event;
import net.minecraftforge.common.animation.IEventHandler;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.animation.CapabilityAnimation;
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.Properties;
import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nonnull;
/**
* Generic TileEntitySpecialRenderer that works with the Forge model system and animations.
*/
@@ -44,7 +47,7 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
{
protected static BlockRendererDispatcher blockRenderer;
public void renderTileEntityFast(T te, double x, double y, double z, float partialTick, int breakStage, VertexBuffer renderer)
public void renderTileEntityFast(@Nonnull T te, double x, double y, double z, float partialTick, int breakStage, @Nonnull VertexBuffer renderer)
{
if(!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null))
{
@@ -64,16 +67,20 @@ public class AnimationTESR<T extends TileEntity> extends FastTESR<T> implements
if(exState.getUnlistedNames().contains(Properties.AnimationProperty))
{
float time = Animation.getWorldTime(getWorld(), partialTick);
Pair<IModelState, Iterable<Event>> pair = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
handleEvents(te, time, pair.getRight());
IAnimationStateMachine capability = te.getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null);
if (capability != null)
{
Pair<IModelState, Iterable<Event>> pair = capability.apply(time);
handleEvents(te, time, pair.getRight());
// TODO: caching?
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());
// TODO: caching?
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
renderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, renderer, false);
}
}
}
}
@@ -31,10 +31,12 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.tileentity.TileEntity;
import javax.annotation.Nonnull;
public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRenderer<T>
{
@Override
public final void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage)
public final void renderTileEntityAt(@Nonnull T te, double x, double y, double z, float partialTicks, int destroyStage)
{
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer VertexBuffer = tessellator.getBuffer();
@@ -64,5 +66,5 @@ public abstract class FastTESR<T extends TileEntity> extends TileEntitySpecialRe
}
@Override
public abstract void renderTileEntityFast(T te, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer VertexBuffer);
public abstract void renderTileEntityFast(@Nonnull T te, double x, double y, double z, float partialTicks, int destroyStage, @Nonnull VertexBuffer VertexBuffer);
}
@@ -29,6 +29,7 @@ import java.util.Map;
import java.util.NoSuchElementException;
import java.util.TreeMap;
import javax.annotation.Nullable;
import javax.vecmath.AxisAngle4f;
import javax.vecmath.Matrix4f;
import javax.vecmath.Quat4f;
@@ -515,6 +516,7 @@ public class ModelBlockAnimation
}
}
@Nullable
public TRSRTransformation getPartTransform(IModelState state, BlockPart part, int i)
{
ImmutableCollection<MBJointWeight> infos = getJoint(i);
@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector3f;
@@ -168,6 +169,7 @@ public enum B3DLoader implements ICustomModelLoader
private final int frame;
private final int nextFrame;
private final float progress;
@Nullable
private final IModelState parent;
public B3DState(Animation animation, int frame)
@@ -185,7 +187,7 @@ public enum B3DLoader implements ICustomModelLoader
this(animation, frame, nextFrame, progress, null);
}
public B3DState(Animation animation, int frame, int nextFrame, float progress, IModelState parent)
public B3DState(Animation animation, int frame, int nextFrame, float progress, @Nullable IModelState parent)
{
this.animation = animation;
this.frame = frame;
@@ -194,7 +196,8 @@ public enum B3DLoader implements ICustomModelLoader
this.parent = getParent(parent);
}
private IModelState getParent(IModelState parent)
@Nullable
private IModelState getParent(@Nullable IModelState parent)
{
if (parent == null) return null;
else if (parent instanceof B3DState) return ((B3DState)parent).parent;
@@ -221,6 +224,7 @@ public enum B3DLoader implements ICustomModelLoader
return progress;
}
@Nullable
public IModelState getParent()
{
return parent;
@@ -33,6 +33,7 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.vecmath.Matrix3f;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector2f;
@@ -1068,7 +1069,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
// public float[] minUVBounds = new float[] {0.0f, 0.0f};
// public float[] maxUVBounds = new float[] {1.0f, 1.0f};
public Group(String name, LinkedHashSet<Face> faces)
public Group(String name, @Nullable LinkedHashSet<Face> faces)
{
this.name = name != null ? name : DEFAULT_NAME;
this.faces = faces == null ? new LinkedHashSet<Face>() : faces;
@@ -1129,6 +1130,7 @@ public class OBJModel implements IRetexturableModel, IModelCustomData
for (String s : visibleGroups) this.visibilityMap.put(s, visibility);
}
@Nullable
public IModelState getParent(IModelState parent)
{
if (parent == null) return null;
@@ -22,6 +22,7 @@ package net.minecraftforge.client.settings;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.util.IntHashMap;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
@@ -38,6 +39,7 @@ public class KeyBindingMap
}
}
@Nullable
public KeyBinding lookupActive(int keyCode)
{
KeyModifier activeModifier = KeyModifier.getActiveModifier();
@@ -52,6 +54,7 @@ public class KeyBindingMap
return getBinding(keyCode, KeyModifier.NONE);
}
@Nullable
private KeyBinding getBinding(int keyCode, KeyModifier keyModifier)
{
Collection<KeyBinding> bindings = map.get(keyModifier).lookup(keyCode);
@@ -32,6 +32,8 @@ import java.util.Set;
import net.minecraft.stats.Achievement;
import javax.annotation.Nullable;
public class AchievementPage
{
private String name;
@@ -83,6 +85,7 @@ public class AchievementPage
* @param name The page's name.
* @return the achievement page with the given name or null if no such page
*/
@Nullable
public static AchievementPage getAchievementPage(String name)
{
for (AchievementPage page : achievementPages)
@@ -33,6 +33,8 @@ import net.minecraft.world.biome.BiomeProvider;
import net.minecraft.world.gen.structure.MapGenVillage;
import net.minecraftforge.common.util.EnumHelper;
import javax.annotation.Nullable;
public class BiomeManager
{
private static TrackedList<BiomeEntry>[] biomes = setupBiomes();
@@ -154,6 +156,7 @@ public class BiomeManager
}
}
@Nullable
public static ImmutableList<BiomeEntry> getBiomes(BiomeType type)
{
int idx = type.ordinal();
@@ -52,6 +52,8 @@ import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
import javax.annotation.Nullable;
public class DimensionManager
{
private static Hashtable<Integer, WorldServer> worlds = new Hashtable<Integer, WorldServer>();
@@ -170,7 +172,7 @@ public class DimensionManager
return worlds.keySet().toArray(new Integer[worlds.size()]); //Only loaded dims, since usually used to cycle through loaded worlds
}
public static void setWorld(int id, WorldServer world, MinecraftServer server)
public static void setWorld(int id, @Nullable WorldServer world, MinecraftServer server)
{
if (world != null)
{
@@ -357,7 +359,7 @@ public class DimensionManager
return dimMap;
}
public static void loadDimensionDataMap(NBTTagCompound compoundTag)
public static void loadDimensionDataMap(@Nullable NBTTagCompound compoundTag)
{
dimensionMap.clear();
if (compoundTag == null)
@@ -387,6 +389,7 @@ public class DimensionManager
* Return the current root directory for the world save. Accesses getSaveHandler from the overworld
* @return the root directory of the save
*/
@Nullable
public static File getCurrentSaveRootDirectory()
{
if (DimensionManager.getWorld(0) != null)
@@ -139,7 +139,7 @@ public class ForgeChunkManager
@Override
public Chunk apply(@Nullable ChunkPos input)
{
return world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos);
return input == null ? null : world.getChunkFromChunkCoords(input.chunkXPos, input.chunkZPos);
}
}));
world.theProfiler.endStartSection("regularChunkLoading");
@@ -687,6 +687,7 @@ public class ForgeChunkManager
return playerTicketLength - playerTickets.get(username).size();
}
@Nullable
public static Ticket requestPlayerTicket(Object mod, String player, World world, Type type)
{
ModContainer mc = getContainer(mod);
@@ -713,6 +714,7 @@ public class ForgeChunkManager
* @param type The type of ticket
* @return A ticket with which to register chunks for loading, or null if no further tickets are available
*/
@Nullable
public static Ticket requestTicket(Object mod, World world, Type type)
{
ModContainer container = getContainer(mod);
@@ -966,6 +968,7 @@ public class ForgeChunkManager
}
}
@Nullable
public static Chunk fetchDormantChunk(long coords, World world)
{
Cache<Long, Chunk> cache = dormantChunkCache.get(world);
@@ -1110,6 +1113,7 @@ public class ForgeChunkManager
return list;
}
@Nullable
public static ConfigCategory getConfigFor(Object mod)
{
ModContainer container = getContainer(mod);
@@ -552,7 +552,7 @@ public class ForgeHooks
return (MinecraftForge.EVENT_BUS.post(event) ? null : new float[]{event.getDistance(), event.getDamageMultiplier()});
}
public static int getLootingLevel(Entity target, Entity killer, DamageSource cause)
public static int getLootingLevel(Entity target, @Nullable Entity killer, DamageSource cause)
{
int looting = 0;
if (killer instanceof EntityLivingBase)
@@ -619,6 +619,7 @@ public class ForgeHooks
MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity));
}
@Nullable
public static EntityItem onPlayerTossEvent(@Nonnull EntityPlayer player, @Nonnull ItemStack item, boolean includeName)
{
player.captureDrops = true;
@@ -649,6 +650,7 @@ public class ForgeHooks
return world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos);
}
@Nullable
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
{
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
@@ -793,7 +795,7 @@ public class ForgeHooks
return event.isCanceled() ? -1 : event.getExpToDrop();
}
public static EnumActionResult onPlaceItemIntoWorld(@Nonnull ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
public static EnumActionResult onPlaceItemIntoWorld(@Nonnull ItemStack itemstack, @Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ, @Nonnull EnumHand hand)
{
// handle all placement events here
int meta = itemstack.getItemDamage();
@@ -896,7 +898,7 @@ public class ForgeHooks
return false;
}
public static float onAnvilRepair(EntityPlayer player, ItemStack output, ItemStack left, ItemStack right)
public static float onAnvilRepair(EntityPlayer player, @Nonnull ItemStack output, @Nonnull ItemStack left, @Nonnull ItemStack right)
{
AnvilRepairEvent e = new AnvilRepairEvent(player, left, right, output);
MinecraftForge.EVENT_BUS.post(e);
@@ -1009,6 +1011,7 @@ public class ForgeHooks
return !event.isCanceled();
}
@Nullable
public static RayTraceResult rayTraceEyes(EntityLivingBase entity, double length)
{
Vec3d startPos = new Vec3d(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ);
@@ -1016,6 +1019,7 @@ public class ForgeHooks
return entity.world.rayTraceBlocks(startPos, endPos);
}
@Nullable
public static Vec3d rayTraceEyeHitVec(EntityLivingBase entity, double length)
{
RayTraceResult git = rayTraceEyes(entity, length);
@@ -1085,6 +1089,8 @@ public class ForgeHooks
return ctx;
}
@Nullable
public static LootTable loadLootTable(Gson gson, ResourceLocation name, String data, boolean custom)
{
Deque<LootTableContext> que = lootContext.get();
@@ -1140,7 +1146,7 @@ public class ForgeHooks
public String validateEntryName(@Nullable String name)
{
if (!this.entryNames.contains(name))
if (name != null && !this.entryNames.contains(name))
{
this.entryNames.add(name);
return name;
@@ -94,6 +94,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import javax.annotation.Nullable;
public class ForgeModContainer extends DummyModContainer implements WorldAccessContainer
{
public static final String VERSION_CHECK_CAT = "version_checking";
@@ -541,6 +543,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
@Override
@Nullable
public Certificate getSigningCertificate()
{
Certificate[] certificates = getClass().getProtectionDomain().getCodeSource().getCertificates();
@@ -47,6 +47,8 @@ import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.versioning.ComparableVersion;
import javax.annotation.Nullable;
public class ForgeVersion
{
// This is Forge's Mod Id, used for the ForgeModContainer and resource locations
@@ -93,6 +95,7 @@ public class ForgeVersion
return getResult(ForgeModContainer.getInstance()).status;
}
@Nullable
public static String getTarget()
{
CheckResult res = getResult(ForgeModContainer.getInstance());
@@ -159,15 +162,17 @@ public class ForgeVersion
public static class CheckResult
{
public final Status status;
@Nullable
public final ComparableVersion target;
public final Map<ComparableVersion, String> changes;
@Nullable
public final String url;
private CheckResult(Status status, ComparableVersion target, Map<ComparableVersion, String> changes, String url)
private CheckResult(Status status, @Nullable ComparableVersion target, @Nullable Map<ComparableVersion, String> changes, @Nullable String url)
{
this.status = status;
this.target = target;
this.changes = changes == null ? null : Collections.unmodifiableMap(changes);
this.changes = changes == null ? Collections.<ComparableVersion, String>emptyMap() : Collections.unmodifiableMap(changes);
this.url = url;
}
}
@@ -35,6 +35,8 @@ import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import javax.annotation.Nullable;
/**
* Various implementations of ITimeValue.
*/
@@ -291,12 +293,13 @@ public final class TimeValues
private final ThreadLocal<Function<String, ITimeValue>> valueResolver = new ThreadLocal<Function<String, ITimeValue>>();
public void setValueResolver(Function<String, ITimeValue> valueResolver)
public void setValueResolver(@Nullable Function<String, ITimeValue> valueResolver)
{
this.valueResolver.set(valueResolver);
}
@SuppressWarnings("unchecked")
@Nullable
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
{
if(type.getRawType() != ITimeValue.class)
@@ -24,8 +24,9 @@ import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull;
public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe {
public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe
{
@Nonnull
private final ItemStack input;
private final T ingredient;
private final ItemStack output;
@@ -30,18 +30,19 @@ public interface IBrewingRecipe {
* being the item that goes in one of the three bottom slots of the brewing
* stand (e.g: water bottle)
*/
public boolean isInput(@Nonnull ItemStack input);
boolean isInput(@Nonnull ItemStack input);
/**
* Returns true if the passed ItemStack is an ingredient for this recipe.
* "Ingredient" being the item that goes in the top slot of the brewing
* stand (e.g: nether wart)
*/
public boolean isIngredient(@Nonnull ItemStack ingredient);
boolean isIngredient(@Nonnull ItemStack ingredient);
/**
* Returns the output when the passed input is brewed with the passed
* ingredient. Null if invalid input or ingredient.
* ingredient. Empty if invalid input or ingredient.
*/
public ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient);
@Nonnull
ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient);
}
@@ -58,6 +58,7 @@ public class VanillaBrewingRecipe implements IBrewingRecipe {
* or if the new potion is a splash potion when the old one wasn't.
*/
@Override
@Nonnull
public ItemStack getOutput(@Nonnull ItemStack input, @Nonnull ItemStack ingredient)
{
if (!input.isEmpty() && !ingredient.isEmpty() && isIngredient(ingredient))
@@ -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();
@@ -21,6 +21,7 @@ package net.minecraftforge.common.model;
import java.util.EnumMap;
import javax.annotation.Nullable;
import javax.vecmath.AxisAngle4f;
import javax.vecmath.Matrix3f;
import javax.vecmath.Matrix4f;
@@ -78,7 +79,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
}
}
public TRSRTransformation(Vector3f translation, Quat4f leftRot, Vector3f scale, Quat4f rightRot)
public TRSRTransformation(@Nullable Vector3f translation, @Nullable Quat4f leftRot, @Nullable Vector3f scale, @Nullable Quat4f rightRot)
{
this.matrix = mul(translation, leftRot, scale, rightRot);
this.translation = translation != null ? translation : new Vector3f();
@@ -260,7 +261,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
);
}
public static Matrix4f mul(Vector3f translation, Quat4f leftRot, Vector3f scale, Quat4f rightRot)
public static Matrix4f mul(@Nullable Vector3f translation, @Nullable Quat4f leftRot, @Nullable Vector3f scale, @Nullable Quat4f rightRot)
{
Matrix4f res = new Matrix4f(), t = new Matrix4f();
res.setIdentity();
@@ -57,6 +57,8 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.gson.annotations.SerializedName;
import javax.annotation.Nullable;
public final class AnimationStateMachine implements IAnimationStateMachine
{
private final ImmutableMap<String, ITimeValue> parameters;
@@ -310,6 +312,7 @@ public final class AnimationStateMachine implements IAnimationStateMachine
INSTANCE;
@SuppressWarnings("unchecked")
@Nullable
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
{
if(type.getRawType() != ImmutableMultimap.class || !(type.getType() instanceof ParameterizedType))
@@ -53,6 +53,8 @@ import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import javax.annotation.Nullable;
/**
* Various implementations of IClip, and utility methods.
*/
@@ -426,12 +428,13 @@ public final class Clips
private final ThreadLocal<Function<String, IClip>> clipResolver = new ThreadLocal<Function<String, IClip>>();
public void setClipResolver(Function<String, IClip> clipResolver)
public void setClipResolver(@Nullable Function<String, IClip> clipResolver)
{
this.clipResolver.set(clipResolver);
}
@SuppressWarnings("unchecked")
@Nullable
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)
{
if(type.getRawType() != IClip.class)
@@ -37,6 +37,9 @@ import com.google.common.collect.ImmutableTable;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ExtendedBlockState extends BlockStateContainer
{
private final ImmutableSet<IUnlistedProperty<?>> unlistedProperties;
@@ -68,7 +71,8 @@ public class ExtendedBlockState extends BlockStateContainer
}
@Override
protected StateImplementation createState(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties)
@Nonnull
protected StateImplementation createState(@Nonnull Block block, @Nonnull ImmutableMap<IProperty<?>, Comparable<?>> properties, @Nullable ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties)
{
if (unlistedProperties == null || unlistedProperties.isEmpty()) return super.createState(block, properties, unlistedProperties);
return new ExtendedStateImplementation(block, properties, unlistedProperties, null);
@@ -79,7 +83,7 @@ public class ExtendedBlockState extends BlockStateContainer
private final ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties;
private Map<Map<IProperty<?>, Comparable<?>>, BlockStateContainer.StateImplementation> normalMap;
protected ExtendedStateImplementation(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties, ImmutableTable<IProperty<?>, Comparable<?>, IBlockState> table)
protected ExtendedStateImplementation(Block block, ImmutableMap<IProperty<?>, Comparable<?>> properties, ImmutableMap<IUnlistedProperty<?>, Optional<?>> unlistedProperties, @Nullable ImmutableTable<IProperty<?>, Comparable<?>, IBlockState> table)
{
super(block, properties);
this.unlistedProperties = unlistedProperties;
@@ -87,7 +91,8 @@ public class ExtendedBlockState extends BlockStateContainer
}
@Override
public <T extends Comparable<T>, V extends T> IBlockState withProperty(IProperty<T> property, V value)
@Nonnull
public <T extends Comparable<T>, V extends T> IBlockState withProperty(@Nonnull IProperty<T> property, @Nonnull V value)
{
if (!this.getProperties().containsKey(property))
{
@@ -30,6 +30,8 @@ import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import javax.annotation.Nullable;
/**
* Represents a captured snapshot of a block which will not change
* automatically.
@@ -46,6 +48,7 @@ public class BlockSnapshot implements Serializable
private final int dimId;
private transient IBlockState replacedBlock;
private int flag;
@Nullable
private final NBTTagCompound nbt;
private transient World world;
private final ResourceLocation registryName;
@@ -73,7 +76,7 @@ public class BlockSnapshot implements Serializable
}
}
public BlockSnapshot(World world, BlockPos pos, IBlockState state, NBTTagCompound nbt)
public BlockSnapshot(World world, BlockPos pos, IBlockState state, @Nullable NBTTagCompound nbt)
{
this.setWorld(world);
this.dimId = world.provider.getDimension();
@@ -98,7 +101,7 @@ public class BlockSnapshot implements Serializable
/**
* Raw constructor designed for serialization usages.
*/
public BlockSnapshot(int dimension, BlockPos pos, String modId, String blockName, int meta, int flag, NBTTagCompound nbt)
public BlockSnapshot(int dimension, BlockPos pos, String modId, String blockName, int meta, int flag, @Nullable NBTTagCompound nbt)
{
this.dimId = dimension;
this.pos = pos.toImmutable();
@@ -322,6 +325,7 @@ public class BlockSnapshot implements Serializable
public void setReplacedBlock(IBlockState replacedBlock) { this.replacedBlock = replacedBlock; }
public int getFlag() { return flag; }
public void setFlag(int flag) { this.flag = flag; }
@Nullable
public NBTTagCompound getNbt() { return nbt; }
public void setWorld(World world) { this.world = world; }
public ResourceLocation getRegistryName() { return registryName; }
@@ -46,6 +46,8 @@ import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.Stronghold.Door;
import net.minecraftforge.classloading.FMLForgePlugin;
import javax.annotation.Nullable;
public class EnumHelper
{
private static Object reflectionFactory = null;
@@ -73,54 +75,67 @@ public class EnumHelper
{EnumRarity.class, TextFormatting.class, String.class}
};
@Nullable
public static EnumAction addAction(String name)
{
return addEnum(EnumAction.class, name);
}
@Nullable
public static ArmorMaterial addArmorMaterial(String name, String textureName, int durability, int[] reductionAmounts, int enchantability, SoundEvent soundOnEquip, float toughness)
{
return addEnum(ArmorMaterial.class, name, textureName, durability, reductionAmounts, enchantability, soundOnEquip, toughness);
}
@Nullable
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
return addEnum(EnumArt.class, name, tile, sizeX, sizeY, offsetX, offsetY);
}
@Nullable
public static EnumCreatureAttribute addCreatureAttribute(String name)
{
return addEnum(EnumCreatureAttribute.class, name);
}
@Nullable
public static EnumCreatureType addCreatureType(String name, Class<?> typeClass, int maxNumber, Material material, boolean peaceful, boolean animal)
{
return addEnum(EnumCreatureType.class, name, typeClass, maxNumber, material, peaceful, animal);
}
@Nullable
public static Door addDoor(String name)
{
return addEnum(Door.class, name);
}
@Nullable
public static EnumEnchantmentType addEnchantmentType(String name, Predicate<Item> delegate)
{
return addEnum(EnumEnchantmentType.class, name, delegate);
}
@Nullable
public static Sensitivity addSensitivity(String name)
{
return addEnum(Sensitivity.class, name);
}
@Nullable
public static RayTraceResult.Type addMovingObjectType(String name)
{
return addEnum(RayTraceResult.Type.class, name);
}
@Nullable
public static EnumSkyBlock addSkyBlock(String name, int lightValue)
{
return addEnum(EnumSkyBlock.class, name, lightValue);
}
@Nullable
public static SleepResult addStatus(String name)
{
return addEnum(SleepResult.class, name);
}
@Nullable
public static ToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability)
{
return addEnum(ToolMaterial.class, name, harvestLevel, maxUses, efficiency, damage, enchantability);
}
@Nullable
public static EnumRarity addRarity(String name, TextFormatting color, String displayName)
{
return addEnum(EnumRarity.class, name, color, displayName);
@@ -164,16 +179,20 @@ public class EnumHelper
return newConstructorAccessor.invoke(reflectionFactory, enumClass.getDeclaredConstructor(parameterTypes));
}
private static < T extends Enum<? >> T makeEnum(Class<T> enumClass, String value, int ordinal, Class<?>[] additionalTypes, Object[] additionalValues) throws Exception
private static < T extends Enum<? >> T makeEnum(Class<T> enumClass, @Nullable String value, int ordinal, Class<?>[] additionalTypes, @Nullable Object[] additionalValues) throws Exception
{
Object[] params = new Object[additionalValues.length + 2];
int additionalParamsCount = additionalValues == null ? 0 : additionalValues.length;
Object[] params = new Object[additionalParamsCount + 2];
params[0] = value;
params[1] = ordinal;
System.arraycopy(additionalValues, 0, params, 2, additionalValues.length);
if (additionalValues != null)
{
System.arraycopy(additionalValues, 0, params, 2, additionalValues.length);
}
return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[] {params}));
}
public static void setFailsafeFieldValue(Field field, Object target, Object value) throws Exception
public static void setFailsafeFieldValue(Field field, @Nullable Object target, @Nullable Object value) throws Exception
{
field.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
@@ -202,12 +221,14 @@ public class EnumHelper
blankField(enumClass, "enumConstants");
}
@Nullable
private static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Object... paramValues)
{
setup();
return addEnum(commonTypes, enumType, enumName, paramValues);
}
@Nullable
protected static <T extends Enum<? >> T addEnum(Class<?>[][] map, Class<T> enumType, String enumName, Object... paramValues)
{
for (Class<?>[] lookup : map)
@@ -231,13 +252,15 @@ public class EnumHelper
addEnum(true, enumType, null, paramTypes, (Object[])null);
}
@Nullable
public static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Class<?>[] paramTypes, Object... paramValues)
{
return addEnum(false, enumType, enumName, paramTypes, paramValues);
}
@SuppressWarnings({ "unchecked", "serial" })
private static <T extends Enum<? >> T addEnum(boolean test, final Class<T> enumType, String enumName, final Class<?>[] paramTypes, Object[] paramValues)
@Nullable
private static <T extends Enum<? >> T addEnum(boolean test, final Class<T> enumType, @Nullable String enumName, final Class<?>[] paramTypes, @Nullable Object[] paramValues)
{
if (!isSetup)
{
@@ -143,10 +143,10 @@ public class ForgeEventFactory
@Deprecated
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction)
{
return onPlayerBlockPlace(player, blockSnapshot, direction, null);
return onPlayerBlockPlace(player, blockSnapshot, direction, EnumHand.MAIN_HAND);
}
public static PlaceEvent onPlayerBlockPlace(EntityPlayer player, BlockSnapshot blockSnapshot, EnumFacing direction, @Nullable EnumHand hand)
public static PlaceEvent onPlayerBlockPlace(@Nonnull EntityPlayer player, @Nonnull BlockSnapshot blockSnapshot, @Nonnull EnumFacing direction, @Nonnull EnumHand hand)
{
IBlockState placedAgainst = blockSnapshot.getWorld().getBlockState(blockSnapshot.getPos().offset(direction.getOpposite()));
PlaceEvent event = new PlaceEvent(blockSnapshot, placedAgainst, player, hand);
@@ -223,6 +223,7 @@ public class ForgeEventFactory
return event.getDroppedExperience();
}
@Nullable
public static List<Biome.SpawnListEntry> getPotentialSpawns(WorldServer world, EnumCreatureType type, BlockPos pos, List<Biome.SpawnListEntry> oldList)
{
WorldEvent.PotentialSpawns event = new WorldEvent.PotentialSpawns(world, type, pos, oldList);
@@ -331,6 +332,7 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(new PlayerEvent.LoadFromFile(player, dir, uuidString));
}
@Nullable
public static ITextComponent onClientChat(byte type, ITextComponent message)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message);
@@ -362,7 +364,8 @@ public class ForgeEventFactory
return 0;
}
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
@Nullable
public static ActionResult<ItemStack> onBucketUse(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull ItemStack stack, @Nullable RayTraceResult target)
{
FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
@@ -543,27 +546,32 @@ public class ForgeEventFactory
return MinecraftForge.EVENT_BUS.post(new RenderBlockOverlayEvent(player, renderPartialTicks, type, block, pos));
}
@Nullable
public static CapabilityDispatcher gatherCapabilities(TileEntity tileEntity)
{
return gatherCapabilities(new AttachCapabilitiesEvent.TileEntity(tileEntity), null);
}
@Nullable
public static CapabilityDispatcher gatherCapabilities(Entity entity)
{
return gatherCapabilities(new AttachCapabilitiesEvent.Entity(entity), null);
}
@Nullable
public static CapabilityDispatcher gatherCapabilities(Item item, ItemStack stack, ICapabilityProvider parent)
{
return gatherCapabilities(new AttachCapabilitiesEvent.Item(item, stack), parent);
}
@Nullable
public static CapabilityDispatcher gatherCapabilities(World world, ICapabilityProvider parent)
{
return gatherCapabilities(new AttachCapabilitiesEvent.World(world), parent);
}
private static CapabilityDispatcher gatherCapabilities(AttachCapabilitiesEvent event, ICapabilityProvider parent)
@Nullable
private static CapabilityDispatcher gatherCapabilities(AttachCapabilitiesEvent<?> event, @Nullable ICapabilityProvider parent)
{
MinecraftForge.EVENT_BUS.post(event);
return event.getCapabilities().size() > 0 || parent != null ? new CapabilityDispatcher(event.getCapabilities(), parent) : null;
@@ -42,7 +42,7 @@ public class PotionBrewEvent extends Event
@Nonnull
public ItemStack getItem(int index)
{
if (index >= stacks.size()) return ItemStack.EMPTY;
if (index < 0 || index >= stacks.size()) return ItemStack.EMPTY;
return stacks.get(index);
}
@@ -24,6 +24,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.Event;
import javax.annotation.Nonnull;
/**
* Fired when the enchantment level is set for each of the three potential enchantments in the enchanting table.
* The {@link #level} is set to the vanilla value and can be modified by this event handler.
@@ -38,11 +40,12 @@ public class EnchantmentLevelSetEvent extends Event
private final BlockPos pos;
private final int enchantRow;
private final int power;
@Nonnull
private final ItemStack itemStack;
private final int originalLevel;
private int level;
public EnchantmentLevelSetEvent(World world, BlockPos pos, int enchantRow, int power, ItemStack itemStack, int level)
public EnchantmentLevelSetEvent(World world, BlockPos pos, int enchantRow, int power, @Nonnull ItemStack itemStack, int level)
{
this.world = world;
this.pos = pos;
@@ -98,6 +101,7 @@ public class EnchantmentLevelSetEvent extends Event
*
* @return the item being enchanted
*/
@Nonnull
public ItemStack getItem()
{
return itemStack;
@@ -25,6 +25,8 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import javax.annotation.Nonnull;
/**
* {@link LivingEquipmentChangeEvent} is fired when the Equipment of a Entity changes. <br>
* This event is fired whenever changes in Equipment are detected in {@link EntityLivingBase#onUpdate()}. <br>
@@ -47,7 +49,7 @@ public class LivingEquipmentChangeEvent extends LivingEvent
private final ItemStack from;
private final ItemStack to;
public LivingEquipmentChangeEvent(EntityLivingBase entity, EntityEquipmentSlot slot, ItemStack from, ItemStack to)
public LivingEquipmentChangeEvent(EntityLivingBase entity, EntityEquipmentSlot slot, @Nonnull ItemStack from, @Nonnull ItemStack to)
{
super(entity);
this.slot = slot;
@@ -56,6 +58,8 @@ public class LivingEquipmentChangeEvent extends LivingEvent
}
public EntityEquipmentSlot getSlot() { return this.slot; }
@Nonnull
public ItemStack getFrom() { return this.from; }
@Nonnull
public ItemStack getTo() { return this.to; }
}
@@ -33,13 +33,15 @@ import javax.annotation.Nonnull;
*/
public class AnvilRepairEvent extends PlayerEvent
{
@Nonnull
private final ItemStack left; // The left side of the input
@Nonnull
private final ItemStack right; // The right side of the input
@Nonnull
private final ItemStack output; // Set this to set the output stack
private float breakChance; // Anvil's chance to break (reduced by 1 durability) when this is complete. Default is 12% (0.12f)
public AnvilRepairEvent(EntityPlayer player, @Nonnull ItemStack left, @Nonnull ItemStack right, ItemStack output)
public AnvilRepairEvent(EntityPlayer player, @Nonnull ItemStack left, @Nonnull ItemStack right, @Nonnull ItemStack output)
{
super(player);
this.output = output;
@@ -53,18 +55,21 @@ public class AnvilRepairEvent extends PlayerEvent
* @return the output slot
*/
@Deprecated
@Nonnull
public ItemStack getLeft() { return output; }
/**
* Deprecated in favour of {@link #getIngredientInput()}} - this is actually the first input slot of the anvil
* @return the first input slot
*/
@Deprecated
@Nonnull
public ItemStack getRight() { return left; }
/**
* Deprecated in favour of {@link #getItemResult()} - this is actually the second input slot of the anvil
* @return the second input slot
*/
@Deprecated
@Nonnull
public ItemStack getOutput() { return right; }
/**
@@ -27,6 +27,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This event is fired when a player attempts to use a Empty bucket, it
@@ -44,11 +45,12 @@ public class FillBucketEvent extends PlayerEvent
private final ItemStack current;
private final World world;
@Nullable
private final RayTraceResult target;
private ItemStack result;
public FillBucketEvent(EntityPlayer player, @Nonnull ItemStack current, World world, RayTraceResult target)
public FillBucketEvent(EntityPlayer player, @Nonnull ItemStack current, World world, @Nullable RayTraceResult target)
{
super(player);
this.current = current;
@@ -59,6 +61,7 @@ public class FillBucketEvent extends PlayerEvent
@Nonnull
public ItemStack getEmptyBucket() { return this.current; }
public World getWorld(){ return this.world; }
@Nullable
public RayTraceResult getTarget() { return this.target; }
@Nonnull
public ItemStack getFilledBucket() { return this.result; }
@@ -47,9 +47,10 @@ public class PlayerInteractEvent extends PlayerEvent
{
private final EnumHand hand;
private final BlockPos pos;
@Nullable
private final EnumFacing face;
private PlayerInteractEvent(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face)
private PlayerInteractEvent(EntityPlayer player, EnumHand hand, BlockPos pos, @Nullable EnumFacing face)
{
super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!"));
this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!");
@@ -40,6 +40,7 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result;
import com.google.common.collect.ImmutableList;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class BlockEvent extends Event
@@ -171,7 +172,6 @@ public class BlockEvent extends Event
public static class PlaceEvent extends BlockEvent
{
private final EntityPlayer player;
private final ItemStack itemInHand;
private final BlockSnapshot blockSnapshot;
private final IBlockState placedBlock;
private final IBlockState placedAgainst;
@@ -180,30 +180,29 @@ public class BlockEvent extends Event
@Deprecated
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player)
{
this(blockSnapshot, placedAgainst, player, null);
this(blockSnapshot, placedAgainst, player, EnumHand.MAIN_HAND);
}
public PlaceEvent(BlockSnapshot blockSnapshot, IBlockState placedAgainst, EntityPlayer player, @Nullable EnumHand hand) {
public PlaceEvent(@Nonnull BlockSnapshot blockSnapshot, @Nonnull IBlockState placedAgainst, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) {
super(blockSnapshot.getWorld(), blockSnapshot.getPos(), blockSnapshot.getCurrentBlock());
this.player = player;
this.itemInHand = player.getHeldItem(hand != null ? hand : EnumHand.MAIN_HAND);
this.blockSnapshot = blockSnapshot;
this.placedBlock = blockSnapshot.getCurrentBlock();
this.placedAgainst = placedAgainst;
this.hand = hand;
if (DEBUG)
{
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ][Hand: %s]\n", getPlacedBlock(), placedAgainst, getItemInHand(), player, hand);
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ][Hand: %s]\n", getPlacedBlock(), placedAgainst, player.getHeldItem(hand), player, hand);
}
}
public EntityPlayer getPlayer() { return player; }
@Nullable
public ItemStack getItemInHand() { return itemInHand; }
@Nonnull
@Deprecated
public ItemStack getItemInHand() { return player.getHeldItem(hand); }
public BlockSnapshot getBlockSnapshot() { return blockSnapshot; }
public IBlockState getPlacedBlock() { return placedBlock; }
public IBlockState getPlacedAgainst() { return placedAgainst; }
@Nullable
public EnumHand getHand() { return hand; }
}
@@ -222,15 +221,15 @@ public class BlockEvent extends Event
@Deprecated
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player)
{
this(blockSnapshots, placedAgainst, player, null);
this(blockSnapshots, placedAgainst, player, EnumHand.MAIN_HAND);
}
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, IBlockState placedAgainst, EntityPlayer player, @Nullable EnumHand hand) {
public MultiPlaceEvent(@Nonnull List<BlockSnapshot> blockSnapshots, @Nonnull IBlockState placedAgainst, @Nonnull EntityPlayer player, @Nonnull EnumHand hand) {
super(blockSnapshots.get(0), placedAgainst, player, hand);
this.blockSnapshots = ImmutableList.copyOf(blockSnapshots);
if (DEBUG)
{
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, this.getItemInHand(), player);
System.out.printf("Created MultiPlaceEvent - [PlacedAgainst: %s ][ItemInHand: %s ][Player: %s ]\n", placedAgainst, player.getHeldItem(hand), player);
}
}
@@ -30,6 +30,7 @@ import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* This is a fluid block implementation which emulates vanilla Minecraft fluid behavior.
@@ -373,6 +374,7 @@ public class BlockFluidClassic extends BlockFluidBase
}
@Override
@Nullable
public FluidStack drain(World world, BlockPos pos, boolean doDrain)
{
if (!isSourceBlock(world, pos))
@@ -49,6 +49,8 @@ import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.registry.RegistryDelegate;
import javax.annotation.Nullable;
/**
* Handles Fluid registrations. Fluids MUST be registered in order to function.
*/
@@ -219,6 +221,7 @@ public abstract class FluidRegistry
return getFluidName(stack.getFluid());
}
@Nullable
public static FluidStack getFluidStack(String fluidName, int amount)
{
if (!fluids.containsKey(fluidName))
@@ -255,7 +258,9 @@ public abstract class FluidRegistry
{
if (Loader.instance().hasReachedState(LoaderState.PREINITIALIZATION))
{
FMLLog.getLogger().log(Level.ERROR, "Trying to activate the universal filled bucket too late. Call it statically in your Mods class. Mod: {}", Loader.instance().activeModContainer().getName());
ModContainer modContainer = Loader.instance().activeModContainer();
String modContainerName = modContainer == null ? null : modContainer.getName();
FMLLog.getLogger().log(Level.ERROR, "Trying to activate the universal filled bucket too late. Call it statically in your Mods class. Mod: {}", modContainerName);
}
else
{
@@ -22,9 +22,12 @@ package net.minecraftforge.fluids;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.registry.RegistryDelegate;
import javax.annotation.Nullable;
/**
* ItemStack substitute for Fluids.
*
@@ -74,15 +77,20 @@ public class FluidStack
* This provides a safe method for retrieving a FluidStack - if the Fluid is invalid, the stack
* will return as null.
*/
@Nullable
public static FluidStack loadFluidStackFromNBT(NBTTagCompound nbt)
{
if (nbt == null)
{
return null;
}
String fluidName = nbt.getString("FluidName");
if (!nbt.hasKey("FluidName", Constants.NBT.TAG_STRING))
{
return null;
}
if (fluidName == null || FluidRegistry.getFluid(fluidName) == null)
String fluidName = nbt.getString("FluidName");
if (FluidRegistry.getFluid(fluidName) == null)
{
return null;
}
@@ -137,7 +145,7 @@ public class FluidStack
* The FluidStack for comparison
* @return true if the Fluids (IDs and NBT Tags) are the same
*/
public boolean isFluidEqual(FluidStack other)
public boolean isFluidEqual(@Nullable FluidStack other)
{
return other != null && getFluid() == other.getFluid() && isFluidStackTagEqual(other);
}
@@ -150,7 +158,7 @@ public class FluidStack
/**
* Determines if the NBT Tags are equal. Useful if the FluidIDs are known to be equal.
*/
public static boolean areFluidStackTagsEqual(FluidStack stack1, FluidStack stack2)
public static boolean areFluidStackTagsEqual(@Nullable FluidStack stack1, @Nullable FluidStack stack2)
{
return stack1 == null && stack2 == null ? true : stack1 == null || stack2 == null ? false : stack1.isFluidStackTagEqual(stack2);
}
@@ -161,7 +169,7 @@ public class FluidStack
* @param other
* @return true if this FluidStack contains the other FluidStack (same fluid and >= amount)
*/
public boolean containsFluid(FluidStack other)
public boolean containsFluid(@Nullable FluidStack other)
{
return isFluidEqual(other) && amount >= other.amount;
}
@@ -237,6 +237,7 @@ public class FluidTank implements IFluidTank, IFluidHandler
* Use this method to bypass the restrictions from {@link #canDrainFluidType(FluidStack)}
* Meant for use by the owner of the tank when they have {@link #canDrain()} set to false}.
*/
@Nullable
public FluidStack drainInternal(FluidStack resource, boolean doDrain)
{
if (resource == null || !resource.isFluidEqual(getFluid()))
@@ -250,6 +251,7 @@ public class FluidTank implements IFluidTank, IFluidHandler
* Use this method to bypass the restrictions from {@link #canDrainFluidType(FluidStack)}
* Meant for use by the owner of the tank when they have {@link #canDrain()} set to false}.
*/
@Nullable
public FluidStack drainInternal(int maxDrain, boolean doDrain)
{
if (fluid == null || maxDrain <= 0)
@@ -343,9 +345,9 @@ public class FluidTank implements IFluidTank, IFluidHandler
*
* @see IFluidTankProperties#canDrainFluidType(FluidStack)
*/
public boolean canDrainFluidType(FluidStack fluid)
public boolean canDrainFluidType(@Nullable FluidStack fluid)
{
return canDrain();
return fluid != null && canDrain();
}
protected void onContentsChanged()
@@ -23,6 +23,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Implement this interface on Block classes which represent world-placeable Fluids.
@@ -60,6 +61,7 @@ public interface IFluidBlock
* If false, the drain will only be simulated.
* @return
*/
@Nullable
FluidStack drain(World world, BlockPos pos, boolean doDrain);
/**
@@ -48,6 +48,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* A universal bucket that can hold any liquid
@@ -103,7 +104,7 @@ public class UniversalBucket extends Item
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(@Nonnull Item itemIn, @Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems)
public void getSubItems(@Nonnull Item itemIn, @Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems)
{
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
{
@@ -276,6 +277,7 @@ public class UniversalBucket extends Item
return bucket;
}
@Nullable
public FluidStack getFluid(@Nonnull ItemStack container)
{
return FluidStack.loadFluidStackFromNBT(container.getTagCompound());
@@ -96,7 +96,7 @@ public class FluidBucketWrapper implements IFluidHandlerItem, ICapabilityProvide
}
}
protected void setFluid(Fluid fluid) {
protected void setFluid(@Nullable Fluid fluid) {
if (fluid == null)
{
container = new ItemStack(Items.BUCKET);
@@ -135,6 +135,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import javax.annotation.Nullable;
/**
* Handles primary communication from hooked code into the system
@@ -512,7 +514,7 @@ public class FMLClientHandler implements IFMLSidedHandler
}
@Override
public void showGuiScreen(Object clientGuiElement)
public void showGuiScreen(@Nullable Object clientGuiElement)
{
GuiScreen gui = (GuiScreen) clientGuiElement;
client.displayGuiScreen(gui);
@@ -813,6 +815,7 @@ public class FMLClientHandler implements IFMLSidedHandler
private static final ResourceLocation iconSheet = new ResourceLocation("fml:textures/gui/icons.png");
private static final CountDownLatch startupConnectionData = new CountDownLatch(1);
@Nullable
public String enhanceServerListEntry(ServerListEntryNormal serverListEntry, ServerData serverEntry, int x, int width, int y, int relativeMouseX, int relativeMouseY)
{
String tooltip;
@@ -29,6 +29,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import net.minecraft.client.Minecraft;
@@ -84,6 +85,7 @@ public class GuiModList extends GuiScreen
this.buttonID = buttonID;
}
@Nullable
public static SortType getTypeForButton(GuiButton button)
{
for (SortType t : values())
@@ -468,11 +470,12 @@ public class GuiModList extends GuiScreen
private class Info extends GuiScrollingList
{
@Nullable
private ResourceLocation logoPath;
private Dimension logoDims;
private List<ITextComponent> lines = null;
public Info(int width, List<String> lines, ResourceLocation logoPath, Dimension logoDims)
public Info(int width, List<String> lines, @Nullable ResourceLocation logoPath, Dimension logoDims)
{
super(GuiModList.this.getMinecraftInstance(),
width,
@@ -25,6 +25,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import javax.annotation.Nullable;
public interface IModGuiFactory {
/**
* Called when instantiated to initialize with the active minecraft instance.
@@ -85,6 +87,7 @@ public interface IModGuiFactory {
* @param element The element we wish to paint for
* @return The Handler for painting it
*/
@Nullable
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element);
/**
@@ -38,6 +38,8 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
@@ -731,12 +733,12 @@ public class SplashProgress
private final int frames;
private final int size;
public Texture(ResourceLocation location, ResourceLocation fallback)
public Texture(ResourceLocation location, @Nullable ResourceLocation fallback)
{
this(location, fallback, true);
}
public Texture(ResourceLocation location, ResourceLocation fallback, boolean allowRP)
public Texture(ResourceLocation location, @Nullable ResourceLocation fallback, boolean allowRP)
{
InputStream s = null;
try
@@ -881,14 +883,15 @@ public class SplashProgress
}
@Override
protected void bindTexture(ResourceLocation location)
protected void bindTexture(@Nonnull ResourceLocation location)
{
if(location != locationFontTexture) throw new IllegalArgumentException();
fontTexture.bind();
}
@Nonnull
@Override
protected IResource getResource(ResourceLocation location) throws IOException
protected IResource getResource(@Nonnull ResourceLocation location) throws IOException
{
DefaultResourcePack pack = Minecraft.getMinecraft().mcDefaultResourcePack;
return new SimpleResource(pack.getPackName(), location, pack.getInputStream(location), null, null);
@@ -920,7 +923,7 @@ public class SplashProgress
}
}
private static InputStream open(ResourceLocation loc, ResourceLocation fallback, boolean allowRP) throws IOException
private static InputStream open(ResourceLocation loc, @Nullable ResourceLocation fallback, boolean allowRP) throws IOException
{
if (!allowRP)
return mcPack.getInputStream(loc);
@@ -28,6 +28,8 @@ import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.config.GuiConfigEntries.IConfigEntry;
import net.minecraftforge.fml.client.config.GuiEditArrayEntries.IArrayEntry;
import javax.annotation.Nullable;
/**
* This class's main purpose is to provide the necessary objects for a sample Config GUI for FML, although
@@ -56,6 +58,7 @@ public class DummyConfigElement implements IConfigElement
protected boolean isListFixedLength = false;
protected int maxListLength = -1;
protected List<IConfigElement> childElements;
@Nullable
protected Class<? extends IConfigEntry> configEntryClass;
protected Class<? extends IArrayEntry> arrayEntryClass;
@@ -75,7 +78,7 @@ public class DummyConfigElement implements IConfigElement
this(name, langKey, new ArrayList<IConfigElement>(), customListEntryClass);
}
public DummyCategoryElement(String name, String langKey, List<IConfigElement> childElements, Class<? extends IConfigEntry> customListEntryClass)
public DummyCategoryElement(String name, String langKey, List<IConfigElement> childElements, @Nullable Class<? extends IConfigEntry> customListEntryClass)
{
super(name, null, ConfigGuiType.CONFIG_CATEGORY, langKey);
this.childElements = childElements;
@@ -89,7 +92,7 @@ public class DummyConfigElement implements IConfigElement
*/
public static class DummyListElement extends DummyConfigElement
{
public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, int maxListLength, Pattern validStringPattern, Object minValue, Object maxValue)
public DummyListElement(String name, Object[] defaultValues, ConfigGuiType type, String langKey, boolean isListFixedLength, int maxListLength, @Nullable Pattern validStringPattern, @Nullable Object minValue, @Nullable Object maxValue)
{
super(name, null, type, langKey, minValue, maxValue);
this.defaultValues = defaultValues;
@@ -42,6 +42,8 @@ import net.minecraftforge.fml.common.eventhandler.Event.Result;
import org.lwjgl.input.Keyboard;
import javax.annotation.Nullable;
/**
* This class is the base GuiScreen for all config GUI screens. It can be extended by mods to provide the top-level config screen
* that will be called when the Config button is clicked from the Main Menu Mods list.
@@ -55,6 +57,7 @@ public class GuiConfig extends GuiScreen
*/
public final GuiScreen parentScreen;
public String title = "Config GUI";
@Nullable
public String titleLine2;
public final List<IConfigElement> configElements;
public final List<IConfigEntry> initEntries;
@@ -68,6 +71,7 @@ public class GuiConfig extends GuiScreen
* if any configElements were changed (includes child screens). If not defined, the events will be posted if the parent gui is null
* or if the parent gui is not an instance of GuiConfig.
*/
@Nullable
public final String configID;
public final boolean isWorldRunning;
public final boolean allRequireWorldRestart;
@@ -154,8 +158,8 @@ public class GuiConfig extends GuiScreen
* @param titleLine2 the desired title second line for this screen. Typically this is used to send the category name of the category
* currently being edited.
*/
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, String configID,
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, String titleLine2)
public GuiConfig(GuiScreen parentScreen, List<IConfigElement> configElements, String modID, @Nullable String configID,
boolean allRequireWorldRestart, boolean allRequireMcRestart, String title, @Nullable String titleLine2)
{
this.mc = Minecraft.getMinecraft();
this.parentScreen = parentScreen;
@@ -20,16 +20,17 @@
package net.minecraftforge.fml.client.config;
import net.minecraft.client.gui.GuiDisconnected;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import javax.annotation.Nullable;
public class GuiMessageDialog extends GuiDisconnected
{
protected String buttonText;
public GuiMessageDialog(GuiScreen nextScreen, String title, ITextComponent message, String buttonText)
public GuiMessageDialog(@Nullable GuiScreen nextScreen, String title, ITextComponent message, String buttonText)
{
super(nextScreen, title, message);
this.buttonText = buttonText;
@@ -22,6 +22,8 @@ package net.minecraftforge.fml.client.config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import javax.annotation.Nullable;
/**
* This class is blatantly stolen from iChunUtils with permission.
*
@@ -42,6 +44,7 @@ public class GuiSlider extends GuiButtonExt
public double maxValue = 5.0D;
public int precision = 1;
@Nullable
public ISlider parent = null;
public String suffix = "";
@@ -53,7 +56,7 @@ public class GuiSlider extends GuiButtonExt
this(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, null);
}
public GuiSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, ISlider par)
public GuiSlider(int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, @Nullable ISlider par)
{
super(id, xPos, yPos, width, height, prefix);
minValue = minVal;
@@ -36,7 +36,7 @@ import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;
/**
* This class provides several methods and constants used by the Config GUI classes.
@@ -210,14 +210,15 @@ public class GuiUtils
tessellator.draw();
}
private static ItemStack cachedTooltipStack;
@Nonnull
private static ItemStack cachedTooltipStack = ItemStack.EMPTY;
/**
* Must be called from {@code GuiScreen.renderToolTip} before {@code GuiScreen.drawHoveringText} is called.
*
* @param stack The stack for which a tooltip is about to be drawn.
*/
public static void preItemToolTip(ItemStack stack)
public static void preItemToolTip(@Nonnull ItemStack stack)
{
cachedTooltipStack = stack;
}
@@ -227,7 +228,7 @@ public class GuiUtils
*/
public static void postItemToolTip()
{
cachedTooltipStack = null;
cachedTooltipStack = ItemStack.EMPTY;
}
/**
@@ -255,8 +256,7 @@ public class GuiUtils
*
* @see #drawHoveringText(List, int, int, int, int, int, FontRenderer)
*/
public static void drawHoveringText(@Nullable final ItemStack stack, List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight,
int maxTextWidth, FontRenderer font)
public static void drawHoveringText(@Nonnull final ItemStack stack, List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font)
{
if (!textLines.isEmpty())
{
@@ -22,6 +22,8 @@ package net.minecraftforge.fml.client.event;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
import javax.annotation.Nullable;
/**
* These events are posted from the GuiConfig screen when the done button is pressed. The events are only posted
* if the parent screen is not an instance of GuiConfig or if the configID field has been set for
@@ -39,9 +41,10 @@ public class ConfigChangedEvent extends Event
private final String modID;
private final boolean isWorldRunning;
private final boolean requiresMcRestart;
@Nullable
private final String configID;
public ConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
public ConfigChangedEvent(String modID, @Nullable String configID, boolean isWorldRunning, boolean requiresMcRestart)
{
this.modID = modID;
this.configID = configID;
@@ -76,6 +79,7 @@ public class ConfigChangedEvent extends Event
/**
* A String identifier for this ConfigChangedEvent.
*/
@Nullable
public String getConfigID()
{
return configID;
@@ -92,7 +96,7 @@ public class ConfigChangedEvent extends Event
*/
public static class OnConfigChangedEvent extends ConfigChangedEvent
{
public OnConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
public OnConfigChangedEvent(String modID, @Nullable String configID, boolean isWorldRunning, boolean requiresMcRestart)
{
super(modID, configID, isWorldRunning, requiresMcRestart);
}
@@ -104,7 +108,7 @@ public class ConfigChangedEvent extends Event
*/
public static class PostConfigChangedEvent extends ConfigChangedEvent
{
public PostConfigChangedEvent(String modID, String configID, boolean isWorldRunning, boolean requiresMcRestart)
public PostConfigChangedEvent(String modID, @Nullable String configID, boolean isWorldRunning, boolean requiresMcRestart)
{
super(modID, configID, isWorldRunning, requiresMcRestart);
}
@@ -43,7 +43,7 @@ public class CertificateHelper {
}
catch (Exception e)
{
return null;
return "CERTIFICATE FINGERPRINT EXCEPTION";
}
}
@@ -58,7 +58,7 @@ public class CertificateHelper {
}
catch (Exception e)
{
return null;
return "CERTIFICATE FINGERPRINT EXCEPTION";
}
}
@@ -34,6 +34,8 @@ import net.minecraftforge.fml.common.versioning.VersionRange;
import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import javax.annotation.Nullable;
public class DummyModContainer implements ModContainer
{
private ModMetadata md;
@@ -164,6 +166,7 @@ public class DummyModContainer implements ModContainer
}
@Override
@Nullable
public Certificate getSigningCertificate()
{
return null;
@@ -81,6 +81,8 @@ import com.google.common.collect.MapMaker;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import javax.annotation.Nullable;
/**
* The main class for non-obfuscated hook handling code
@@ -709,6 +711,7 @@ public class FMLCommonHandler
* @param inputstream Input stream containing the lang file.
* @return A new InputStream that vanilla uses to load normal Lang files, Null if this is a 'enhanced' file and loading is done.
*/
@Nullable
public InputStream loadLanguage(Map<String, String> table, InputStream inputstream) throws IOException
{
byte[] data = IOUtils.toByteArray(inputstream);
@@ -52,6 +52,8 @@ import org.apache.logging.log4j.Level;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import javax.annotation.Nullable;
/**
* @author cpw
*
@@ -343,6 +345,7 @@ public final class FMLContainer extends DummyModContainer implements WorldAccess
@Override
@Nullable
public Certificate getSigningCertificate()
{
Certificate[] certificates = getClass().getProtectionDomain().getCodeSource().getCertificates();
@@ -77,6 +77,8 @@ import com.google.common.collect.Sets;
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import javax.annotation.Nullable;
public class FMLModContainer implements ModContainer
{
private Object modInstance;
@@ -280,6 +282,7 @@ public class FMLModContainer implements ModContainer
}
}
@Nullable
public Properties searchForVersionProperties()
{
try
@@ -391,6 +394,7 @@ public class FMLModContainer implements ModContainer
}
}
@Nullable
@SuppressWarnings("unchecked")
private Method gatherAnnotations(Class<?> clazz) throws Exception
{
@@ -31,6 +31,8 @@ import net.minecraftforge.fml.common.versioning.VersionRange;
import com.google.common.eventbus.EventBus;
import javax.annotation.Nullable;
public class InjectedModContainer implements ModContainer
{
private File source;
@@ -150,6 +152,7 @@ public class InjectedModContainer implements ModContainer
return wrappedContainer.acceptableMinecraftVersionRange();
}
@Nullable
public WorldAccessContainer getWrappedWorldAccessContainer()
{
if (wrappedContainer instanceof WorldAccessContainer)
@@ -163,6 +166,7 @@ public class InjectedModContainer implements ModContainer
}
@Override
@Nullable
public Certificate getSigningCertificate()
{
return wrappedContainer.getSigningCertificate();
@@ -55,6 +55,8 @@ import com.google.common.eventbus.Subscribe;
import com.google.common.eventbus.SubscriberExceptionHandler;
import com.google.common.eventbus.SubscriberExceptionContext;
import javax.annotation.Nullable;
public class LoadController
{
private Loader loader;
@@ -198,12 +200,13 @@ public class LoadController
}
@Nullable
public ModContainer activeContainer()
{
return activeContainer != null ? activeContainer : findActiveContainerFromStack();
}
void forceActiveContainer(ModContainer container)
void forceActiveContainer(@Nullable ModContainer container)
{
activeContainer = container;
}
@@ -237,7 +240,7 @@ public class LoadController
}
}
activeContainer = mc;
stateEvent.applyModContainer(activeContainer());
stateEvent.applyModContainer(mc);
ThreadContext.put("mod", modId);
FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
eventChannels.get(modId).post(stateEvent);
@@ -358,6 +361,7 @@ public class LoadController
this.state = newState;
}
@Nullable
private ModContainer findActiveContainerFromStack()
{
for (Class<?> c : getCallingStack())
@@ -90,6 +90,8 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import javax.annotation.Nullable;
/**
* The loader class performs the actual loading of the mod code from disk.
*
@@ -887,6 +889,7 @@ public class Loader
return getModObjectList().inverse();
}
@Nullable
public ModContainer activeModContainer()
{
return modController != null ? modController.activeContainer() : null;
@@ -1162,7 +1165,7 @@ public class Loader
return modController != null ? modController.getState() : LoaderState.NOINIT;
}
public void setActiveModContainer(ModContainer container)
public void setActiveModContainer(@Nullable ModContainer container)
{
this.modController.forceActiveContainer(container);
}
@@ -41,13 +41,15 @@ import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import javax.annotation.Nullable;
public class MetadataCollection
{
private String modListVersion;
private ModMetadata[] modList;
private Map<String, ModMetadata> metadatas = Maps.newHashMap();
public static MetadataCollection from(InputStream inputStream, String sourceName)
public static MetadataCollection from(@Nullable InputStream inputStream, String sourceName)
{
if (inputStream == null)
{
@@ -28,6 +28,8 @@ import net.minecraftforge.fml.common.versioning.VersionRange;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nullable;
public class MinecraftDummyContainer extends DummyModContainer
{
@@ -65,6 +67,7 @@ public class MinecraftDummyContainer extends DummyModContainer
}
@Override
@Nullable
public Certificate getSigningCertificate()
{
if (FMLLaunchHandler.side() != Side.CLIENT)
@@ -76,7 +79,7 @@ public class MinecraftDummyContainer extends DummyModContainer
Certificate[] certificates = cbr.getProtectionDomain().getCodeSource().getCertificates();
return certificates != null ? certificates[0] : null;
}
catch (Exception e){} // Errors don't matter just return null.
catch (Exception ignored){} // Errors don't matter just return null.
return null;
}
}
@@ -32,6 +32,8 @@ import net.minecraftforge.fml.common.versioning.VersionRange;
import com.google.common.collect.ImmutableMap;
import com.google.common.eventbus.EventBus;
import javax.annotation.Nullable;
/**
* The container that wraps around mods in the system.
* <p>
@@ -141,6 +143,7 @@ public interface ModContainer
VersionRange acceptableMinecraftVersionRange();
@Nullable
Certificate getSigningCertificate();
public static final Map<String,String> EMPTY_PROPERTIES = ImmutableMap.of();
@@ -34,6 +34,8 @@ import org.objectweb.asm.Type;
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import javax.annotation.Nullable;
public class ModContainerFactory
{
public static Map<Type, Constructor<? extends ModContainer>> modTypes = Maps.newHashMap();
@@ -58,6 +60,8 @@ public class ModContainerFactory
Throwables.propagate(e);
}
}
@Nullable
public ModContainer build(ASMModParser modParser, File modSource, ModCandidate container)
{
String className = modParser.getASMType().getClassName();
@@ -24,6 +24,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import net.minecraft.server.MinecraftServer;
import javax.annotation.Nullable;
public class StartupQuery {
// internal class/functionality, do not use
@@ -80,12 +82,13 @@ public class StartupQuery {
private static volatile boolean aborted = false;
private StartupQuery(String text, AtomicBoolean result)
private StartupQuery(String text, @Nullable AtomicBoolean result)
{
this.text = text;
this.result = result;
}
@Nullable
public Boolean getResult()
{
return result == null ? null : result.get();
@@ -159,6 +162,7 @@ public class StartupQuery {
}
private String text;
@Nullable
private AtomicBoolean result;
private CountDownLatch signal = new CountDownLatch(1);
private volatile boolean synchronous;
@@ -47,6 +47,8 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
import javax.annotation.Nullable;
public class ASMTransformerWrapper
{
private static final Map<String, String> wrapperModMap = Maps.newHashMap();
@@ -80,6 +82,7 @@ public class ASMTransformerWrapper
private static class ASMGenHandler extends URLStreamHandler
{
@Nullable
protected URLConnection openConnection(URL url) throws IOException
{
String file = url.getFile();
@@ -125,6 +128,7 @@ public class ASMTransformerWrapper
}
@Override
@Nullable
public Permission getPermission()
{
return null;
@@ -54,6 +54,8 @@ import com.google.common.collect.Sets;
import com.google.common.io.CharSource;
import com.google.common.io.Files;
import javax.annotation.Nullable;
public class FMLDeobfuscatingRemapper extends Remapper {
public static final FMLDeobfuscatingRemapper INSTANCE = new FMLDeobfuscatingRemapper();
@@ -198,12 +200,13 @@ public class FMLDeobfuscatingRemapper extends Remapper {
/*
* Cache the field descriptions for classes so we don't repeatedly reload the same data again and again
*/
private Map<String,Map<String,String>> fieldDescriptions = Maps.newHashMap();
private final Map<String,Map<String,String>> fieldDescriptions = Maps.newHashMap();
// Cache null values so we don't waste time trying to recompute classes with no field or method maps
private Set<String> negativeCacheMethods = Sets.newHashSet();
private Set<String> negativeCacheFields = Sets.newHashSet();
@Nullable
private String getFieldType(String owner, String name)
{
if (fieldDescriptions.containsKey(owner))
@@ -283,12 +286,12 @@ public class FMLDeobfuscatingRemapper extends Remapper {
}
@Override
public String mapFieldName(String owner, String name, String desc)
public String mapFieldName(String owner, String name, @Nullable String desc)
{
return mapFieldName(owner, name, desc, false);
}
String mapFieldName(String owner, String name, String desc, boolean raw)
String mapFieldName(String owner, String name, @Nullable String desc, boolean raw)
{
if (classNameBiMap == null || classNameBiMap.isEmpty())
{
@@ -350,6 +353,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
}
@Override
@Nullable
public String mapSignature(String signature, boolean typeSignature)
{
// JDT decorates some lambdas with this and SignatureReader chokes on it
@@ -430,7 +434,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
e.printStackTrace();
}
}
public void mergeSuperMaps(String name, String superName, String[] interfaces)
public void mergeSuperMaps(String name, @Nullable String superName, String[] interfaces)
{
// System.out.printf("Computing super maps for %s: %s %s\n", name, superName, Arrays.asList(interfaces));
if (classNameBiMap == null || classNameBiMap.isEmpty())
@@ -483,6 +487,7 @@ public class FMLDeobfuscatingRemapper extends Remapper {
return ImmutableSet.copyOf(classNameBiMap.keySet());
}
@Nullable
public String getStaticFieldType(String oldType, String oldName, String newType, String newName)
{
String fType = getFieldType(newType, newName);
@@ -35,6 +35,8 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
import javax.annotation.Nullable;
public class ASMDataTable
{
public final static class ASMData implements Cloneable
@@ -45,7 +47,7 @@ public class ASMDataTable
private String objectName;
private int classVersion;
private Map<String,Object> annotationInfo;
public ASMData(ModCandidate candidate, String annotationName, String className, String objectName, Map<String,Object> info)
public ASMData(ModCandidate candidate, String annotationName, String className, @Nullable String objectName, @Nullable Map<String,Object> info)
{
this.candidate = candidate;
this.annotationName = annotationName;
@@ -128,7 +130,7 @@ public class ASMDataTable
return globalAnnotationData.get(annotation);
}
public void addASMData(ModCandidate candidate, String annotation, String className, String objectName, Map<String,Object> annotationInfo)
public void addASMData(ModCandidate candidate, String annotation, String className, @Nullable String objectName, @Nullable Map<String,Object> annotationInfo)
{
globalAnnotationData.put(annotation, new ASMData(candidate, annotation, className, objectName, annotationInfo));
}
@@ -148,6 +150,7 @@ public class ASMDataTable
return this.packageMap.get(pkg);
}
@Nullable
public static String getOwnerModID(Set<ASMData> mods, ASMData targ)
{
if (mods.size() == 1) {
@@ -39,6 +39,8 @@ import org.apache.logging.log4j.Level;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import javax.annotation.Nullable;
public class DirectoryDiscoverer implements ITypeDiscoverer
{
private class ClassFilter implements FileFilter
@@ -66,7 +68,7 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
return found;
}
public void exploreFileSystem(String path, File modDir, List<ModContainer> harvestedMods, ModCandidate candidate, MetadataCollection mc)
public void exploreFileSystem(String path, File modDir, List<ModContainer> harvestedMods, ModCandidate candidate, @Nullable MetadataCollection mc)
{
if (path.length() == 0)
{
@@ -35,6 +35,8 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableList;
import org.apache.logging.log4j.Level;
import javax.annotation.Nonnull;
/**
* Simple intermod communications to receive simple messages directed at you
* from other mods
@@ -91,20 +93,22 @@ public class FMLInterModComms {
/**
* This field, and {@link #value} are both at the mod's discretion
*/
@Nonnull
public final String key;
/**
* This field, and {@link #key} are both at the mod's discretion
*/
@Nonnull
private final Object value;
private IMCMessage(String key, Object value)
private IMCMessage(@Nonnull String key, @Nonnull Object value)
{
this.key = key;
this.value = value;
this.isFunction = false;
}
private IMCMessage(String key, String value, boolean isFunction) {
private IMCMessage(@Nonnull String key, @Nonnull String value, boolean isFunction) {
this.key = key;
this.value = value;
this.isFunction = isFunction;
@@ -164,6 +168,7 @@ public class FMLInterModComms {
* @throws ClassCastException if this message doesn't contain an Itemstack value
* @return The Itemstack value
*/
@Nonnull
public ItemStack getItemStackValue()
{
return (ItemStack) value;
@@ -70,14 +70,14 @@ public class FMLPostInitializationEvent extends FMLStateEvent
@Nullable
@Override
public Class<?> apply(@Nullable Object input) {
return input.getClass();
return input == null ? null : input.getClass();
}
}).toArray(new Class[0]);
try
{
Class<?> clz = Class.forName(className,true,Loader.instance().getModClassLoader());
Constructor<?> ct = clz.getConstructor(args);
return Optional.fromNullable(ct.newInstance(arguments));
return Optional.of(ct.newInstance(arguments));
}
catch (Exception e)
{
@@ -33,6 +33,8 @@ import net.minecraftforge.fml.common.discovery.ASMDataTable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
/**
* Called before {@link FMLInitializationEvent} during mod startup.
*
@@ -132,6 +134,7 @@ public class FMLPreInitializationEvent extends FMLStateEvent
* such as a unique version number from a properties file shipped as part of the distributable.
* @return A properties object if one exists, else null
*/
@Nullable
public Properties getVersionProperties()
{
if (this.modContainer instanceof FMLModContainer)
@@ -153,7 +153,7 @@ public class Event
public void setPhase(@Nonnull EventPriority value)
{
Preconditions.checkArgument(value != null, "setPhase argument must not be null");
Preconditions.checkNotNull(value, "setPhase argument must not be null");
int prev = phase == null ? -1 : phase.ordinal();
Preconditions.checkArgument(prev < value.ordinal(), "Attempted to set event phase to %s when already %s", value, phase);
phase = value;
@@ -59,7 +59,7 @@ public class EventBus implements IEventExceptionHandler
public EventBus(@Nonnull IEventExceptionHandler handler)
{
this();
Preconditions.checkArgument(handler != null, "EventBus exception handler can not be null");
Preconditions.checkNotNull(handler, "EventBus exception handler can not be null");
exceptionHandler = handler;
}
@@ -23,12 +23,15 @@ import java.util.*;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import javax.annotation.Nullable;
public class ListenerList
{
private static ImmutableList<ListenerList> allLists = ImmutableList.of();
private static int maxSize = 0;
@Nullable
private ListenerList parent;
private ListenerListInst[] lists = new ListenerListInst[0];
@@ -37,7 +40,7 @@ public class ListenerList
this(null);
}
public ListenerList(ListenerList parent)
public ListenerList(@Nullable ListenerList parent)
{
// parent needs to be set before resize !
this.parent = parent;
@@ -30,6 +30,8 @@ import com.google.common.base.Throwables;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nullable;
/**
* Utilities for interacting with {@link ByteBuf}.
* @author cpw
@@ -203,6 +205,7 @@ public class ByteBufUtils {
* @param from The buffer to read from
* @return The read tag
*/
@Nullable
public static NBTTagCompound readTag(ByteBuf from)
{
PacketBuffer pb = new PacketBuffer(from);
@@ -31,6 +31,8 @@ import net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nullable;
/**
* Utility wrapper around {@link EmbeddedChannel}. Provides some convenience methods
* associated with the specific needs of FML network handling.
@@ -72,6 +74,7 @@ public class FMLEmbeddedChannel extends EmbeddedChannel {
return pkt;
}
@Nullable
public String findChannelHandlerNameForType(Class<? extends ChannelHandler> type)
{
String targetName = null;
@@ -33,6 +33,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nullable;
/**
* An event driven network channel, using {@link FMLNetworkEvent.CustomPacketEvent} and {@link FMLNetworkEvent.CustomNetworkEvent}
* to deliver messages to an event listener. There is one "bus" for each channel, due to the
@@ -57,6 +59,7 @@ public class FMLEventChannel {
SERVER()
{
@Override
@Nullable
FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg)
{
FMLNetworkEvent.CustomPacketEvent<?> event = null;
@@ -71,6 +74,7 @@ public class FMLEventChannel {
CLIENT()
{
@Override
@Nullable
FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg)
{
FMLNetworkEvent.CustomPacketEvent<?> event = null;
@@ -87,6 +91,7 @@ public class FMLEventChannel {
return event;
}
};
@Nullable
abstract FMLNetworkEvent.CustomPacketEvent<?> make(FMLProxyPacket msg);
}
@@ -40,6 +40,8 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import javax.annotation.Nullable;
public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
public static final AttributeKey<OutboundTarget> FML_MESSAGETARGET = AttributeKey.valueOf("fml:outboundTarget");
public static final AttributeKey<Object> FML_MESSAGETARGETARGS = AttributeKey.valueOf("fml:outboundTargetArgs");
@@ -59,6 +61,7 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
}
@Override
@Nullable
public List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet)
{
return null;
@@ -253,6 +256,7 @@ public class FMLOutboundHandler extends ChannelOutboundHandlerAdapter {
}
public final ImmutableSet<Side> allowed;
public abstract void validateArgs(Object args);
@Nullable
public abstract List<NetworkDispatcher> selectNetworks(Object args, ChannelHandlerContext context, FMLProxyPacket packet);
}
@@ -50,6 +50,8 @@ import net.minecraftforge.fml.relauncher.Side;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import javax.annotation.Nullable;
/**
* @author cpw
*
@@ -242,6 +244,7 @@ public enum NetworkRegistry
* @param z Z coord
* @return The server side GUI object (An instance of {@link Container})
*/
@Nullable
public Container getRemoteGuiContainer(ModContainer mc, EntityPlayerMP player, int modGuiId, World world, int x, int y, int z)
{
IGuiHandler handler = serverGuiHandlers.get(mc);
@@ -267,6 +270,7 @@ public enum NetworkRegistry
* @param z Z coord
* @return The client side GUI object (An instance of {@link net.minecraft.client.gui.Gui})
*/
@Nullable
public Object getLocalGuiContainer(ModContainer mc, EntityPlayer player, int modGuiId, World world, int x, int y, int z)
{
IGuiHandler handler = clientGuiHandlers.get(mc);
@@ -291,7 +295,7 @@ public enum NetworkRegistry
* @param remoteVersionRange the acceptable remote range
* @param asmHarvestedData internal data
*/
public void register(ModContainer fmlModContainer, Class<?> clazz, String remoteVersionRange, ASMDataTable asmHarvestedData)
public void register(ModContainer fmlModContainer, Class<?> clazz, @Nullable String remoteVersionRange, ASMDataTable asmHarvestedData)
{
NetworkModHolder networkModHolder = new NetworkModHolder(fmlModContainer, clazz, remoteVersionRange, asmHarvestedData);
registry.put(fmlModContainer, networkModHolder);
Loaded 100 of 130 files, more files were not shown because too many files have changed in this diff. Show more