Also updated IItemHandler javadocs to reflect returning EMPTY instead of NULL.
This commit is contained in:
parent
cec90d7f48
commit
c0eea379a4
4 changed files with 50 additions and 16 deletions
|
@ -242,13 +242,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "com.mojang:realms:1.10.14",
|
"name": "com.mojang:realms:1.10.16",
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"artifact": {
|
"artifact": {
|
||||||
"size": 3162566,
|
"size": 3257394,
|
||||||
"sha1": "f08caf995313992fcfe03bc12234748328471d0a",
|
"sha1": "b4948eb06ff238e45044f47aa69c2c977ce69dcb",
|
||||||
"path": "com/mojang/realms/1.10.14/realms-1.10.14.jar",
|
"path": "com/mojang/realms/1.10.16/realms-1.10.16.jar",
|
||||||
"url": "https://libraries.minecraft.net/com/mojang/realms/1.10.14/realms-1.10.14.jar"
|
"url": "https://libraries.minecraft.net/com/mojang/realms/1.10.16/realms-1.10.16.jar"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -558,6 +558,6 @@
|
||||||
"minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userType ${user_type} --versionType ${version_type}",
|
"minecraftArguments": "--username ${auth_player_name} --version ${version_name} --gameDir ${game_directory} --assetsDir ${assets_root} --assetIndex ${assets_index_name} --uuid ${auth_uuid} --accessToken ${auth_access_token} --userType ${user_type} --versionType ${version_type}",
|
||||||
"minimumLauncherVersion": 18,
|
"minimumLauncherVersion": 18,
|
||||||
"releaseTime": "2016-12-21T09:29:12+00:00",
|
"releaseTime": "2016-12-21T09:29:12+00:00",
|
||||||
"time": "2017-02-27T10:13:05+00:00",
|
"time": "2017-04-07T11:44:29+00:00",
|
||||||
"type": "release"
|
"type": "release"
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public interface IItemHandler
|
||||||
* @param slot Slot to insert into.
|
* @param slot Slot to insert into.
|
||||||
* @param stack ItemStack to insert.
|
* @param stack ItemStack to insert.
|
||||||
* @param simulate If true, the insertion is only simulated
|
* @param simulate If true, the insertion is only simulated
|
||||||
* @return The remaining ItemStack that was not inserted (if the entire stack is accepted, then return null).
|
* @return The remaining ItemStack that was not inserted (if the entire stack is accepted, then return ItemStack.EMPTY).
|
||||||
* May be the same as the input ItemStack if unchanged, otherwise a new ItemStack.
|
* May be the same as the input ItemStack if unchanged, otherwise a new ItemStack.
|
||||||
**/
|
**/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -76,7 +76,7 @@ public interface IItemHandler
|
||||||
* @param slot Slot to extract from.
|
* @param slot Slot to extract from.
|
||||||
* @param amount Amount to extract (may be greater than the current stacks max limit)
|
* @param amount Amount to extract (may be greater than the current stacks max limit)
|
||||||
* @param simulate If true, the extraction is only simulated
|
* @param simulate If true, the extraction is only simulated
|
||||||
* @return ItemStack extracted from the slot, must be null, if nothing can be extracted
|
* @return ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
|
||||||
**/
|
**/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
ItemStack extractItem(int slot, int amount, boolean simulate);
|
ItemStack extractItem(int slot, int amount, boolean simulate);
|
||||||
|
|
|
@ -131,6 +131,10 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||||
((IItemHandlerModifiable) singleHandler).setStackInSlot(targetSlot, stack);
|
((IItemHandlerModifiable) singleHandler).setStackInSlot(targetSlot, stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chest = getChest(!accessingUpperChest);
|
||||||
|
if (chest != null)
|
||||||
|
chest.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,7 +144,19 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||||
boolean accessingUpperChest = slot < 27;
|
boolean accessingUpperChest = slot < 27;
|
||||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||||
TileEntityChest chest = getChest(accessingUpperChest);
|
TileEntityChest chest = getChest(accessingUpperChest);
|
||||||
return chest != null ? chest.getSingleChestHandler().insertItem(targetSlot, stack, simulate) : stack;
|
if (chest == null)
|
||||||
|
return stack;
|
||||||
|
|
||||||
|
int starting = stack.getCount();
|
||||||
|
ItemStack ret = chest.getSingleChestHandler().insertItem(targetSlot, stack, simulate);
|
||||||
|
if (ret.getCount() != starting && !simulate)
|
||||||
|
{
|
||||||
|
chest = getChest(!accessingUpperChest);
|
||||||
|
if (chest != null)
|
||||||
|
chest.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -150,7 +166,18 @@ public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest
|
||||||
boolean accessingUpperChest = slot < 27;
|
boolean accessingUpperChest = slot < 27;
|
||||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||||
TileEntityChest chest = getChest(accessingUpperChest);
|
TileEntityChest chest = getChest(accessingUpperChest);
|
||||||
return chest != null ? chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate) : ItemStack.EMPTY;
|
if (chest == null)
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
|
||||||
|
ItemStack ret = chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate);
|
||||||
|
if (!ret.isEmpty() && !simulate)
|
||||||
|
{
|
||||||
|
chest = getChest(!accessingUpperChest);
|
||||||
|
if (chest != null)
|
||||||
|
chest.markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
{
|
{
|
||||||
ItemStack copy = stack.copy();
|
ItemStack copy = stack.copy();
|
||||||
copy.grow(stackInSlot.getCount());
|
copy.grow(stackInSlot.getCount());
|
||||||
inv.setInventorySlotContents(slot1, copy);
|
setInventorySlotContents(slot1, copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
@ -125,7 +125,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
{
|
{
|
||||||
ItemStack copy = stack.splitStack(m);
|
ItemStack copy = stack.splitStack(m);
|
||||||
copy.grow(stackInSlot.getCount());
|
copy.grow(stackInSlot.getCount());
|
||||||
inv.setInventorySlotContents(slot1, copy);
|
setInventorySlotContents(slot1, copy);
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -147,7 +147,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
stack = stack.copy();
|
stack = stack.copy();
|
||||||
if (!simulate)
|
if (!simulate)
|
||||||
{
|
{
|
||||||
inv.setInventorySlotContents(slot1, stack.splitStack(m));
|
setInventorySlotContents(slot1, stack.splitStack(m));
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -159,7 +159,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!simulate)
|
if (!simulate)
|
||||||
inv.setInventorySlotContents(slot1, stack);
|
setInventorySlotContents(slot1, stack);
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,12 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
int slot1 = getSlot(inv, slot, side);
|
int slot1 = getSlot(inv, slot, side);
|
||||||
|
|
||||||
if (slot1 != -1)
|
if (slot1 != -1)
|
||||||
inv.setInventorySlotContents(slot1, stack);
|
setInventorySlotContents(slot1, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setInventorySlotContents(int slot, ItemStack stack) {
|
||||||
|
inv.markDirty(); //Notify vanilla of updates, We change the handler to be responsible for this instead of the caller. So mimic vanilla behavior
|
||||||
|
inv.setInventorySlotContents(slot, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -211,7 +216,9 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int m = Math.min(stackInSlot.getCount(), amount);
|
int m = Math.min(stackInSlot.getCount(), amount);
|
||||||
return inv.decrStackSize(slot1, m);
|
ItemStack ret = inv.decrStackSize(slot1, m);
|
||||||
|
inv.markDirty();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue