[1.11] Fix nullability issues around ForgeHooks and Capabilities (#3395)

This commit is contained in:
mezz authored and LexManos committed 2016-11-17 10:44:31 -08:00
1 parent bf090cb4c2
commit 150566d9a3
26 files changed
+165 -108

No files matched your search

@@ -23,6 +23,8 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
/**
*
* AnvilUpdateEvent is fired when a player places items in both the left and right slots of a anvil.
@@ -33,27 +35,34 @@ import net.minecraft.item.ItemStack;
@Cancelable
public class AnvilUpdateEvent extends Event
{
@Nonnull
private final ItemStack left; // The left side of the input
@Nonnull
private final ItemStack right; // The right side of the input
private final String name; // The name to set the item, if the user specified one.
@Nonnull
private ItemStack output; // Set this to set the output stack
private int cost; // The base cost, set this to change it if output != null
private int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
public AnvilUpdateEvent(ItemStack left, ItemStack right, String name, int cost)
public AnvilUpdateEvent(@Nonnull ItemStack left, @Nonnull ItemStack right, String name, int cost)
{
this.left = left;
this.right = right;
this.output = ItemStack.field_190927_a;
this.name = name;
this.setCost(cost);
this.setMaterialCost(0);
}
@Nonnull
public ItemStack getLeft() { return left; }
@Nonnull
public ItemStack getRight() { return right; }
public String getName() { return name; }
@Nonnull
public ItemStack getOutput() { return output; }
public void setOutput(ItemStack output) { this.output = output; }
public void setOutput(@Nonnull ItemStack output) { this.output = output; }
public int getCost() { return cost; }
public void setCost(int cost) { this.cost = cost; }
public int getMaterialCost() { return materialCost; }
@@ -113,6 +113,7 @@ import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ForgeEventFactory
@@ -173,7 +174,7 @@ public class ForgeEventFactory
return (MinecraftForge.EVENT_BUS.post(event) ? -1 : event.getNewSpeed());
}
public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack, EnumHand hand)
public static void onPlayerDestroyItem(EntityPlayer player, @Nonnull ItemStack stack, @Nullable EnumHand hand)
{
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand));
}
@@ -38,6 +38,9 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* PlayerDestroyItemEvent is fired when a player destroys an item.<br>
* This event is fired whenever a player destroys an item in
@@ -61,16 +64,20 @@ import net.minecraft.util.EnumHand;
**/
public class PlayerDestroyItemEvent extends PlayerEvent
{
@Nonnull
private final ItemStack original;
@Nullable
private final EnumHand hand; // May be null if this player destroys the item by any use besides holding it.
public PlayerDestroyItemEvent(EntityPlayer player, ItemStack original, EnumHand hand)
public PlayerDestroyItemEvent(EntityPlayer player, @Nonnull ItemStack original, @Nullable EnumHand hand)
{
super(player);
this.original = original;
this.hand = hand;
}
@Nonnull
public ItemStack getOriginal() { return this.original; }
@Nullable
public EnumHand getHand() { return this.hand; }
}