TechReborn/src/main/java/techreborn/itemblocks/ItemBlockDigitalChest.java

59 lines
1.7 KiB
Java
Raw Normal View History

2015-06-07 04:11:13 +02:00
package techreborn.itemblocks;
2016-03-24 01:39:26 +01:00
import java.util.List;
2015-06-07 04:11:13 +02:00
import net.minecraft.block.Block;
2015-11-23 20:19:18 +01:00
import net.minecraft.block.state.IBlockState;
2015-06-07 04:11:13 +02:00
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
2015-11-23 20:19:18 +01:00
import net.minecraft.util.EnumFacing;
2016-03-15 09:13:05 +01:00
import net.minecraft.util.math.BlockPos;
2015-06-07 04:11:13 +02:00
import net.minecraft.world.World;
2015-11-23 20:19:18 +01:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2015-06-07 04:11:13 +02:00
import techreborn.tiles.TileDigitalChest;
2015-07-02 20:51:24 +02:00
2016-03-24 01:39:26 +01:00
public class ItemBlockDigitalChest extends ItemBlock
{
2015-06-07 04:11:13 +02:00
2016-03-24 01:39:26 +01:00
public ItemBlockDigitalChest(Block p_i45328_1_)
{
super(p_i45328_1_);
}
2015-06-07 04:11:13 +02:00
2016-03-24 01:39:26 +01:00
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{
if (stack != null && stack.hasTagCompound())
{
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items");
}
}
2015-06-07 04:11:13 +02:00
2016-03-24 01:39:26 +01:00
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side,
float hitX, float hitY, float hitZ, IBlockState newState)
{
if (!world.setBlockState(pos, newState))
{
return false;
}
if (world.getBlockState(pos).getBlock() == block)
{
world.getBlockState(pos).getBlock().onBlockPlacedBy(world, pos, newState, player, stack);
// world.getBlockState(pos).getBlock().onPostBlockPlaced(world, x,
// y, z, metadata);
}
if (stack != null && stack.hasTagCompound())
{
((TileDigitalChest) world.getTileEntity(pos))
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
}
return true;
}
2015-06-07 04:11:13 +02:00
}