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

51 lines
1.7 KiB
Java
Raw Normal View History

package techreborn.itemblocks;
import net.minecraft.block.Block;
2015-11-23 20:19:18 +01:00
import net.minecraft.block.state.IBlockState;
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;
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;
import techreborn.tiles.TileQuantumChest;
2015-07-02 20:51:24 +02:00
2016-10-08 21:46:16 +02:00
import java.util.List;
public class ItemBlockQuantumChest extends ItemBlock {
2016-10-08 21:46:16 +02:00
public ItemBlockQuantumChest(Block p_i45328_1_) {
2016-03-25 10:47:34 +01:00
super(p_i45328_1_);
}
2015-04-24 15:20:09 +02:00
2016-03-25 10:47:34 +01:00
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
2016-10-08 21:46:16 +02:00
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
if (stack != null && stack.hasTagCompound()) {
2016-03-25 10:47:34 +01:00
if (stack.getTagCompound().getCompoundTag("tileEntity") != null)
list.add(stack.getTagCompound().getCompoundTag("tileEntity").getInteger("storedQuantity") + " items");
}
}
2015-04-24 15:20:09 +02:00
2016-03-25 10:47:34 +01:00
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side,
2016-10-08 21:46:16 +02:00
float hitX, float hitY, float hitZ, IBlockState newState) {
if (!world.setBlockState(pos, newState)) {
2016-03-25 10:47:34 +01:00
return false;
}
2016-10-08 21:46:16 +02:00
if (world.getBlockState(pos).getBlock() == block) {
2016-03-25 10:47:34 +01:00
world.getBlockState(pos).getBlock().onBlockPlacedBy(world, pos, newState, player, stack);
// world.getBlockState(pos).getBlock().onPostBlockPlaced(world, x,
// y, z, metadata);
}
2016-10-08 21:46:16 +02:00
if (stack != null && stack.hasTagCompound()) {
2016-03-25 10:47:34 +01:00
((TileQuantumChest) world.getTileEntity(pos))
2016-10-08 21:46:16 +02:00
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
2016-03-25 10:47:34 +01:00
}
return true;
}
}