improve dropped inventory

This commit is contained in:
Raoul Van den Berge
2015-12-24 15:27:05 +01:00
parent 9e412bac64
commit 35bacfc90b
9 changed files with 30 additions and 23 deletions

View File

@@ -4,7 +4,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockPistonBase;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
@@ -83,9 +82,9 @@ public abstract class BlockBase extends Block
{
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof IInventory && tile instanceof TileBase && ((TileBase) tile).canDropInventory())
if (tile instanceof TileBase && ((TileBase) tile).getDroppedInventory() != null)
{
InventoryUtils.dropInventory(world, (IInventory) tile, x, y, z);
InventoryUtils.dropInventory(world, ((TileBase) tile).getDroppedInventory(), x, y, z);
}
super.onBlockPreDestroy(world, x, y, z, meta);

View File

@@ -1,6 +1,7 @@
package storagecraft.tile;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.inventory.IInventory;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
@@ -78,8 +79,8 @@ public abstract class TileBase extends TileEntity
direction = ForgeDirection.getOrientation(packet.func_148857_g().getInteger("Direction"));
}
public boolean canDropInventory()
public IInventory getDroppedInventory()
{
return true;
return null;
}
}

View File

@@ -290,10 +290,4 @@ public class TileDetector extends TileMachine implements IInventory, ISidedInven
buf.writeInt(amount);
buf.writeBoolean(providesPower);
}
@Override
public boolean canDropInventory()
{
return false;
}
}

View File

@@ -135,4 +135,10 @@ public class TileDrive extends TileMachine implements IInventory, IStorageProvid
}
}
}
@Override
public IInventory getDroppedInventory()
{
return inventory;
}
}

View File

@@ -229,10 +229,4 @@ public class TileExporter extends TileMachine implements IInventory, ISidedInven
buf.writeInt(compare);
}
@Override
public boolean canDropInventory()
{
return false;
}
}

View File

@@ -1,6 +1,7 @@
package storagecraft.tile;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
@@ -100,4 +101,10 @@ public class TileGrid extends TileMachine
InventoryUtils.saveInventory(craftingMatrix, nbt);
}
@Override
public IInventory getDroppedInventory()
{
return craftingMatrix;
}
}

View File

@@ -280,10 +280,4 @@ public class TileImporter extends TileMachine implements IInventory, ISidedInven
buf.writeInt(compare);
buf.writeInt(mode);
}
@Override
public boolean canDropInventory()
{
return false;
}
}

View File

@@ -259,4 +259,10 @@ public class TileSolderer extends TileMachine implements IInventory, ISidedInven
{
return duration;
}
@Override
public IInventory getDroppedInventory()
{
return inventory;
}
}

View File

@@ -224,4 +224,10 @@ public class TileWirelessTransmitter extends TileMachine implements IInventory
buf.writeBoolean(working);
buf.writeInt(progress);
}
@Override
public IInventory getDroppedInventory()
{
return inventory;
}
}