From 19fb264b3b2b0b90fe43cba6a2b7f35162165f04 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Sun, 2 Nov 2014 23:55:01 +0100 Subject: [PATCH] Fixes #376 IO Port now dropping upgrades properly. --- .../java/appeng/tile/storage/TileIOPort.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/appeng/tile/storage/TileIOPort.java b/src/main/java/appeng/tile/storage/TileIOPort.java index 6a37cc13..fa4270d4 100644 --- a/src/main/java/appeng/tile/storage/TileIOPort.java +++ b/src/main/java/appeng/tile/storage/TileIOPort.java @@ -1,8 +1,27 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 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, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 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 Applied Energistics 2. If not, see . + */ + package appeng.tile.storage; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import appeng.api.AEApi; import appeng.api.config.Actionable; @@ -45,6 +64,8 @@ import appeng.util.InventoryAdaptor; import appeng.util.Platform; import appeng.util.inv.WrapperInventoryRange; +import java.util.ArrayList; + public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable { @@ -419,4 +440,28 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC return false; } + /** + * Adds the items in the upgrade slots to the drop list. + * + * @param w world + * @param x x pos of tile entity + * @param y y pos of tile entity + * @param z z pos of tile entity + * @param drops drops of tile entity + */ + @Override + public void getDrops( World w, int x, int y, int z, ArrayList drops ) + { + super.getDrops( w, x, y, z, drops ); + + for (int upgradeInventoryIndex = 0; upgradeInventoryIndex < this.upgrades.getSizeInventory(); upgradeInventoryIndex++) + { + ItemStack stackInSlot = this.upgrades.getStackInSlot(upgradeInventoryIndex); + + if ( stackInSlot != null ) + { + drops.add( stackInSlot ); + } + } + } }