2015-12-06 02:16:52 +01:00
|
|
|
/*
|
|
|
|
* This file ("BlockMiner.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
|
|
|
* © 2015 Ellpeck
|
|
|
|
*/
|
|
|
|
|
|
|
|
package ellpeck.actuallyadditions.blocks;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2015-12-09 20:24:45 +01:00
|
|
|
import ellpeck.actuallyadditions.ActuallyAdditions;
|
2015-12-06 02:16:52 +01:00
|
|
|
import ellpeck.actuallyadditions.blocks.base.BlockContainerBase;
|
2015-12-09 20:24:45 +01:00
|
|
|
import ellpeck.actuallyadditions.inventory.GuiHandler;
|
2015-12-06 02:16:52 +01:00
|
|
|
import ellpeck.actuallyadditions.tile.TileEntityMiner;
|
|
|
|
import ellpeck.actuallyadditions.util.ModUtil;
|
2015-12-21 22:18:33 +01:00
|
|
|
import ellpeck.actuallyadditions.util.StringUtil;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.material.Material;
|
2015-12-21 22:18:33 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.ScaledResolution;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
2015-12-09 16:54:25 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.item.EnumRarity;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2015-12-21 22:18:33 +01:00
|
|
|
import net.minecraft.profiler.Profiler;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.IIcon;
|
2015-12-21 22:18:33 +01:00
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2015-12-21 22:18:33 +01:00
|
|
|
public class BlockMiner extends BlockContainerBase implements IHudDisplay{
|
2015-12-06 02:16:52 +01:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
private IIcon frontIcon;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
private IIcon topIcon;
|
|
|
|
|
|
|
|
public BlockMiner(String name){
|
|
|
|
super(Material.rock, name);
|
|
|
|
this.setHarvestLevel("pickaxe", 0);
|
|
|
|
this.setHardness(8F);
|
|
|
|
this.setResistance(30F);
|
|
|
|
this.setStepSound(soundTypeStone);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public IIcon getIcon(int side, int meta){
|
|
|
|
return side == 0 ? this.frontIcon : (side == 1 ? this.topIcon : this.blockIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube(){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-19 10:30:39 +01:00
|
|
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
|
|
|
|
if(!world.isRemote){
|
|
|
|
TileEntity tile = world.getTileEntity(x, y, z);
|
2015-12-21 22:18:33 +01:00
|
|
|
if(tile instanceof TileEntityMiner){
|
|
|
|
player.openGui(ActuallyAdditions.instance, GuiHandler.GuiTypes.MINER.ordinal(), world, x, y, z);
|
2015-12-19 10:30:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2015-12-06 02:16:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerBlockIcons(IIconRegister iconReg){
|
|
|
|
this.blockIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName());
|
|
|
|
this.frontIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Front");
|
|
|
|
this.topIcon = iconReg.registerIcon(ModUtil.MOD_ID_LOWER+":"+this.getBaseName()+"Top");
|
|
|
|
}
|
|
|
|
|
2015-12-19 10:30:39 +01:00
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
|
|
|
return EnumRarity.rare;
|
|
|
|
}
|
|
|
|
|
2015-12-06 02:16:52 +01:00
|
|
|
@Override
|
|
|
|
public TileEntity createNewTileEntity(World world, int i){
|
|
|
|
return new TileEntityMiner();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
|
|
|
this.dropInventory(world, x, y, z);
|
|
|
|
super.breakBlock(world, x, y, z, block, par6);
|
|
|
|
}
|
2015-12-21 22:18:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
|
|
|
|
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ);
|
|
|
|
if(tile instanceof TileEntityMiner){
|
|
|
|
String info = ((TileEntityMiner)tile).layerAt <= 0 ? "Done Mining!" : "Mining at Y = "+((TileEntityMiner)tile).layerAt+".";
|
|
|
|
minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-20, StringUtil.DECIMAL_COLOR_WHITE);
|
|
|
|
}
|
|
|
|
}
|
2015-12-06 02:16:52 +01:00
|
|
|
}
|