2015-12-06 02:16:52 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("BlockMiner.java") is part of the Actually Additions mod for Minecraft.
|
2015-12-06 02:16:52 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-12-06 02:16:52 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-12-06 02:16:52 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
2015-12-06 02:16:52 +01:00
|
|
|
|
2016-01-08 13:31:58 +01:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.block.SoundType;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.block.material.Material;
|
2016-01-07 23:42:42 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-12-21 22:18:33 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.ScaledResolution;
|
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;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-01-07 23:42:42 +01:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.EnumHand;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.world.World;
|
2016-01-07 18:20:59 +01:00
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2015-12-06 02:16:52 +01:00
|
|
|
|
2015-12-21 22:18:33 +01:00
|
|
|
public class BlockMiner extends BlockContainerBase implements IHudDisplay{
|
2015-12-06 02:16:52 +01:00
|
|
|
|
|
|
|
public BlockMiner(String name){
|
2016-04-20 21:39:03 +02:00
|
|
|
super(Material.ROCK, name);
|
2015-12-06 02:16:52 +01:00
|
|
|
this.setHarvestLevel("pickaxe", 0);
|
|
|
|
this.setHardness(8F);
|
|
|
|
this.setResistance(30F);
|
2016-04-20 21:39:03 +02:00
|
|
|
this.setSoundType(SoundType.STONE);
|
2015-12-06 02:16:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-18 23:47:22 +01:00
|
|
|
public boolean isOpaqueCube(IBlockState state){
|
2015-12-06 02:16:52 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-11-19 21:11:17 +01:00
|
|
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
|
2015-12-19 10:30:39 +01:00
|
|
|
if(!world.isRemote){
|
2016-01-07 23:42:42 +01:00
|
|
|
TileEntity tile = world.getTileEntity(pos);
|
2015-12-21 22:18:33 +01:00
|
|
|
if(tile instanceof TileEntityMiner){
|
2018-05-10 11:38:58 +02:00
|
|
|
player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.MINER.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
2015-12-19 10:30:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2015-12-06 02:16:52 +01:00
|
|
|
}
|
|
|
|
|
2015-12-19 10:30:39 +01:00
|
|
|
@Override
|
|
|
|
public EnumRarity getRarity(ItemStack stack){
|
2016-01-07 23:42:42 +01:00
|
|
|
return EnumRarity.RARE;
|
2015-12-19 10:30:39 +01:00
|
|
|
}
|
|
|
|
|
2016-05-29 23:49:35 +02:00
|
|
|
|
2015-12-06 02:16:52 +01:00
|
|
|
@Override
|
2016-05-29 23:49:35 +02:00
|
|
|
public TileEntity createNewTileEntity(World world, int i){
|
2015-12-06 02:16:52 +01:00
|
|
|
return new TileEntityMiner();
|
|
|
|
}
|
|
|
|
|
2015-12-21 22:18:33 +01:00
|
|
|
@Override
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-07-25 22:37:14 +02:00
|
|
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
2016-11-26 21:32:27 +01:00
|
|
|
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
2015-12-21 22:18:33 +01:00
|
|
|
if(tile instanceof TileEntityMiner){
|
2016-12-06 20:06:40 +01:00
|
|
|
TileEntityMiner miner = (TileEntityMiner)tile;
|
|
|
|
String info = miner.checkY == 0 ? "Done Mining!" : (miner.checkY == -1 ? "Calculating positions..." : "Mining at "+(miner.getPos().getX()+miner.checkX)+", "+miner.checkY+", "+(miner.getPos().getZ()+miner.checkZ)+".");
|
2017-06-29 18:30:02 +02:00
|
|
|
minecraft.fontRenderer.drawStringWithShadow(info, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2-20, StringUtil.DECIMAL_COLOR_WHITE);
|
2015-12-21 22:18:33 +01:00
|
|
|
}
|
|
|
|
}
|
2015-12-06 02:16:52 +01:00
|
|
|
}
|