ForgePatch/src/main/java/net/minecraftforge/items/wrapper/SidedInvWrapper.java

254 lines
7.2 KiB
Java
Raw Normal View History

/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
package net.minecraftforge.items.wrapper;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
2019-05-23 23:02:15 +00:00
import net.minecraft.util.Direction;
import net.minecraftforge.common.util.LazyOptional;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper;
2016-11-13 22:09:54 +00:00
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
2016-11-13 22:09:54 +00:00
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
public class SidedInvWrapper implements IItemHandlerModifiable
{
protected final ISidedInventory inv;
@Nullable
2019-05-23 23:02:15 +00:00
protected final Direction side;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
@SuppressWarnings("unchecked")
2019-05-23 23:02:15 +00:00
public static LazyOptional<IItemHandlerModifiable>[] create(ISidedInventory inv, Direction... sides) {
LazyOptional<IItemHandlerModifiable>[] ret = new LazyOptional[sides.length];
for (int x = 0; x < sides.length; x++) {
2019-05-23 23:02:15 +00:00
final Direction side = sides[x];
ret[x] = LazyOptional.of(() -> new SidedInvWrapper(inv, side));
}
return ret;
}
public SidedInvWrapper(ISidedInventory inv, @Nullable Direction side)
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
this.inv = inv;
this.side = side;
}
public static int getSlot(ISidedInventory inv, int slot, @Nullable Direction side)
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
int[] slots = inv.getSlotsForFace(side);
if (slot < slots.length)
return slots[slot];
return -1;
}
@Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
SidedInvWrapper that = (SidedInvWrapper) o;
return inv.equals(that.inv) && side == that.side;
}
@Override
public int hashCode()
{
int result = inv.hashCode();
result = 31 * result + (side == null ? 0 : side.hashCode());
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
return result;
}
@Override
public int getSlots()
{
return inv.getSlotsForFace(side).length;
}
@Override
2016-11-13 22:09:54 +00:00
@Nonnull
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
public ItemStack getStackInSlot(int slot)
{
int i = getSlot(inv, slot, side);
return i == -1 ? ItemStack.EMPTY : inv.getStackInSlot(i);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}
@Override
2016-11-13 22:09:54 +00:00
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
if (stack.isEmpty())
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
int slot1 = getSlot(inv, slot, side);
if (slot1 == -1)
return stack;
ItemStack stackInSlot = inv.getStackInSlot(slot1);
int m;
if (!stackInSlot.isEmpty())
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
if (stackInSlot.getCount() >= Math.min(stackInSlot.getMaxStackSize(), getSlotLimit(slot)))
return stack;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
if (!ItemHandlerHelper.canItemStacksStack(stack, stackInSlot))
return stack;
if (!inv.canInsertItem(slot1, stack, side) || !inv.isItemValidForSlot(slot1, stack))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot)) - stackInSlot.getCount();
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
if (stack.getCount() <= m)
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
if (!simulate)
{
ItemStack copy = stack.copy();
copy.grow(stackInSlot.getCount());
setInventorySlotContents(slot1, copy);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}
else
{
2016-01-02 13:38:18 +00:00
// copy the stack to not modify the original one
stack = stack.copy();
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
if (!simulate)
{
ItemStack copy = stack.split(m);
copy.grow(stackInSlot.getCount());
setInventorySlotContents(slot1, copy);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
return stack;
}
else
{
stack.shrink(m);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
return stack;
}
}
}
else
{
if (!inv.canInsertItem(slot1, stack, side) || !inv.isItemValidForSlot(slot1, stack))
return stack;
m = Math.min(stack.getMaxStackSize(), getSlotLimit(slot));
if (m < stack.getCount())
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
2016-01-02 13:38:18 +00:00
// copy the stack to not modify the original one
stack = stack.copy();
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
if (!simulate)
{
setInventorySlotContents(slot1, stack.split(m));
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
return stack;
}
else
{
stack.shrink(m);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
return stack;
}
}
else
{
if (!simulate)
setInventorySlotContents(slot1, stack);
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}
}
}
@Override
2016-11-13 22:09:54 +00:00
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
int slot1 = getSlot(inv, slot, side);
if (slot1 != -1)
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);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}
@Override
2016-11-13 22:09:54 +00:00
@Nonnull
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
public ItemStack extractItem(int slot, int amount, boolean simulate)
{
if (amount == 0)
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
int slot1 = getSlot(inv, slot, side);
if (slot1 == -1)
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
ItemStack stackInSlot = inv.getStackInSlot(slot1);
if (stackInSlot.isEmpty())
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
if (!inv.canExtractItem(slot1, stackInSlot, side))
return ItemStack.EMPTY;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
if (simulate)
{
if (stackInSlot.getCount() < amount)
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
{
return stackInSlot.copy();
}
else
{
ItemStack copy = stackInSlot.copy();
copy.setCount(amount);
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
return copy;
}
}
else
{
int m = Math.min(stackInSlot.getCount(), amount);
ItemStack ret = inv.decrStackSize(slot1, m);
inv.markDirty();
return ret;
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}
}
@Override
public int getSlotLimit(int slot)
{
return inv.getInventoryStackLimit();
}
@Override
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
{
int slot1 = getSlot(inv, slot, side);
return slot1 == -1 ? false : inv.isItemValidForSlot(slot1, stack);
}
Add IItemHandler capability Add the actual patches that I forgot. Add simple implementations of IStorage and the factory methods. Add ItemStackHandler. A simple IItemHandler implementaton. return nulls, not throw nulls. Move the vanilla wrappers to a separate class for now. Minor clean ups of VanillaWrapper code. Inline static methods. Add comments. Minor cleanup of code. Remove redundant size field and add a validate slot index method. Minor formatting issues. Break early If stacksize to insert is 0. Remove setByte() methods. Throw exception if IItemHandler can't be modifyed in NBT loading. Replace event handler with patches Add capability to mine cart inventory entities. Change formatting and registration of capability. Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them. Reduce patch sizes Lazy initialization of the item handler for vanilla tiles. Minor formatting changes. Create a single vanilla chest item handler that will merge with adjacent chests when detected. Added hooks to reset the cached adjacent value when a block update is detected and when a chunk loads. Revert "Make InventoryPlayer implements IItemHandler because why not. Also added a field to allow mods that add additional player inventory space to publicly expose them." This reverts commit 306d4a37fd0e8c8a0754411c013b750dfe8e2c87. Fix furnace derp Replace double chest code with a simpler method. Vanilla wrappers implement IItemHandlerModifiable (since they are modifiable) Minor code cleanups Add an onContentsChanged() and onLoad() callback methods.to the default implementation. Add slot as a parameter in the callback method. Change IItemHandlerModifiable.setStackInSlot() to void, and added a note about not being intended for cross-mod use. Improve ItemStackHandler handling of errored NBT. Make the stacks array protected. Fix a lot of derps in SlotItemHandler. Fix derp in ItemStackHandler Clarify comments on IItemHandler ItemStackHandler no longer caches the stack array in local variable. Clean up the Chests code to make intentions clearer Vanilla hoppers have their cooldown activated when an item is inserted. Made this behavior part of an item handler (rather than the insertion code) Fix mistake in ItemStackHandler More documentation of potential edge cases in getStackInSlot() Make limit checking more resiliant.
2016-01-17 16:41:34 +00:00
}