Files
MinecraftForge/src/main/java/net/minecraftforge/items/VanillaHopperItemHandler.java
T
be5446b91c Update to 1.17
Update to Official classnames
Patchwork
Make the game compile and run
Merge in the new HUD overlay API
Merge in the new render properties API
PEEL
Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason.
New FML installer
Update to 1.17.1

Co-authored-by: LexManos <[email protected]>
Co-authored-by: SizableShrimp <[email protected]>
Co-authored-by: cpw <[email protected]>
Co-authored-by: Curle <[email protected]>
Co-authored-by: Unnoen <[email protected]>
Co-authored-by: covers1624 <[email protected]>
Co-authored-by: DaemonUmbra <[email protected]>
Co-authored-by: gigaherz <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
2021-07-22 19:57:02 +01:00

70 lines
2.3 KiB
Java

/*
* Minecraft Forge
* Copyright (c) 2016-2021.
*
* 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
*/
package net.minecraftforge.items;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.HopperBlockEntity;
import net.minecraftforge.items.wrapper.InvWrapper;
import javax.annotation.Nonnull;
public class VanillaHopperItemHandler extends InvWrapper
{
private final HopperBlockEntity hopper;
public VanillaHopperItemHandler(HopperBlockEntity hopper)
{
super(hopper);
this.hopper = hopper;
}
@Override
@Nonnull
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
{
if (simulate)
{
return super.insertItem(slot, stack, simulate);
}
else
{
boolean wasEmpty = getInv().isEmpty();
int originalStackSize = stack.getCount();
stack = super.insertItem(slot, stack, simulate);
if (wasEmpty && originalStackSize > stack.getCount())
{
if (!hopper.isOnCustomCooldown())
{
// This cooldown is always set to 8 in vanilla with one exception:
// Hopper -> Hopper transfer sets this cooldown to 7 when this hopper
// has not been updated as recently as the one pushing items into it.
// This vanilla behavior is preserved by VanillaInventoryCodeHooks#insertStack,
// the cooldown is set properly by the hopper that is pushing items into this one.
hopper.setCooldown(8);
}
}
return stack;
}
}
}