mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Clean up null issues, add more annotations (#3590)
This commit is contained in:
1 parent
43efa3cfc4
commit
c545b8ecd4
130 files changed
+629
-262
No files matched your search
+5
-1
@@ -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!");
|
||||
|
||||
Reference in new issue
Block a user