2014-12-15 00:11:48 +00:00
|
|
|
package com.cricketcraft.chisel.block;
|
2014-12-14 20:05:39 +00:00
|
|
|
|
2014-10-27 16:26:14 -04:00
|
|
|
import net.minecraft.block.Block;
|
2014-05-23 22:44:19 +01:00
|
|
|
import net.minecraft.block.BlockContainer;
|
|
|
|
|
import net.minecraft.block.material.Material;
|
2014-10-27 16:26:14 -04:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
2014-05-23 22:44:19 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
import net.minecraft.world.World;
|
2014-12-16 22:27:44 +00:00
|
|
|
|
|
|
|
|
import com.cricketcraft.chisel.Chisel;
|
|
|
|
|
import com.cricketcraft.chisel.block.tileentity.TileEntityAutoChisel;
|
2015-01-07 19:50:18 -05:00
|
|
|
|
|
|
|
|
public class BlockAutoChisel extends BlockContainer {
|
|
|
|
|
|
|
|
|
|
public BlockAutoChisel() {
|
|
|
|
|
super(Material.rock);
|
|
|
|
|
setHardness(1F);
|
2015-01-11 17:21:53 -05:00
|
|
|
setBlockBounds(0.125f, 0, 0.125f, 0.875f, 0.8125f, 0.875f);
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int getRenderType() {
|
2015-01-08 01:59:50 -05:00
|
|
|
return Chisel.renderAutoChiselId;
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isOpaqueCube() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean renderAsNormalBlock() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float x1, float y1, float z1) {
|
|
|
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
|
|
|
|
if (world.isRemote)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (tile != null && tile instanceof TileEntityAutoChisel && !player.isSneaking()) {
|
|
|
|
|
player.openGui(Chisel.instance, 1, world, x, y, z);
|
|
|
|
|
}
|
2015-01-15 14:55:08 -05:00
|
|
|
|
2015-01-07 19:50:18 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
|
|
|
|
|
dropItems(world, x, y, z);
|
|
|
|
|
super.breakBlock(world, x, y, z, block, par6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void dropItems(World world, int x, int y, int z) {
|
|
|
|
|
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
|
|
|
|
|
|
|
|
|
if (!(tileEntity instanceof TileEntityAutoChisel)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TileEntityAutoChisel inventory = (TileEntityAutoChisel) world.getTileEntity(x, y, z);
|
|
|
|
|
|
|
|
|
|
for (int c = 0; c < inventory.getSizeInventory(); c++) {
|
|
|
|
|
ItemStack stack = inventory.getStackInSlot(c);
|
2015-01-15 14:55:08 -05:00
|
|
|
if (stack != null) {
|
|
|
|
|
dropBlockAsItem(world, x, y, z, stack);
|
2015-01-07 19:50:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TileEntity createNewTileEntity(World var1, int var2) {
|
|
|
|
|
return new TileEntityAutoChisel();
|
|
|
|
|
}
|
2014-05-23 22:44:19 +01:00
|
|
|
}
|