Initial 1.11-pre1 update

This commit is contained in:
cpw committed 2016-11-13 17:09:55 -05:00
1 parent c177219ff3
commit 4e6a774075
294 files changed
+3099 -2846

No files matched your search

@@ -22,6 +22,7 @@ package net.minecraftforge.common;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.WeightedRandom;
public class DungeonHooks
@@ -42,7 +43,7 @@ public class DungeonHooks
* Meaning, Zombies are twice as common as spiders or skeletons.
* @return The new rarity of the monster,
*/
public static float addDungeonMob(String name, int rarity)
public static float addDungeonMob(ResourceLocation name, int rarity)
{
if (rarity <= 0)
{
@@ -85,21 +86,17 @@ public class DungeonHooks
* @param rand World generation random number generator
* @return The mob name
*/
public static String getRandomDungeonMob(Random rand)
public static ResourceLocation getRandomDungeonMob(Random rand)
{
DungeonMob mob = WeightedRandom.getRandomItem(rand, dungeonMobs);
if (mob == null)
{
return "";
}
return mob.type;
}
public static class DungeonMob extends WeightedRandom.Item
{
public String type;
public DungeonMob(int weight, String type)
public ResourceLocation type;
public DungeonMob(int weight, ResourceLocation type)
{
super(weight);
this.type = type;
@@ -114,8 +111,8 @@ public class DungeonHooks
static
{
addDungeonMob("Skeleton", 100);
addDungeonMob("Zombie", 200);
addDungeonMob("Spider", 100);
addDungeonMob(new ResourceLocation("skeleton"), 100);
addDungeonMob(new ResourceLocation("zombie"), 200);
addDungeonMob(new ResourceLocation("spider"), 100);
}
}
@@ -78,6 +78,7 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.AxisAlignedBB;
@@ -146,7 +147,7 @@ public class ForgeHooks
SeedEntry entry = WeightedRandom.getRandomItem(rand, seedList);
if (entry == null || entry.seed == null)
{
return null;
return ItemStack.field_190927_a;
}
return entry.getStack(rand, fortune);
}
@@ -264,14 +265,14 @@ public class ForgeHooks
public static int getTotalArmorValue(EntityPlayer player)
{
int ret = 0;
for (int x = 0; x < player.inventory.armorInventory.length; x++)
for (int x = 0; x < player.inventory.armorInventory.size(); x++)
{
ItemStack stack = player.inventory.armorInventory[x];
if (stack != null && stack.getItem() instanceof ISpecialArmor)
ItemStack stack = player.inventory.armorInventory.get(x);
if (stack.getItem() instanceof ISpecialArmor)
{
ret += ((ISpecialArmor)stack.getItem()).getArmorDisplay(player, stack, x);
}
else if (stack != null && stack.getItem() instanceof ItemArmor)
else if (stack.getItem() instanceof ItemArmor)
{
ret += ((ItemArmor)stack.getItem()).damageReduceAmount;
}
@@ -297,6 +298,7 @@ public class ForgeHooks
public static boolean onPickBlock(RayTraceResult target, EntityPlayer player, World world)
{
/*
boolean flag = this.thePlayer.capabilities.isCreativeMode;
TileEntity tileentity = null;
ItemStack itemstack;
@@ -306,14 +308,14 @@ public class ForgeHooks
IBlockState iblockstate = this.theWorld.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() == Material.air)
if (iblockstate.getMaterial() == Material.AIR)
{
return;
}
itemstack = block.func_185473_a(this.theWorld, blockpos, iblockstate);
itemstack = block.getItem(this.theWorld, blockpos, iblockstate);
if (itemstack == null)
if (itemstack.func_190926_b())
{
return;
}
@@ -332,24 +334,24 @@ public class ForgeHooks
if (this.objectMouseOver.entityHit instanceof EntityPainting)
{
itemstack = new ItemStack(Items.painting);
itemstack = new ItemStack(Items.PAINTING);
}
else if (this.objectMouseOver.entityHit instanceof EntityLeashKnot)
{
itemstack = new ItemStack(Items.lead);
itemstack = new ItemStack(Items.LEAD);
}
else if (this.objectMouseOver.entityHit instanceof EntityItemFrame)
{
EntityItemFrame entityitemframe = (EntityItemFrame)this.objectMouseOver.entityHit;
ItemStack itemstack1 = entityitemframe.getDisplayedItem();
if (itemstack1 == null)
if (itemstack1.func_190926_b())
{
itemstack = new ItemStack(Items.item_frame);
itemstack = new ItemStack(Items.ITEM_FRAME);
}
else
{
itemstack = ItemStack.copyItemStack(itemstack1);
itemstack = itemstack1.copy();
}
}
else if (this.objectMouseOver.entityHit instanceof EntityMinecart)
@@ -357,52 +359,96 @@ public class ForgeHooks
EntityMinecart entityminecart = (EntityMinecart)this.objectMouseOver.entityHit;
Item item;
switch (entityminecart.func_184264_v())
switch (entityminecart.getType())
{
case FURNACE:
item = Items.furnace_minecart;
item = Items.FURNACE_MINECART;
break;
case CHEST:
item = Items.chest_minecart;
item = Items.CHEST_MINECART;
break;
case TNT:
item = Items.tnt_minecart;
item = Items.TNT_MINECART;
break;
case HOPPER:
item = Items.hopper_minecart;
item = Items.HOPPER_MINECART;
break;
case COMMAND_BLOCK:
item = Items.command_block_minecart;
item = Items.COMMAND_BLOCK_MINECART;
break;
default:
item = Items.minecart;
item = Items.MINECART;
}
itemstack = new ItemStack(item);
}
else if (this.objectMouseOver.entityHit instanceof EntityBoat)
{
itemstack = new ItemStack(((EntityBoat)this.objectMouseOver.entityHit).func_184455_j());
itemstack = new ItemStack(((EntityBoat)this.objectMouseOver.entityHit).getItemBoat());
}
else if (this.objectMouseOver.entityHit instanceof EntityArmorStand)
{
itemstack = new ItemStack(Items.armor_stand);
itemstack = new ItemStack(Items.ARMOR_STAND);
}
else if (this.objectMouseOver.entityHit instanceof EntityEnderCrystal)
{
itemstack = new ItemStack(Items.field_185158_cP);
itemstack = new ItemStack(Items.END_CRYSTAL);
}
else
{
String s = EntityList.getEntityString(this.objectMouseOver.entityHit);
ResourceLocation resourcelocation = EntityList.func_191301_a(this.objectMouseOver.entityHit);
if (!EntityList.entityEggs.containsKey(s))
if (resourcelocation == null || !EntityList.ENTITY_EGGS.containsKey(resourcelocation))
{
return;
}
itemstack = new ItemStack(Items.spawn_egg);
ItemMonsterPlacer.func_185078_a(itemstack, s);
itemstack = new ItemStack(Items.SPAWN_EGG);
ItemMonsterPlacer.applyEntityIdToItemStack(itemstack, resourcelocation);
}
}
if (itemstack.func_190926_b())
{
String s = "";
if (this.objectMouseOver.typeOfHit == RayTraceResult.Type.BLOCK)
{
s = ((ResourceLocation)Block.REGISTRY.getNameForObject(this.theWorld.getBlockState(this.objectMouseOver.getBlockPos()).getBlock())).toString();
}
else if (this.objectMouseOver.typeOfHit == RayTraceResult.Type.ENTITY)
{
s = EntityList.func_191301_a(this.objectMouseOver.entityHit).toString();
}
LOGGER.warn("Picking on: [{}] {} gave null item", new Object[] {this.objectMouseOver.typeOfHit, s});
}
else
{
InventoryPlayer inventoryplayer = this.thePlayer.inventory;
if (tileentity != null)
{
this.storeTEInStack(itemstack, tileentity);
}
int i = inventoryplayer.getSlotFor(itemstack);
if (flag)
{
inventoryplayer.setPickedItemStack(itemstack);
this.playerController.sendSlotPacket(this.thePlayer.getHeldItem(EnumHand.MAIN_HAND), 36 + inventoryplayer.currentItem);
}
else if (i != -1)
{
if (InventoryPlayer.isHotbar(i))
{
inventoryplayer.currentItem = i;
}
else
{
this.playerController.pickItem(i);
}
}
}
*/
@@ -756,7 +802,7 @@ public class ForgeHooks
{
// handle all placement events here
int meta = itemstack.getItemDamage();
int size = itemstack.stackSize;
int size = itemstack.func_190916_E();
NBTTagCompound nbt = null;
if (itemstack.getTagCompound() != null)
{
@@ -768,14 +814,14 @@ public class ForgeHooks
world.captureBlockSnapshots = true;
}
EnumActionResult ret = itemstack.getItem().onItemUse(itemstack, player, world, pos, hand, side, hitX, hitY, hitZ);
EnumActionResult ret = itemstack.getItem().onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ);
world.captureBlockSnapshots = false;
if (ret == EnumActionResult.SUCCESS)
{
// save new item data
int newMeta = itemstack.getItemDamage();
int newSize = itemstack.stackSize;
int newSize = itemstack.func_190916_E();
NBTTagCompound newNBT = null;
if (itemstack.getTagCompound() != null)
{
@@ -788,7 +834,7 @@ public class ForgeHooks
// make sure to set pre-placement item data for event
itemstack.setItemDamage(meta);
itemstack.stackSize = size;
itemstack.func_190920_e(size);
if (nbt != null)
{
itemstack.setTagCompound(nbt);
@@ -817,7 +863,7 @@ public class ForgeHooks
{
// Change the stack to its new content
itemstack.setItemDamage(newMeta);
itemstack.stackSize = newSize;
itemstack.func_190920_e(newSize);
if (nbt != null)
{
itemstack.setTagCompound(newNBT);
@@ -883,12 +929,12 @@ public class ForgeHooks
* @param inv Crafting inventory
* @return Crafting inventory contents after the recipe.
*/
public static ItemStack[] defaultRecipeGetRemainingItems(InventoryCrafting inv)
public static NonNullList<ItemStack> defaultRecipeGetRemainingItems(InventoryCrafting inv)
{
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
for (int i = 0; i < ret.length; i++)
NonNullList<ItemStack> ret = NonNullList.func_191197_a(inv.getSizeInventory(), ItemStack.field_190927_a);
for (int i = 0; i < ret.size(); i++)
{
ret[i] = getContainerItem(inv.getStackInSlot(i));
ret.set(i, getContainerItem(inv.getStackInSlot(i)));
}
return ret;
}
@@ -983,25 +1029,25 @@ public class ForgeHooks
return git == null ? null : git.hitVec;
}
public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, RayTraceResult ray, ItemStack stack, EnumHand hand)
public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, RayTraceResult ray, EnumHand hand)
{
Vec3d vec3d = new Vec3d(ray.hitVec.xCoord - entity.posX, ray.hitVec.yCoord - entity.posY, ray.hitVec.zCoord - entity.posZ);
return onInteractEntityAt(player, entity, vec3d, stack, hand);
return onInteractEntityAt(player, entity, vec3d, hand);
}
public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, Vec3d vec3d, ItemStack stack, EnumHand hand)
public static boolean onInteractEntityAt(EntityPlayer player, Entity entity, Vec3d vec3d, EnumHand hand)
{
return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.EntityInteractSpecific(player, hand, stack, entity, vec3d));
return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.EntityInteractSpecific(player, hand, entity, vec3d));
}
public static boolean onInteractEntity(EntityPlayer player, Entity entity, ItemStack item, EnumHand hand)
public static boolean onInteractEntity(EntityPlayer player, Entity entity, EnumHand hand)
{
return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.EntityInteract(player, hand, item, entity));
return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.EntityInteract(player, hand, entity));
}
public static boolean onItemRightClick(EntityPlayer player, EnumHand hand, ItemStack stack)
public static boolean onItemRightClick(EntityPlayer player, EnumHand hand)
{
return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickItem(player, hand, stack));
return MinecraftForge.EVENT_BUS.post(new PlayerInteractEvent.RightClickItem(player, hand));
}
public static PlayerInteractEvent.LeftClickBlock onLeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec)
@@ -1011,9 +1057,9 @@ public class ForgeHooks
return evt;
}
public static PlayerInteractEvent.RightClickBlock onRightClickBlock(EntityPlayer player, EnumHand hand, ItemStack stack, BlockPos pos, EnumFacing face, Vec3d hitVec)
public static PlayerInteractEvent.RightClickBlock onRightClickBlock(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face, Vec3d hitVec)
{
PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, stack, pos, face, hitVec);
PlayerInteractEvent.RightClickBlock evt = new PlayerInteractEvent.RightClickBlock(player, hand, pos, face, hitVec);
MinecraftForge.EVENT_BUS.post(evt);
return evt;
}
@@ -50,17 +50,17 @@ import net.minecraftforge.fml.common.versioning.ComparableVersion;
public class ForgeVersion
{
//This number is incremented every time we remove deprecated code/major API changes, never reset
public static final int majorVersion = 12;
public static final int majorVersion = 13;
//This number is incremented every minecraft release, never reset
public static final int minorVersion = 18;
public static final int minorVersion = 19;
//This number is incremented every time a interface changes or new major feature is added, and reset every Minecraft version
public static final int revisionVersion = 2;
public static final int revisionVersion = 0;
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
public static final int buildVersion = 0;
// This is the minecraft version we're building for - used in various places in Forge/FML code
public static final String mcVersion = "1.10.2";
public static final String mcVersion = "1.11_pre1";
// This is the MCP data version we're using
public static final String mcpVersion = "9.32";
public static final String mcpVersion = "9.34";
@SuppressWarnings("unused")
private static Status status = PENDING;
@SuppressWarnings("unused")
@@ -32,6 +32,7 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
/**
* This interface is to be implemented by ItemArmor classes. It will allow to
@@ -110,7 +111,7 @@ public interface ISpecialArmor
* @param damage The total damage being done
* @return The left over damage that has not been absorbed by the armor
*/
public static float applyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage)
public static float applyArmor(EntityLivingBase entity, NonNullList<ItemStack> inventory, DamageSource source, double damage)
{
if (DEBUG)
{
@@ -118,10 +119,10 @@ public interface ISpecialArmor
}
damage *= 25;
ArrayList<ArmorProperties> dmgVals = new ArrayList<ArmorProperties>();
for (int x = 0; x < inventory.length; x++)
for (int x = 0; x < inventory.size(); x++)
{
ItemStack stack = inventory[x];
if (stack == null)
ItemStack stack = inventory.get(x);
if (stack.func_190926_b())
{
continue;
}
@@ -161,7 +162,7 @@ public interface ISpecialArmor
double absorb = damage * prop.AbsorbRatio;
if (absorb > 0)
{
ItemStack stack = inventory[prop.Slot];
ItemStack stack = inventory.get(prop.Slot);
int itemDamage = (int)(absorb / 25D < 1 ? 1 : absorb / 25D);
if (stack.getItem() instanceof ISpecialArmor)
{
@@ -175,13 +176,13 @@ public interface ISpecialArmor
}
stack.damageItem(itemDamage, entity);
}
if (stack.stackSize <= 0)
if (stack.func_190926_b())
{
/*if (entity instanceof EntityPlayer)
{
stack.onItemDestroyedByUse((EntityPlayer)entity);
}*/
inventory[prop.Slot] = null;
inventory.set(prop.Slot, ItemStack.field_190927_a);
}
}
}
@@ -54,7 +54,7 @@ public abstract class AbstractBrewingRecipe<T> implements IBrewingRecipe {
@Override
public ItemStack getOutput(ItemStack input, ItemStack ingredient)
{
return isInput(input) && isIngredient(ingredient) ? ItemStack.copyItemStack(getOutput()) : null;
return isInput(input) && isIngredient(ingredient) ? getOutput().copy() : null;
}
public ItemStack getInput()
@@ -23,6 +23,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import javax.annotation.Nonnull;
public class BrewingRecipeRegistry {
@@ -84,10 +87,11 @@ public class BrewingRecipeRegistry {
* Returns the output ItemStack obtained by brewing the passed input and
* ingredient. Null if no matches are found.
*/
public static ItemStack getOutput(ItemStack input, ItemStack ingredient)
@Nonnull
public static ItemStack getOutput(@Nonnull ItemStack input, ItemStack ingredient)
{
if (input == null || input.getMaxStackSize() != 1 || input.stackSize != 1) return null;
if (ingredient == null || ingredient.stackSize <= 0) return null;
if (input.func_190926_b() || input.getMaxStackSize() != 1 || input.func_190916_E() != 1) return ItemStack.field_190927_a;
if (ingredient.func_190926_b()) return ItemStack.field_190927_a;
for (IBrewingRecipe recipe : recipes)
{
@@ -97,7 +101,7 @@ public class BrewingRecipeRegistry {
return output;
}
}
return null;
return ItemStack.field_190927_a;
}
/**
@@ -105,7 +109,7 @@ public class BrewingRecipeRegistry {
*/
public static boolean hasOutput(ItemStack input, ItemStack ingredient)
{
return getOutput(input, ingredient) != null;
return !getOutput(input, ingredient).func_190926_b();
}
/**
@@ -113,13 +117,13 @@ public class BrewingRecipeRegistry {
* Extra parameters exist to allow modders to create bigger brewing stands
* without much hassle
*/
public static boolean canBrew(ItemStack[] inputs, ItemStack ingredient, int[] inputIndexes)
public static boolean canBrew(NonNullList<ItemStack> inputs, @Nonnull ItemStack ingredient, int[] inputIndexes)
{
if (ingredient == null || ingredient.stackSize <= 0) return false;
if (ingredient.func_190926_b()) return false;
for (int i : inputIndexes)
{
if (hasOutput(inputs[i], ingredient))
if (hasOutput(inputs.get(i), ingredient))
{
return true;
}
@@ -132,14 +136,14 @@ public class BrewingRecipeRegistry {
* Used by the brewing stand to brew its inventory Extra parameters exist to
* allow modders to create bigger brewing stands without much hassle
*/
public static void brewPotions(ItemStack[] inputs, ItemStack ingredient, int[] inputIndexes)
public static void brewPotions(NonNullList<ItemStack> inputs, @Nonnull ItemStack ingredient, int[] inputIndexes)
{
for (int i : inputIndexes)
{
ItemStack output = getOutput(inputs[i], ingredient);
if (output != null)
ItemStack output = getOutput(inputs.get(i), ingredient);
if (!output.func_190926_b())
{
inputs[i] = output;
inputs.set(i, output);
}
}
}
@@ -148,9 +152,9 @@ public class BrewingRecipeRegistry {
* Returns true if the passed ItemStack is a valid ingredient for any of the
* recipes in the registry.
*/
public static boolean isValidIngredient(ItemStack stack)
public static boolean isValidIngredient(@Nonnull ItemStack stack)
{
if (stack == null || stack.stackSize <= 0) return false;
if (stack.func_190926_b()) return false;
for (IBrewingRecipe recipe : recipes)
{
@@ -166,9 +170,9 @@ public class BrewingRecipeRegistry {
* Returns true if the passed ItemStack is a valid input for any of the
* recipes in the registry.
*/
public static boolean isValidInput(ItemStack stack)
public static boolean isValidInput(@Nonnull ItemStack stack)
{
if (stack == null || stack.getMaxStackSize() != 1 || stack.stackSize != 1) return false;
if (stack.getMaxStackSize() != 1 || stack.func_190916_E() != 1) return false;
for (IBrewingRecipe recipe : recipes)
{
@@ -44,7 +44,7 @@ public class FakePlayer extends EntityPlayerMP
@Override public Vec3d getPositionVector(){ return new Vec3d(0, 0, 0); }
@Override public boolean canCommandSenderUseCommand(int i, String s){ return false; }
@Override public void addChatComponentMessage(ITextComponent chatmessagecomponent){}
@Override public void addChatComponentMessage(ITextComponent chatmessagecomponent, boolean type){}
@Override public void addStat(StatBase par1StatBase, int par2){}
@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
@Override public boolean isEntityInvulnerable(DamageSource source){ return true; }
@@ -46,6 +46,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
@@ -152,9 +153,9 @@ public class ForgeEventFactory
return event;
}
public static NeighborNotifyEvent onNeighborNotify(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides)
public static NeighborNotifyEvent onNeighborNotify(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides, boolean forceRedstoneUpdate)
{
NeighborNotifyEvent event = new NeighborNotifyEvent(world, pos, state, notifiedSides);
NeighborNotifyEvent event = new NeighborNotifyEvent(world, pos, state, notifiedSides, forceRedstoneUpdate);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
@@ -354,7 +355,7 @@ public class ForgeEventFactory
if (event.getResult() == Result.ALLOW)
{
if (!world.isRemote)
stack.stackSize--;
stack.func_190918_g(1);
return 1;
}
return 0;
@@ -370,7 +371,8 @@ public class ForgeEventFactory
if (player.capabilities.isCreativeMode)
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
if (--stack.stackSize <= 0)
stack.func_190918_g(1);
if (stack.func_190926_b())
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());
if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
@@ -398,7 +400,7 @@ public class ForgeEventFactory
public static int onItemExpire(EntityItem entity, ItemStack item)
{
if (item == null) return -1;
ItemExpireEvent event = new ItemExpireEvent(entity, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
ItemExpireEvent event = new ItemExpireEvent(entity, (item.func_190926_b() ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
return event.getExtraLife();
}
@@ -493,20 +495,20 @@ public class ForgeEventFactory
return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.getAmount());
}
public static boolean onPotionAttemptBrew(ItemStack[] stacks)
public static boolean onPotionAttemptBrew(NonNullList<ItemStack> stacks)
{
ItemStack[] tmp = new ItemStack[stacks.length];
for (int x = 0; x < tmp.length; x++)
tmp[x] = ItemStack.copyItemStack(stacks[x]);
NonNullList<ItemStack> tmp = NonNullList.func_191197_a(stacks.size(), ItemStack.field_190927_a);
for (int x = 0; x < tmp.size(); x++)
tmp.set(x, stacks.get(x).copy());
PotionBrewEvent.Pre event = new PotionBrewEvent.Pre(tmp);
if (MinecraftForge.EVENT_BUS.post(event))
{
boolean changed = false;
for (int x = 0; x < stacks.length; x++)
for (int x = 0; x < stacks.size(); x++)
{
changed |= ItemStack.areItemStacksEqual(tmp[x], stacks[x]);
stacks[x] = event.getItem(x);
changed |= ItemStack.areItemStacksEqual(tmp.get(x), stacks.get(x));
stacks.set(x, event.getItem(x));
}
if (changed)
onPotionBrewed(stacks);
@@ -515,7 +517,7 @@ public class ForgeEventFactory
return false;
}
public static void onPotionBrewed(ItemStack[] brewingItemStacks)
public static void onPotionBrewed(NonNullList<ItemStack> brewingItemStacks)
{
MinecraftForge.EVENT_BUS.post(new PotionBrewEvent.Post(brewingItemStacks));
}
@@ -21,6 +21,7 @@ package net.minecraftforge.event.brewing;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityBrewingStand;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.common.eventhandler.Event;
@@ -29,30 +30,30 @@ import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
public class PotionBrewEvent extends Event
{
private ItemStack[] stacks;
private NonNullList<ItemStack> stacks;
protected PotionBrewEvent(ItemStack[] stacks)
protected PotionBrewEvent(NonNullList<ItemStack> stacks)
{
this.stacks = stacks;
}
public ItemStack getItem(int index)
{
if (index >= stacks.length) return null;
return stacks[index];
if (index >= stacks.size()) return null;
return stacks.get(index);
}
public void setItem(int index, ItemStack stack)
{
if (index < stacks.length)
if (index < stacks.size())
{
stacks[index] = stack;
stacks.set(index, stack);
}
}
public int getLength()
{
return stacks.length;
return stacks.size();
}
/**
@@ -75,7 +76,7 @@ public class PotionBrewEvent extends Event
@Cancelable
public static class Pre extends PotionBrewEvent
{
public Pre(ItemStack[] stacks)
public Pre(NonNullList<ItemStack> stacks)
{
super(stacks);
}
@@ -96,7 +97,7 @@ public class PotionBrewEvent extends Event
**/
public static class Post extends PotionBrewEvent
{
public Post(ItemStack[] stacks)
public Post(NonNullList<ItemStack> stacks)
{
super(stacks);
}
@@ -52,18 +52,16 @@ import net.minecraft.util.EnumHand;
public class MinecartInteractEvent extends MinecartEvent
{
private final EntityPlayer player;
private final ItemStack item;
private final EnumHand hand;
public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player, ItemStack item, EnumHand hand)
public MinecartInteractEvent(EntityMinecart minecart, EntityPlayer player, EnumHand hand)
{
super(minecart);
this.player = player;
this.item = item;
this.hand = hand;
}
public EntityPlayer getPlayer() { return player; }
public ItemStack getItem() { return item; }
public ItemStack getItem() { return player.getHeldItem(hand); }
public EnumHand getHand() { return hand; }
}
@@ -35,6 +35,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Cancelable;
import net.minecraftforge.fml.relauncher.Side;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT;
@@ -48,15 +49,13 @@ import static net.minecraftforge.fml.common.eventhandler.Event.Result.DENY;
public class PlayerInteractEvent extends PlayerEvent
{
private final EnumHand hand;
private final ItemStack stack;
private final BlockPos pos;
private final EnumFacing face;
private PlayerInteractEvent(EntityPlayer player, EnumHand hand, ItemStack stack, BlockPos pos, EnumFacing face)
private PlayerInteractEvent(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face)
{
super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!"));
this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!");
this.stack = stack;
this.pos = Preconditions.checkNotNull(pos, "Null position in PlayerInteractEvent!");
this.face = face;
}
@@ -78,9 +77,9 @@ public class PlayerInteractEvent extends PlayerEvent
private final Vec3d localPos;
private final Entity target;
public EntityInteractSpecific(EntityPlayer player, EnumHand hand, ItemStack stack, Entity target, Vec3d localPos)
public EntityInteractSpecific(EntityPlayer player, EnumHand hand, Entity target, Vec3d localPos)
{
super(player, hand, stack, new BlockPos(target), null);
super(player, hand, new BlockPos(target), null);
this.localPos = localPos;
this.target = target;
}
@@ -120,9 +119,9 @@ public class PlayerInteractEvent extends PlayerEvent
{
private final Entity target;
public EntityInteract(EntityPlayer player, EnumHand hand, ItemStack stack, Entity target)
public EntityInteract(EntityPlayer player, EnumHand hand, Entity target)
{
super(player, hand, stack, new BlockPos(target), null);
super(player, hand, new BlockPos(target), null);
this.target = target;
}
@@ -147,9 +146,8 @@ public class PlayerInteractEvent extends PlayerEvent
private Result useItem = DEFAULT;
private final Vec3d hitVec;
public RightClickBlock(EntityPlayer player, EnumHand hand, ItemStack stack,
BlockPos pos, EnumFacing face, Vec3d hitVec) {
super(player, hand, stack, pos, face);
public RightClickBlock(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face, Vec3d hitVec) {
super(player, hand, pos, face);
this.hitVec = hitVec;
}
@@ -218,9 +216,9 @@ public class PlayerInteractEvent extends PlayerEvent
@Cancelable
public static class RightClickItem extends PlayerInteractEvent
{
public RightClickItem(EntityPlayer player, EnumHand hand, ItemStack stack)
public RightClickItem(EntityPlayer player, EnumHand hand)
{
super(player, hand, stack, new BlockPos(player), null);
super(player, hand, new BlockPos(player), null);
}
}
@@ -233,7 +231,7 @@ public class PlayerInteractEvent extends PlayerEvent
{
public RightClickEmpty(EntityPlayer player, EnumHand hand)
{
super(player, hand, null, new BlockPos(player), null);
super(player, hand, new BlockPos(player), null);
}
}
@@ -258,7 +256,7 @@ public class PlayerInteractEvent extends PlayerEvent
public LeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec)
{
super(player, EnumHand.MAIN_HAND, player.getHeldItem(EnumHand.MAIN_HAND), pos, face);
super(player, EnumHand.MAIN_HAND, pos, face);
this.hitVec = hitVec;
}
@@ -317,7 +315,7 @@ public class PlayerInteractEvent extends PlayerEvent
{
public LeftClickEmpty(EntityPlayer player, ItemStack stack)
{
super(player, EnumHand.MAIN_HAND, stack, new BlockPos(player), null);
super(player, EnumHand.MAIN_HAND, new BlockPos(player), null);
}
}
@@ -332,10 +330,10 @@ public class PlayerInteractEvent extends PlayerEvent
/**
* @return The itemstack involved in this interaction, or null if the hand was empty.
*/
@Nullable
@Nonnull
public ItemStack getItemStack()
{
return stack;
return getEntityPlayer().getHeldItem(hand);
}
/**
@@ -255,11 +255,13 @@ public class BlockEvent extends Event
public static class NeighborNotifyEvent extends BlockEvent
{
private final EnumSet<EnumFacing> notifiedSides;
private final boolean forceRedstoneUpdate;
public NeighborNotifyEvent(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides)
public NeighborNotifyEvent(World world, BlockPos pos, IBlockState state, EnumSet<EnumFacing> notifiedSides, boolean forceRedstoneUpdate)
{
super(world, pos, state);
this.notifiedSides = notifiedSides;
this.forceRedstoneUpdate = forceRedstoneUpdate;
}
/**
@@ -271,6 +273,15 @@ public class BlockEvent extends Event
{
return notifiedSides;
}
/**
* Get if redstone update was forced during setBlock call (0x16 to flags)
* @return if the flag was set
*/
public boolean getForceRedstoneUpdate()
{
return forceRedstoneUpdate;
}
}
/**
@@ -325,7 +325,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
@Override
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock)
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block neighborBlock, BlockPos neighbourPos)
{
world.scheduleUpdate(pos, this, tickRate);
}
@@ -675,7 +675,7 @@ public abstract class BlockFluidBase extends Block implements IFluidBlock
}
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos)
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos)
{
return NULL_AABB;
}
@@ -152,7 +152,7 @@ public class BlockFluidClassic extends BlockFluidBase
{
world.setBlockState(pos, state.withProperty(LEVEL, quantaPerBlock - expQuanta), 2);
world.scheduleUpdate(pos, this, tickRate);
world.notifyNeighborsOfStateChange(pos, this);
world.notifyNeighborsOfStateChange(pos, this, false);
}
}
}
@@ -29,6 +29,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.capability.IFluidHandler;
import javax.annotation.Nonnull;
/**
* Fills or drains a fluid container item using a Dispenser.
*/
@@ -60,7 +62,8 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
/**
* Picks up fluid in front of a Dispenser and fills a container with it.
*/
private ItemStack fillContainer(IBlockSource source, ItemStack stack)
@Nonnull
private ItemStack fillContainer(IBlockSource source, @Nonnull ItemStack stack)
{
World world = source.getWorld();
EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING);
@@ -72,7 +75,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
return super.dispenseStack(source, stack);
}
if (--stack.stackSize == 0)
if (stack.func_190916_E() == 1)
{
stack.deserializeNBT(result.serializeNBT());
}
@@ -81,6 +84,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
this.dispenseBehavior.dispense(source, result);
}
stack.func_190918_g(1);
return stack;
}
@@ -90,7 +94,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
private ItemStack dumpContainer(IBlockSource source, ItemStack stack)
{
ItemStack dispensedStack = stack.copy();
dispensedStack.stackSize = 1;
dispensedStack.func_190920_e(1);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(dispensedStack);
if (fluidHandler == null)
{
@@ -105,7 +109,7 @@ public class DispenseFluidContainer extends BehaviorDefaultDispenseItem
{
fluidHandler.drain(Fluid.BUCKET_VOLUME, true);
if (--stack.stackSize == 0)
if (stack.func_190916_E() == 1)
{
stack.deserializeNBT(dispensedStack.serializeNBT());
}
@@ -19,6 +19,7 @@
package net.minecraftforge.fluids;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
@@ -84,10 +85,11 @@ public class FluidUtil
* @param doFill true if the container should actually be filled, false if it should be simulated.
* @return The filled container or null if the liquid couldn't be taken from the tank.
*/
public static ItemStack tryFillContainer(ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable EntityPlayer player, boolean doFill)
@Nonnull
public static ItemStack tryFillContainer(@Nonnull ItemStack container, IFluidHandler fluidSource, int maxAmount, @Nullable EntityPlayer player, boolean doFill)
{
container = container.copy(); // do not modify the input
container.stackSize = 1;
container.func_190920_e(1);
IFluidHandler containerFluidHandler = getFluidHandler(container);
if (containerFluidHandler != null)
{
@@ -125,11 +127,11 @@ public class FluidUtil
* NOTE The empty container will have a stackSize of 0 when a filled container is consumable,
* i.e. it has a "null" empty container but has successfully been emptied.
*/
@Nullable
public static ItemStack tryEmptyContainer(ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
@Nonnull
public static ItemStack tryEmptyContainer(@Nonnull ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
{
container = container.copy(); // do not modify the input
container.stackSize = 1;
container.func_190920_e(1);
IFluidHandler containerFluidHandler = getFluidHandler(container);
if (containerFluidHandler != null)
{
@@ -169,9 +171,9 @@ public class FluidUtil
* @param player The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.
* @return True if the container was filled successfully and stowed, false otherwise.
*/
public static boolean tryFillContainerAndStow(ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
public static boolean tryFillContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidSource, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
{
if (container == null || container.stackSize < 1)
if (container.func_190926_b())
{
return false;
}
@@ -184,7 +186,7 @@ public class FluidUtil
return true;
}
}
else if (container.stackSize == 1) // don't need to stow anything, just fill and edit the container stack
else if (container.func_190916_E() == 1) // don't need to stow anything, just fill and edit the container stack
{
ItemStack filledReal = tryFillContainer(container, fluidSource, maxAmount, player, true);
if (filledReal != null)
@@ -211,7 +213,7 @@ public class FluidUtil
ItemHandlerHelper.giveItemToPlayer(player, remainder);
}
container.stackSize--;
container.func_190918_g(1);
return true;
}
}
@@ -234,9 +236,9 @@ public class FluidUtil
* @param player The player that gets the items the inventory can't take. Can be null, only used if the inventory cannot take the filled stack.
* @return True if the container was filled successfully and stowed, false otherwise.
*/
public static boolean tryEmptyContainerAndStow(ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
public static boolean tryEmptyContainerAndStow(@Nonnull ItemStack container, IFluidHandler fluidDestination, IItemHandler inventory, int maxAmount, @Nullable EntityPlayer player)
{
if (container == null || container.stackSize < 1)
if (container.func_190926_b())
{
return false;
}
@@ -249,51 +251,45 @@ public class FluidUtil
return true;
}
}
else if (container.stackSize == 1) // don't need to stow anything, just fill and edit the container stack
else if (container.func_190916_E() == 1) // don't need to stow anything, just fill and edit the container stack
{
ItemStack emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
if (emptiedReal != null)
if (emptiedReal.func_190926_b())
{
if (emptiedReal.stackSize <= 0)
{
container.stackSize--;
}
else
{
container.deserializeNBT(emptiedReal.serializeNBT());
}
return true;
container.func_190918_g(1);
}
else
{
container.deserializeNBT(emptiedReal.serializeNBT());
}
return true;
}
else
{
ItemStack emptiedSimulated = tryEmptyContainer(container, fluidDestination, maxAmount, player, false);
if (emptiedSimulated != null)
if (emptiedSimulated.func_190926_b())
{
tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
container.func_190918_g(1);
return true;
}
else
{
if (emptiedSimulated.stackSize <= 0)
// check if we can give the itemStack to the inventory
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedSimulated, true);
if (remainder == null || player != null)
{
tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
container.stackSize--;
return true;
}
else
{
// check if we can give the itemStack to the inventory
ItemStack remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedSimulated, true);
if (remainder == null || player != null)
ItemStack emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedReal, false);
// give it to the player or drop it at their feet
if (remainder != null && player != null)
{
ItemStack emptiedReal = tryEmptyContainer(container, fluidDestination, maxAmount, player, true);
remainder = ItemHandlerHelper.insertItemStacked(inventory, emptiedReal, false);
// give it to the player or drop it at their feet
if (remainder != null && player != null)
{
ItemHandlerHelper.giveItemToPlayer(player, remainder);
}
container.stackSize--;
return true;
ItemHandlerHelper.giveItemToPlayer(player, remainder);
}
container.func_190918_g(1);
return true;
}
}
}
@@ -381,7 +377,7 @@ public class FluidUtil
if (container != null)
{
container = container.copy();
container.stackSize = 1;
container.func_190920_e(1);
IFluidHandler fluidHandler = FluidUtil.getFluidHandler(container);
if (fluidHandler != null)
{
@@ -488,11 +484,11 @@ public class FluidUtil
* @param side The side of the fluid that is being drained.
* @return a filled container if it was successful. returns null on failure.
*/
@Nullable
public static ItemStack tryPickUpFluid(ItemStack emptyContainer, @Nullable EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side)
@Nonnull
public static ItemStack tryPickUpFluid(@Nonnull ItemStack emptyContainer, @Nullable EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side)
{
if (emptyContainer == null || worldIn == null || pos == null) {
return null;
if (emptyContainer.func_190926_b() || worldIn == null || pos == null) {
return ItemStack.field_190927_a;
}
IBlockState state = worldIn.getBlockState(pos);
@@ -639,11 +635,11 @@ public class FluidUtil
if (liquid != null && liquid.amount > 0)
{
// check which itemstack shall be altered by the fill call
if (container.stackSize > 1)
if (container.func_190916_E() > 1)
{
// create a copy of the container and fill it
ItemStack toFill = container.copy();
toFill.stackSize = 1;
toFill.func_190920_e(1);
int filled = fluidContainer.fill(toFill, liquid, false);
if (filled > 0)
{
@@ -677,7 +673,7 @@ public class FluidUtil
tank.drain(side, filled, true);
// decrease its stacksize to accommodate the filled one (it was >1 from the check above)
container.stackSize--;
container.func_190918_g(1);
}
// just 1 empty container to fill, no special treatment needed
else
@@ -754,11 +750,11 @@ public class FluidUtil
if (drained != null && drained.amount == filled)
{
// more than 1 filled itemstack, ensure that we can insert the changed container
if (container.stackSize > 1)
if (container.func_190916_E() > 1)
{
// create a copy of the container and drain it
ItemStack toEmpty = container.copy();
toEmpty.stackSize = 1;
toEmpty.func_190920_e(1);
drained = fluidContainer.drain(toEmpty, filled, true); // modifies the container!
if(player == null || !player.worldObj.isRemote)
@@ -782,7 +778,7 @@ public class FluidUtil
tank.fill(side, drained, true);
// decrease its stacksize to accommodate the filled one (it was >1 from the check above)
container.stackSize--;
container.func_190918_g(1);
}
// itemstack of size 1, no special treatment needed
else
@@ -98,7 +98,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems)
{
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
{
@@ -139,8 +139,9 @@ public class UniversalBucket extends Item implements IFluidContainerItem
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemstack, World world, EntityPlayer player, EnumHand hand)
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
FluidStack fluidStack = getFluid(itemstack);
// empty bucket shouldn't exist, do nothing since it should be handled by the bucket event
if (fluidStack == null)
@@ -173,11 +174,11 @@ public class UniversalBucket extends Item implements IFluidContainerItem
// success!
player.addStat(StatList.getObjectUseStats(this));
itemstack.stackSize--;
itemstack.func_190918_g(1);
ItemStack emptyStack = getEmpty() != null ? getEmpty().copy() : new ItemStack(this);
// check whether we replace the item or add the empty one to the inventory
if (itemstack.stackSize <= 0)
if (itemstack.func_190926_b())
{
return ActionResult.newResult(EnumActionResult.SUCCESS, emptyStack);
}
@@ -244,7 +245,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
BlockPos pos = target.getBlockPos();
ItemStack singleBucket = emptyBucket.copy();
singleBucket.stackSize = 1;
singleBucket.func_190920_e(1);
ItemStack filledBucket = FluidUtil.tryPickUpFluid(singleBucket, event.getEntityPlayer(), world, pos, target.sideHit);
if (filledBucket != null)
@@ -285,7 +286,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
// has to be exactly 1, must be handled from the caller
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return 0;
}
@@ -342,7 +343,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
// has to be exactly 1, must be handled from the caller
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return null;
}
@@ -361,7 +362,7 @@ public class UniversalBucket extends Item implements IFluidContainerItem
container.deserializeNBT(getEmpty().serializeNBT());
}
else {
container.stackSize = 0;
container.func_190920_e(0);
}
}
@@ -90,7 +90,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
{
return 0;
}
@@ -130,7 +130,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
{
return null;
}
@@ -140,7 +140,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain <= 0)
if (container.func_190916_E() != 1 || maxDrain <= 0)
{
return null;
}
@@ -219,7 +219,7 @@ public class FluidHandlerItemStack implements IFluidHandler, ICapabilityProvider
protected void setContainerToEmpty()
{
super.setContainerToEmpty();
container.stackSize--;
container.func_190918_g(1);
}
}
@@ -88,7 +88,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
{
return 0;
}
@@ -114,7 +114,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
if (container.func_190916_E() != 1 || resource == null || resource.amount <= 0 || !resource.isFluidEqual(getFluid()))
{
return null;
}
@@ -124,7 +124,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain <= 0)
if (container.func_190916_E() != 1 || maxDrain <= 0)
{
return null;
}
@@ -196,7 +196,7 @@ public class FluidHandlerItemStackSimple implements IFluidHandler, ICapabilityPr
protected void setContainerToEmpty()
{
super.setContainerToEmpty();
container.stackSize--;
container.func_190918_g(1);
}
}
@@ -119,7 +119,7 @@ public class FluidBucketWrapper implements IFluidHandler, ICapabilityProvider
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME || container.getItem() instanceof ItemBucketMilk || getFluid() != null || !canFillFluidType(resource))
if (container.func_190916_E() != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME || container.getItem() instanceof ItemBucketMilk || getFluid() != null || !canFillFluidType(resource))
{
return 0;
}
@@ -136,7 +136,7 @@ public class FluidBucketWrapper implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME)
if (container.func_190916_E() != 1 || resource == null || resource.amount < Fluid.BUCKET_VOLUME)
{
return null;
}
@@ -158,7 +158,7 @@ public class FluidBucketWrapper implements IFluidHandler, ICapabilityProvider
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain < Fluid.BUCKET_VOLUME)
if (container.func_190916_E() != 1 || maxDrain < Fluid.BUCKET_VOLUME)
{
return null;
}
@@ -55,7 +55,7 @@ public class FluidContainerItemWrapper implements IFluidHandler, ICapabilityProv
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return 0;
}
@@ -65,7 +65,7 @@ public class FluidContainerItemWrapper implements IFluidHandler, ICapabilityProv
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
if (container.func_190916_E() != 1 || resource == null)
{
return null;
}
@@ -84,7 +84,7 @@ public class FluidContainerItemWrapper implements IFluidHandler, ICapabilityProv
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return null;
}
@@ -58,7 +58,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null)
if (container.func_190916_E() != 1 || resource == null)
{
return 0;
}
@@ -87,7 +87,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
@Override
public FluidStack drain(FluidStack resource, boolean doDrain)
{
if (container.stackSize != 1 || resource == null)
if (container.func_190916_E() != 1 || resource == null)
{
return null;
}
@@ -105,7 +105,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1)
if (container.func_190916_E() != 1)
{
return null;
}
@@ -122,7 +122,7 @@ public class FluidContainerRegistryWrapper implements IFluidHandler, ICapability
{
if (FluidContainerRegistry.hasNullEmptyContainer(container))
{
emptyContainer.stackSize = 0;
emptyContainer.func_190920_e(0);
}
container.deserializeNBT(emptyContainer.serializeNBT());
}
@@ -81,6 +81,7 @@ public class ItemStackTransformer implements IClassTransformer {
for (MethodNode m: classNode.methods)
{
if (m.name.equals("func_190923_F") || m.name.equals("func_190926_b")) continue;
for (ListIterator<AbstractInsnNode> it = m.instructions.iterator(); it.hasNext(); )
{
AbstractInsnNode insnNode = it.next();
@@ -172,29 +172,6 @@ public class EntityRegistry
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
try
{
entityClassRegistrations.put(entityClass, er);
entityNames.put(entityName, mc);
if (!EntityList.CLASS_TO_NAME.containsKey(entityClass))
{
String entityModName = String.format("%s.%s", mc.getModId(), entityName);
EntityList.CLASS_TO_NAME.put(entityClass, entityModName);
EntityList.NAME_TO_CLASS.put(entityModName, entityClass);
FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
}
else
{
FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
}
}
catch (IllegalArgumentException e)
{
FMLLog.log(Level.WARN, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
return;
}
entityRegistrations.put(mc, er);
}
/**
@@ -214,16 +191,6 @@ public class EntityRegistry
public static void registerEgg(Class<? extends Entity> entityClass, int primary, int secondary)
{
if (EntityList.CLASS_TO_NAME.containsKey(entityClass))
{
String name = EntityList.CLASS_TO_NAME.get(entityClass);
EntityList.ENTITY_EGGS.put(name, new EntityList.EntityEggInfo(name, primary, secondary));
FMLLog.fine("Registering entity egg '%s' for %s", name, entityClass);
}
else
{
FMLLog.fine("Failed registering entity egg %s (No entity found)", entityClass.getName());
}
}
/**
@@ -272,7 +239,7 @@ public class EntityRegistry
@SuppressWarnings("unchecked")
public static void addSpawn(String entityName, int weightedProb, int min, int max, EnumCreatureType typeOfCreature, Biome... biomes)
{
Class <? extends Entity > entityClazz = EntityList.NAME_TO_CLASS.get(entityName);
Class <? extends Entity > entityClazz = null;
if (EntityLiving.class.isAssignableFrom(entityClazz))
{
@@ -312,7 +279,7 @@ public class EntityRegistry
@SuppressWarnings("unchecked")
public static void removeSpawn(String entityName, EnumCreatureType typeOfCreature, Biome... biomes)
{
Class <? extends Entity > entityClazz = EntityList.NAME_TO_CLASS.get(entityName);
Class <? extends Entity > entityClazz = null;
if (EntityLiving.class.isAssignableFrom(entityClazz))
{
@@ -257,7 +257,7 @@ public class GameRegistry
public static void registerTileEntity(Class<? extends TileEntity> tileEntityClass, String id)
{
TileEntity.addMapping(tileEntityClass, id);
// TileEntity.addMapping(tileEntityClass, id);
}
/**
@@ -270,7 +270,7 @@ public class GameRegistry
*/
public static void registerTileEntityWithAlternatives(Class<? extends TileEntity> tileEntityClass, String id, String... alternatives)
{
TileEntity.addMapping(tileEntityClass, id);
// TileEntity.addMapping(tileEntityClass, id);
Map<String, Class<?>> teMappings = ObfuscationReflectionHelper.getPrivateValue(TileEntity.class, null, "field_" + "145855_i", "nameToClassMap");
for (String s : alternatives)
{
@@ -25,10 +25,10 @@ import java.util.Map;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.entity.monster.EntityZombieVillager;
import org.apache.commons.lang3.Validate;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.monster.ZombieType;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityVillager.ITradeList;
import net.minecraft.util.EnumFacing;
@@ -315,10 +315,9 @@ public class VillagerRegistry
List<VillagerProfession> entries = INSTANCE.professions.getValues();
entity.setProfession(entries.get(rand.nextInt(entries.size())));
}
public static void setRandomProfession(EntityZombie entity, Random rand)
public static void setRandomProfession(EntityZombieVillager entity, Random rand)
{
List<VillagerProfession> entries = INSTANCE.professions.getValues();
entity.setVillagerType(entries.get(rand.nextInt(entries.size())));
}
@@ -352,50 +351,21 @@ public class VillagerRegistry
}
@SuppressWarnings("deprecation")
public static void onSetProfession(EntityZombie entity, VillagerProfession prof)
public static void onSetProfession(EntityZombieVillager entity, VillagerProfession prof)
{
if (prof == null)
{
if (entity.getZombieType() != ZombieType.NORMAL && entity.getZombieType() != ZombieType.HUSK)
entity.setZombieType(ZombieType.NORMAL);
return;
}
int network = INSTANCE.professions.getId(prof);
if (network == -1 || prof != INSTANCE.professions.getObjectById(network))
{
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + network + " " + prof);
}
if (network >= 0 && network < 5) // Vanilla
{
if (entity.getZombieType() == null || entity.getZombieType().getId() != network + 1)
{
entity.setZombieType(ZombieType.getVillagerByOrdinal(network));
}
}
else if (entity.getZombieType() != null)
entity.setZombieType(ZombieType.NORMAL);
}
public static void onSetProfession(EntityZombie entity, ZombieType type, int network)
public static void onSetProfession(EntityZombieVillager entity, int network)
{
if (type == ZombieType.NORMAL || type == ZombieType.HUSK)
{
if (entity.getVillagerTypeForge() != null)
entity.setVillagerType(null);
return;
}
int realID = network - 1;
if (type == null) //Forge type?
realID = network * -1; // Forge encoded as -ID
VillagerProfession prof = INSTANCE.professions.getObjectById(realID);
if (prof == null && network != 0 || INSTANCE.professions.getId(prof) != realID)
{
throw new RuntimeException("Attempted to set villager profession to unregistered profession: " + realID + " " + prof);
}
if (prof != entity.getVillagerTypeForge())
entity.setVillagerType(prof);
if (prof != entity.getForgeProfession())
entity.setForgeProfession(prof);
}
@Deprecated public static VillagerProfession getById(int network){ return INSTANCE.professions.getObjectById(network); }
@@ -72,7 +72,7 @@ public class CapabilityItemHandler
if (j >= 0 && j < instance.getSlots())
{
itemHandlerModifiable.setStackInSlot(j, ItemStack.loadItemStackFromNBT(itemTags));
itemHandlerModifiable.setStackInSlot(j, new ItemStack(itemTags));
}
}
}
@@ -21,6 +21,8 @@ package net.minecraftforge.items;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public interface IItemHandler
{
/**
@@ -49,6 +51,7 @@ public interface IItemHandler
* @param slot Slot to query
* @return ItemStack in given slot. May be null.
**/
@Nonnull
ItemStack getStackInSlot(int slot);
/**
@@ -62,7 +65,8 @@ public interface IItemHandler
* @return The remaining ItemStack that was not inserted (if the entire stack is accepted, then return null).
* May be the same as the input ItemStack if unchanged, otherwise a new ItemStack.
**/
ItemStack insertItem(int slot, ItemStack stack, boolean simulate);
@Nonnull
ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate);
/**
* Extracts an ItemStack from the given slot. The returned value must be null
@@ -74,5 +78,6 @@ public interface IItemHandler
* @param simulate If true, the extraction is only simulated
* @return ItemStack extracted from the slot, must be null, if nothing can be extracted
**/
@Nonnull
ItemStack extractItem(int slot, int amount, boolean simulate);
}
@@ -21,6 +21,8 @@ package net.minecraftforge.items;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public interface IItemHandlerModifiable extends IItemHandler
{
/**
@@ -34,5 +36,5 @@ public interface IItemHandlerModifiable extends IItemHandler
* @throws RuntimeException if the handler is called in a way that the handler
* was not expecting.
**/
void setStackInSlot(int slot, ItemStack stack);
void setStackInSlot(int slot, @Nonnull ItemStack stack);
}
@@ -28,19 +28,22 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import net.minecraftforge.items.wrapper.PlayerMainInvWrapper;
import javax.annotation.Nonnull;
public class ItemHandlerHelper
{
public static ItemStack insertItem(IItemHandler dest, ItemStack stack, boolean simulate)
@Nonnull
public static ItemStack insertItem(IItemHandler dest, @Nonnull ItemStack stack, boolean simulate)
{
if (dest == null || stack == null)
return stack;
if (dest == null || stack.func_190926_b())
return ItemStack.field_190927_a;
for (int i = 0; i < dest.getSlots(); i++)
{
stack = dest.insertItem(i, stack, simulate);
if (stack == null || stack.stackSize <= 0)
if (stack.func_190926_b())
{
return null;
return ItemStack.field_190927_a;
}
}
@@ -80,13 +83,13 @@ public class ItemHandlerHelper
return (aTag != null || bTag == null) && (aTag == null || aTag.equals(bTag));
}
@Nonnull
public static ItemStack copyStackWithSize(ItemStack itemStack, int size)
{
if (size == 0)
return null;
ItemStack copy = ItemStack.copyItemStack(itemStack);
if (copy != null)
copy.stackSize = size;
return ItemStack.field_190927_a;
ItemStack copy = itemStack.copy();
copy.func_190920_e(size);
return copy;
}
@@ -174,7 +177,7 @@ public class ItemHandlerHelper
}
// play sound if something got picked up
if (remainder == null || remainder.stackSize != stack.stackSize)
if (remainder == null || remainder.func_190916_E() != stack.func_190916_E())
{
world.playSound(player, player.posX, player.posY, player.posZ,
SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
@@ -22,12 +22,15 @@ package net.minecraftforge.items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.NonNullList;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.INBTSerializable;
import javax.annotation.Nonnull;
public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, INBTSerializable<NBTTagCompound>
{
protected ItemStack[] stacks;
protected NonNullList<ItemStack> stacks;
public ItemStackHandler()
{
@@ -36,102 +39,105 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
public ItemStackHandler(int size)
{
stacks = new ItemStack[size];
stacks = NonNullList.func_191196_a();
}
public ItemStackHandler(ItemStack[] stacks)
public ItemStackHandler(NonNullList<ItemStack> stacks)
{
this.stacks = stacks;
}
public void setSize(int size)
{
stacks = new ItemStack[size];
stacks = NonNullList.func_191197_a(size, ItemStack.field_190927_a);
}
@Override
public void setStackInSlot(int slot, ItemStack stack)
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{
validateSlotIndex(slot);
if (ItemStack.areItemStacksEqual(this.stacks[slot], stack))
if (ItemStack.areItemStacksEqual(this.stacks.get(slot), stack))
return;
this.stacks[slot] = stack;
this.stacks.set(slot, stack);
onContentsChanged(slot);
}
@Override
public int getSlots()
{
return stacks.length;
return stacks.size();
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
validateSlotIndex(slot);
return this.stacks[slot];
return this.stacks.get(slot);
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (stack == null || stack.stackSize == 0)
return null;
if (stack.func_190926_b())
return ItemStack.field_190927_a;
validateSlotIndex(slot);
ItemStack existing = this.stacks[slot];
ItemStack existing = this.stacks.get(slot);
int limit = getStackLimit(slot, stack);
if (existing != null)
if (!existing.func_190926_b())
{
if (!ItemHandlerHelper.canItemStacksStack(stack, existing))
return stack;
limit -= existing.stackSize;
limit -= existing.func_190916_E();
}
if (limit <= 0)
return stack;
boolean reachedLimit = stack.stackSize > limit;
boolean reachedLimit = stack.func_190916_E() > limit;
if (!simulate)
{
if (existing == null)
if (existing.func_190926_b())
{
this.stacks[slot] = reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack;
this.stacks.set(slot, reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, limit) : stack);
}
else
{
existing.stackSize += reachedLimit ? limit : stack.stackSize;
existing.func_190917_f(reachedLimit ? limit : stack.func_190916_E());
}
onContentsChanged(slot);
}
return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.stackSize - limit) : null;
return reachedLimit ? ItemHandlerHelper.copyStackWithSize(stack, stack.func_190916_E()- limit) : ItemStack.field_190927_a;
}
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
if (amount == 0)
return null;
return ItemStack.field_190927_a;
validateSlotIndex(slot);
ItemStack existing = this.stacks[slot];
ItemStack existing = this.stacks.get(slot);
if (existing == null)
return null;
if (existing.func_190926_b())
return ItemStack.field_190927_a;
int toExtract = Math.min(amount, existing.getMaxStackSize());
if (existing.stackSize <= toExtract)
if (existing.func_190916_E() <= toExtract)
{
if (!simulate)
{
this.stacks[slot] = null;
this.stacks.set(slot, ItemStack.field_190927_a);
onContentsChanged(slot);
}
return existing;
@@ -140,7 +146,7 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
{
if (!simulate)
{
this.stacks[slot] = ItemHandlerHelper.copyStackWithSize(existing, existing.stackSize - toExtract);
this.stacks.set(slot, ItemHandlerHelper.copyStackWithSize(existing, existing.func_190916_E() - toExtract));
onContentsChanged(slot);
}
@@ -157,35 +163,35 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
public NBTTagCompound serializeNBT()
{
NBTTagList nbtTagList = new NBTTagList();
for (int i = 0; i < stacks.length; i++)
for (int i = 0; i < stacks.size(); i++)
{
if (stacks[i] != null)
if (!stacks.get(i).func_190926_b())
{
NBTTagCompound itemTag = new NBTTagCompound();
itemTag.setInteger("Slot", i);
stacks[i].writeToNBT(itemTag);
stacks.get(i).writeToNBT(itemTag);
nbtTagList.appendTag(itemTag);
}
}
NBTTagCompound nbt = new NBTTagCompound();
nbt.setTag("Items", nbtTagList);
nbt.setInteger("Size", stacks.length);
nbt.setInteger("Size", stacks.size());
return nbt;
}
@Override
public void deserializeNBT(NBTTagCompound nbt)
{
setSize(nbt.hasKey("Size", Constants.NBT.TAG_INT) ? nbt.getInteger("Size") : stacks.length);
setSize(nbt.hasKey("Size", Constants.NBT.TAG_INT) ? nbt.getInteger("Size") : stacks.size());
NBTTagList tagList = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound itemTags = tagList.getCompoundTagAt(i);
int slot = itemTags.getInteger("Slot");
if (slot >= 0 && slot < stacks.length)
if (slot >= 0 && slot < stacks.size())
{
stacks[slot] = ItemStack.loadItemStackFromNBT(itemTags);
stacks.set(slot, new ItemStack(itemTags));
}
}
onLoad();
@@ -193,8 +199,8 @@ public class ItemStackHandler implements IItemHandler, IItemHandlerModifiable, I
protected void validateSlotIndex(int slot)
{
if (slot < 0 || slot >= stacks.length)
throw new RuntimeException("Slot " + slot + " not in valid range - [0," + stacks.length + ")");
if (slot < 0 || slot >= stacks.size())
throw new RuntimeException("Slot " + slot + " not in valid range - [0," + stacks.size() + ")");
}
protected void onLoad()
@@ -25,6 +25,8 @@ import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class SlotItemHandler extends Slot
{
private static IInventory emptyInventory = new InventoryBasic("[Null]", true, 0);
@@ -39,9 +41,9 @@ public class SlotItemHandler extends Slot
}
@Override
public boolean isItemValid(ItemStack stack)
public boolean isItemValid(@Nonnull ItemStack stack)
{
if (stack == null)
if (stack.func_190926_b())
return false;
IItemHandler handler = this.getItemHandler();
@@ -51,7 +53,7 @@ public class SlotItemHandler extends Slot
IItemHandlerModifiable handlerModifiable = (IItemHandlerModifiable) handler;
ItemStack currentStack = handlerModifiable.getStackInSlot(index);
handlerModifiable.setStackInSlot(index, null);
handlerModifiable.setStackInSlot(index, ItemStack.field_190927_a);
remainder = handlerModifiable.insertItem(index, stack, true);
@@ -61,10 +63,11 @@ public class SlotItemHandler extends Slot
{
remainder = handler.insertItem(index, stack, true);
}
return remainder == null || remainder.stackSize < stack.stackSize;
return remainder == null || remainder.func_190916_E() < stack.func_190916_E();
}
@Override
@Nonnull
public ItemStack getStack()
{
return this.getItemHandler().getStackInSlot(index);
@@ -72,44 +75,44 @@ public class SlotItemHandler extends Slot
// Override if your IItemHandler does not implement IItemHandlerModifiable
@Override
public void putStack(ItemStack stack)
public void putStack(@Nonnull ItemStack stack)
{
((IItemHandlerModifiable) this.getItemHandler()).setStackInSlot(index, stack);
this.onSlotChanged();
}
@Override
public void onSlotChange(ItemStack p_75220_1_, ItemStack p_75220_2_)
public void onSlotChange(@Nonnull ItemStack p_75220_1_, @Nonnull ItemStack p_75220_2_)
{
}
@Override
public int getItemStackLimit(ItemStack stack)
public int getItemStackLimit(@Nonnull ItemStack stack)
{
ItemStack maxAdd = stack.copy();
int maxInput = stack.getMaxStackSize();
maxAdd.stackSize = maxInput;
maxAdd.func_190920_e(maxInput);
IItemHandler handler = this.getItemHandler();
ItemStack currentStack = handler.getStackInSlot(index);
if (handler instanceof IItemHandlerModifiable) {
IItemHandlerModifiable handlerModifiable = (IItemHandlerModifiable) handler;
handlerModifiable.setStackInSlot(index, null);
handlerModifiable.setStackInSlot(index, ItemStack.field_190927_a);
ItemStack remainder = handlerModifiable.insertItem(index, maxAdd, true);
handlerModifiable.setStackInSlot(index, currentStack);
return maxInput - (remainder != null ? remainder.stackSize : 0);
return maxInput - remainder.func_190916_E();
}
else
{
ItemStack remainder = handler.insertItem(index, maxAdd, true);
int current = currentStack == null ? 0 : currentStack.stackSize;
int added = maxInput - (remainder != null ? remainder.stackSize : 0);
int current = currentStack.func_190916_E();
int added = maxInput - remainder.func_190916_E();
return current + added;
}
}
@@ -117,10 +120,11 @@ public class SlotItemHandler extends Slot
@Override
public boolean canTakeStack(EntityPlayer playerIn)
{
return this.getItemHandler().extractItem(index, 1, true) != null;
return !this.getItemHandler().extractItem(index, 1, true).func_190926_b();
}
@Override
@Nonnull
public ItemStack decrStackSize(int amount)
{
return this.getItemHandler().extractItem(index, amount, false);
@@ -31,6 +31,8 @@ import java.lang.ref.WeakReference;
import com.google.common.base.Objects;
import javax.annotation.Nonnull;
public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest> implements IItemHandlerModifiable
{
// Dummy cache value to signify that we have checked and definitely found no adjacent chests
@@ -102,16 +104,17 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
TileEntityChest chest = getChest(accessingUpperChest);
return chest != null ? chest.getStackInSlot(targetSlot) : null;
return chest != null ? chest.getStackInSlot(targetSlot) : ItemStack.field_190927_a;
}
@Override
public void setStackInSlot(int slot, ItemStack stack)
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
@@ -127,7 +130,8 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
@@ -136,12 +140,13 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
}
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
boolean accessingUpperChest = slot < 27;
int targetSlot = accessingUpperChest ? slot : slot - 27;
TileEntityChest chest = getChest(accessingUpperChest);
return chest != null ? chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate) : null;
return chest != null ? chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate) : ItemStack.field_190927_a;
}
@Override
@@ -23,6 +23,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraftforge.items.wrapper.InvWrapper;
import javax.annotation.Nonnull;
public class VanillaHopperItemHandler extends InvWrapper
{
private final TileEntityHopper hopper;
@@ -34,19 +36,20 @@ public class VanillaHopperItemHandler extends InvWrapper
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (stack == null)
return null;
if (simulate || !hopper.mayTransfer())
return super.insertItem(slot, stack, simulate);
// if (simulate || !hopper.mayTransfer())
// return super.insertItem(slot, stack, simulate);
int curStackSize = stack.stackSize;
int curStackSize = stack.func_190916_E();
ItemStack itemStack = super.insertItem(slot, stack, false);
if (itemStack == null || curStackSize != itemStack.stackSize)
{
hopper.setTransferCooldown(8);
}
// if (itemStack == null || curStackSize != itemStack.func_190916_E())
// {
// hopper.setTransferCooldown(8);
// }
return itemStack;
}
}
@@ -30,6 +30,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class VanillaInventoryCodeHooks
{
//Return: Null if we did nothing {no IItemHandler}, True if we moved an item, False if we moved no items
@@ -50,14 +52,14 @@ public class VanillaInventoryCodeHooks
for (int j = 0; j < dest.getSizeInventory(); j++)
{
ItemStack destStack = dest.getStackInSlot(j);
if (destStack == null || destStack.stackSize < destStack.getMaxStackSize() && destStack.stackSize < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack))
if (destStack == null || destStack.func_190916_E() < destStack.getMaxStackSize() && destStack.func_190916_E() < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack))
{
extractItem = handler.extractItem(i, 1, false);
if (destStack == null)
dest.setInventorySlotContents(j, extractItem);
else
{
destStack.stackSize++;
destStack.func_190917_f(1);
dest.setInventorySlotContents(j, destStack);
}
dest.markDirty();
@@ -70,7 +72,7 @@ public class VanillaInventoryCodeHooks
return false;
}
public static boolean dropperInsertHook(World world, BlockPos pos, TileEntityDispenser dropper, int slot, ItemStack stack)
public static boolean dropperInsertHook(World world, BlockPos pos, TileEntityDispenser dropper, int slot, @Nonnull ItemStack stack)
{
EnumFacing enumfacing = world.getBlockState(pos).getValue(BlockDropper.FACING);
BlockPos offsetPos = pos.offset(enumfacing);
@@ -84,14 +86,10 @@ public class VanillaInventoryCodeHooks
ItemStack result = ItemHandlerHelper.insertItem(capability, ItemHandlerHelper.copyStackWithSize(stack, 1), false);
if (result == null)
if (result.func_190926_b())
{
result = stack.copy();
if (--result.stackSize == 0)
{
result = null;
}
result.func_190918_g(1);
}
else
{
@@ -125,9 +123,9 @@ public class VanillaInventoryCodeHooks
if (stackInSlot != null)
{
ItemStack insert = stackInSlot.copy();
insert.stackSize = 1;
insert.func_190920_e(1);
ItemStack newStack = ItemHandlerHelper.insertItem(handler, insert, true);
if (newStack == null || newStack.stackSize == 0)
if (newStack.func_190926_b())
{
ItemHandlerHelper.insertItem(handler, hopper.decrStackSize(i, 1), false);
hopper.markDirty();
@@ -22,6 +22,8 @@ package net.minecraftforge.items.wrapper;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
// combines multiple IItemHandlerModifiable into one interface
public class CombinedInvWrapper implements IItemHandlerModifiable
{
@@ -78,7 +80,7 @@ public class CombinedInvWrapper implements IItemHandlerModifiable
}
@Override
public void setStackInSlot(int slot, ItemStack stack)
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{
int index = getIndexForSlot(slot);
IItemHandlerModifiable handler = getHandlerFromIndex(index);
@@ -93,6 +95,7 @@ public class CombinedInvWrapper implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
int index = getIndexForSlot(slot);
@@ -102,7 +105,8 @@ public class CombinedInvWrapper implements IItemHandlerModifiable
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
int index = getIndexForSlot(slot);
IItemHandlerModifiable handler = getHandlerFromIndex(index);
@@ -111,6 +115,7 @@ public class CombinedInvWrapper implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
int index = getIndexForSlot(slot);
@@ -23,6 +23,8 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
public class EmptyHandler implements IItemHandlerModifiable
{
public static final IItemHandler INSTANCE = new EmptyHandler();
@@ -34,25 +36,28 @@ public class EmptyHandler implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
return null;
return ItemStack.field_190927_a;
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
return stack;
}
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
return null;
return ItemStack.field_190927_a;
}
@Override
public void setStackInSlot(int slot, ItemStack stack)
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{
// nothing to do here
}
@@ -24,6 +24,8 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
public class InvWrapper implements IItemHandlerModifiable
{
private final IInventory inv;
@@ -60,13 +62,15 @@ public class InvWrapper implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
return getInv().getStackInSlot(slot);
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (stack == null)
return null;
@@ -77,19 +81,19 @@ public class InvWrapper implements IItemHandlerModifiable
ItemStack stackInSlot = getInv().getStackInSlot(slot);
int m;
if (stackInSlot != null)
if (!stackInSlot.func_190926_b())
{
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit()) - stackInSlot.stackSize;
m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit()) - stackInSlot.func_190916_E();
if (stack.stackSize <= m)
if (stack.func_190916_E() <= m)
{
if (!simulate)
{
ItemStack copy = stack.copy();
copy.stackSize += stackInSlot.stackSize;
copy.func_190918_g(stackInSlot.func_190916_E());
getInv().setInventorySlotContents(slot, copy);
getInv().markDirty();
}
@@ -103,14 +107,14 @@ public class InvWrapper implements IItemHandlerModifiable
if (!simulate)
{
ItemStack copy = stack.splitStack(m);
copy.stackSize += stackInSlot.stackSize;
copy.func_190917_f(stackInSlot.func_190916_E());
getInv().setInventorySlotContents(slot, copy);
getInv().markDirty();
return stack;
}
else
{
stack.stackSize -= m;
stack.func_190918_g(m);
return stack;
}
}
@@ -118,7 +122,7 @@ public class InvWrapper implements IItemHandlerModifiable
else
{
m = Math.min(stack.getMaxStackSize(), getInv().getInventoryStackLimit());
if (m < stack.stackSize)
if (m < stack.func_190916_E())
{
// copy the stack to not modify the original one
stack = stack.copy();
@@ -130,7 +134,7 @@ public class InvWrapper implements IItemHandlerModifiable
}
else
{
stack.stackSize -= m;
stack.func_190918_g(m);
return stack;
}
}
@@ -148,6 +152,7 @@ public class InvWrapper implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
if (amount == 0)
@@ -160,20 +165,20 @@ public class InvWrapper implements IItemHandlerModifiable
if (simulate)
{
if (stackInSlot.stackSize < amount)
if (stackInSlot.func_190916_E() < amount)
{
return stackInSlot.copy();
}
else
{
ItemStack copy = stackInSlot.copy();
copy.stackSize = amount;
copy.func_190920_e(amount);
return copy;
}
}
else
{
int m = Math.min(stackInSlot.stackSize, amount);
int m = Math.min(stackInSlot.func_190916_E(), amount);
ItemStack decrStackSize = getInv().decrStackSize(slot, m);
getInv().markDirty();
@@ -23,18 +23,21 @@ import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
public class PlayerArmorInvWrapper extends RangedWrapper
{
private final InventoryPlayer inventoryPlayer;
public PlayerArmorInvWrapper(InventoryPlayer inv)
{
super(new InvWrapper(inv), inv.mainInventory.length, inv.mainInventory.length + inv.armorInventory.length);
super(new InvWrapper(inv), inv.mainInventory.size(), inv.mainInventory.size() + inv.armorInventory.size());
inventoryPlayer = inv;
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
EntityEquipmentSlot equ = null;
for (EntityEquipmentSlot s : EntityEquipmentSlot.values())
@@ -46,7 +49,7 @@ public class PlayerArmorInvWrapper extends RangedWrapper
}
}
// check if it's valid for the armor slot
if (slot < 4 && stack != null && stack.getItem().isValidArmor(stack, equ, getInventoryPlayer().player))
if (equ != null && slot < 4 && !stack.func_190926_b() && stack.getItem().isValidArmor(stack, equ, getInventoryPlayer().player))
{
return super.insertItem(slot, stack, simulate);
}
@@ -23,6 +23,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import javax.annotation.Nonnull;
/**
* Exposes the player inventory WITHOUT the armor inventory as IItemHandler.
* Also takes core of inserting/extracting having the same logic as picking up items.
@@ -33,23 +35,24 @@ public class PlayerMainInvWrapper extends RangedWrapper
public PlayerMainInvWrapper(InventoryPlayer inv)
{
super(new InvWrapper(inv), 0, inv.mainInventory.length);
super(new InvWrapper(inv), 0, inv.mainInventory.size());
inventoryPlayer = inv;
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
ItemStack rest = super.insertItem(slot, stack, simulate);
if (rest == null || rest.stackSize != stack.stackSize)
if (rest.func_190916_E()!= stack.func_190916_E())
{
// the stack in the slot changed, animate it
ItemStack inSlot = getStackInSlot(slot);
if(inSlot != null)
if(!inSlot.func_190926_b())
{
if (getInventoryPlayer().player.worldObj.isRemote)
{
inSlot.animationsToGo = 5;
inSlot.func_190915_d(5);
}
else if(getInventoryPlayer().player instanceof EntityPlayerMP) {
getInventoryPlayer().player.openContainer.detectAndSendChanges();
@@ -25,7 +25,7 @@ public class PlayerOffhandInvWrapper extends RangedWrapper
{
public PlayerOffhandInvWrapper(InventoryPlayer inv)
{
super(new InvWrapper(inv), inv.mainInventory.length + inv.armorInventory.length,
inv.mainInventory.length + inv.armorInventory.length + inv.offHandInventory.length);
super(new InvWrapper(inv), inv.mainInventory.size() + inv.armorInventory.size(),
inv.mainInventory.size() + inv.armorInventory.size() + inv.offHandInventory.size());
}
}
@@ -23,6 +23,8 @@ import com.google.common.base.Preconditions;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandlerModifiable;
import javax.annotation.Nonnull;
/**
* A wrapper that composes another IItemHandlerModifiable, exposing only a range of the composed slots.
* Shifting of slot indices is handled automatically for you.
@@ -48,6 +50,7 @@ public class RangedWrapper implements IItemHandlerModifiable {
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
if (checkSlot(slot))
@@ -59,7 +62,8 @@ public class RangedWrapper implements IItemHandlerModifiable {
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (checkSlot(slot))
{
@@ -70,6 +74,7 @@ public class RangedWrapper implements IItemHandlerModifiable {
}
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
if (checkSlot(slot))
@@ -77,7 +82,7 @@ public class RangedWrapper implements IItemHandlerModifiable {
return compose.extractItem(slot + minSlot, amount, simulate);
}
return null;
return ItemStack.field_190927_a;
}
@Override
@@ -25,6 +25,8 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper;
import javax.annotation.Nonnull;
public class SidedInvWrapper implements IItemHandlerModifiable
{
protected final ISidedInventory inv;
@@ -72,18 +74,19 @@ public class SidedInvWrapper implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack getStackInSlot(int slot)
{
int i = getSlot(inv, slot, side);
return i == -1 ? null : inv.getStackInSlot(i);
return i == -1 ? ItemStack.field_190927_a : inv.getStackInSlot(i);
}
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate)
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (stack == null)
return null;
if (stack.func_190926_b())
return ItemStack.field_190927_a;
int slot1 = getSlot(inv, slot, side);
@@ -96,23 +99,23 @@ public class SidedInvWrapper implements IItemHandlerModifiable
ItemStack stackInSlot = inv.getStackInSlot(slot1);
int m;
if (stackInSlot != null)
if (!stackInSlot.func_190926_b())
{
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - stackInSlot.stackSize;
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit()) - stackInSlot.func_190916_E();
if (stack.stackSize <= m)
if (stack.func_190916_E() <= m)
{
if (!simulate)
{
ItemStack copy = stack.copy();
copy.stackSize += stackInSlot.stackSize;
copy.func_190917_f(stackInSlot.func_190916_E());
inv.setInventorySlotContents(slot1, copy);
}
return null;
return ItemStack.field_190927_a;
}
else
{
@@ -121,13 +124,13 @@ public class SidedInvWrapper implements IItemHandlerModifiable
if (!simulate)
{
ItemStack copy = stack.splitStack(m);
copy.stackSize += stackInSlot.stackSize;
copy.func_190917_f(stackInSlot.func_190916_E());
inv.setInventorySlotContents(slot1, copy);
return stack;
}
else
{
stack.stackSize -= m;
stack.func_190918_g(m);
return stack;
}
}
@@ -135,7 +138,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
else
{
m = Math.min(stack.getMaxStackSize(), inv.getInventoryStackLimit());
if (m < stack.stackSize)
if (m < stack.func_190916_E())
{
// copy the stack to not modify the original one
stack = stack.copy();
@@ -146,7 +149,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
}
else
{
stack.stackSize -= m;
stack.func_190918_g(m);
return stack;
}
}
@@ -154,14 +157,14 @@ public class SidedInvWrapper implements IItemHandlerModifiable
{
if (!simulate)
inv.setInventorySlotContents(slot1, stack);
return null;
return ItemStack.field_190927_a;
}
}
}
@Override
public void setStackInSlot(int slot, ItemStack stack)
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
{
int slot1 = getSlot(inv, slot, side);
@@ -170,40 +173,41 @@ public class SidedInvWrapper implements IItemHandlerModifiable
}
@Override
@Nonnull
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
if (amount == 0)
return null;
return ItemStack.field_190927_a;
int slot1 = getSlot(inv, slot, side);
if (slot1 == -1)
return null;
return ItemStack.field_190927_a;
ItemStack stackInSlot = inv.getStackInSlot(slot1);
if (stackInSlot == null)
return null;
if (stackInSlot.func_190926_b())
return ItemStack.field_190927_a;
if (!inv.canExtractItem(slot1, stackInSlot, side))
return null;
return ItemStack.field_190927_a;
if (simulate)
{
if (stackInSlot.stackSize < amount)
if (stackInSlot.func_190916_E() < amount)
{
return stackInSlot.copy();
}
else
{
ItemStack copy = stackInSlot.copy();
copy.stackSize = amount;
copy.func_190920_e(amount);
return copy;
}
}
else
{
int m = Math.min(stackInSlot.stackSize, amount);
int m = Math.min(stackInSlot.func_190916_E(), amount);
return inv.decrStackSize(slot1, m);
}
}
@@ -30,6 +30,7 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
@@ -276,7 +277,7 @@ public class ShapedOreRecipe implements IRecipe
}
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv) //getRecipeLeftovers
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) //getRecipeLeftovers
{
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
}
@@ -30,6 +30,7 @@ import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
@@ -166,7 +167,7 @@ public class ShapelessOreRecipe implements IRecipe
}
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv) //getRecipeLeftovers
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) //getRecipeLeftovers
{
return ForgeHooks.defaultRecipeGetRemainingItems(inv);
}