Fixes some issues with the storage chests, closes #1481
This commit is contained in:
parent
9a6d9765bd
commit
1c10c199ae
3 changed files with 55 additions and 5 deletions
|
@ -27,6 +27,7 @@ package techreborn.blocks.tier2;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -54,8 +55,7 @@ public class BlockDigitalChest extends BlockMachineBase {
|
|||
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/tier2_machines"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory(final World world, final BlockPos pos) {
|
||||
protected void dropChest(final World world, final BlockPos pos) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
return;
|
||||
|
@ -66,6 +66,30 @@ public class BlockDigitalChest extends BlockMachineBase {
|
|||
WorldUtils.dropItems(items, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory(World world, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
} else {
|
||||
final TileTechStorageBase tileEntity1 = (TileTechStorageBase) tileEntity;
|
||||
drops.add(tileEntity1.getDropWithNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if(worldIn.getTileEntity(pos) != null){
|
||||
dropChest(worldIn, pos);
|
||||
}
|
||||
worldIn.removeTileEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.blocks.tier3;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -59,8 +60,7 @@ public class BlockQuantumChest extends BlockMachineBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory(final World world, final BlockPos pos) {
|
||||
protected void dropChest(final World world, final BlockPos pos) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
return;
|
||||
|
@ -71,6 +71,30 @@ public class BlockQuantumChest extends BlockMachineBase {
|
|||
WorldUtils.dropItems(items, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory(World world, BlockPos pos) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
final TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (!(tileEntity instanceof TileTechStorageBase)) {
|
||||
super.getDrops(drops, world, pos, state, fortune);
|
||||
} else {
|
||||
final TileTechStorageBase tileEntity1 = (TileTechStorageBase) tileEntity;
|
||||
drops.add(tileEntity1.getDropWithNBT());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
if(worldIn.getTileEntity(pos) != null){
|
||||
dropChest(worldIn, pos);
|
||||
}
|
||||
worldIn.removeTileEntity(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -143,6 +143,8 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
if (!this.storedItem.isEmpty()) {
|
||||
this.storedItem.setCount(Math.min(tagCompound.getInteger("storedQuantity"), this.maxCapacity));
|
||||
}
|
||||
|
||||
inventory.readFromNBT(tagCompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,7 +165,7 @@ public class TileTechStorageBase extends TileLegacyMachineBase
|
|||
} else {
|
||||
tagCompound.setInteger("storedQuantity", 0);
|
||||
}
|
||||
|
||||
inventory.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue