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
|
|
|
|
2021-02-27 21:24:26 +01:00
|
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
2021-03-01 20:14:50 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.base.DirectionalBlock;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityMiner;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraft.block.BlockState;
|
2021-02-27 17:22:03 +01:00
|
|
|
import net.minecraft.client.MainWindow;
|
2015-12-21 22:18:33 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2021-02-26 22:15:48 +01:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraft.util.ActionResultType;
|
2021-02-26 22:15:48 +01:00
|
|
|
import net.minecraft.util.Hand;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraft.util.math.BlockRayTraceResult;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraft.util.math.shapes.ISelectionContext;
|
|
|
|
import net.minecraft.util.math.shapes.VoxelShape;
|
|
|
|
import net.minecraft.world.IBlockReader;
|
2015-12-06 02:16:52 +01:00
|
|
|
import net.minecraft.world.World;
|
2021-02-27 13:24:45 +01:00
|
|
|
import net.minecraftforge.api.distmarker.Dist;
|
2021-03-01 20:14:50 +01:00
|
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
2021-03-01 18:11:34 +01:00
|
|
|
|
2015-12-06 02:16:52 +01:00
|
|
|
|
2021-05-05 18:15:25 +02:00
|
|
|
public class BlockVerticalDigger extends DirectionalBlock.Container implements IHudDisplay {
|
2015-12-06 02:16:52 +01:00
|
|
|
|
2021-05-05 18:15:25 +02:00
|
|
|
public BlockVerticalDigger() {
|
2021-03-01 20:14:50 +01:00
|
|
|
super(ActuallyBlocks.defaultPickProps(0, 8F, 30F));
|
2015-12-06 02:16:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-08-22 17:09:06 +02:00
|
|
|
public ActionResultType use(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
2021-03-01 20:14:50 +01:00
|
|
|
return this.openGui(worldIn, player, pos, TileEntityMiner.class);
|
2015-12-19 10:30:39 +01:00
|
|
|
}
|
|
|
|
|
2015-12-06 02:16:52 +01:00
|
|
|
@Override
|
2021-08-22 17:09:06 +02:00
|
|
|
public TileEntity newBlockEntity(IBlockReader world) {
|
2015-12-06 02:16:52 +01:00
|
|
|
return new TileEntityMiner();
|
|
|
|
}
|
|
|
|
|
2015-12-21 22:18:33 +01:00
|
|
|
@Override
|
2021-02-26 22:15:48 +01:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2021-02-27 21:24:26 +01:00
|
|
|
public void displayHud(MatrixStack matrices, Minecraft minecraft, PlayerEntity player, ItemStack stack, RayTraceResult rayCast, MainWindow resolution) {
|
2021-03-01 20:14:50 +01:00
|
|
|
if (!(rayCast instanceof BlockRayTraceResult)) {
|
|
|
|
return;
|
|
|
|
}
|
2021-08-22 17:09:06 +02:00
|
|
|
TileEntity tile = minecraft.level.getBlockEntity(((BlockRayTraceResult) rayCast).getBlockPos());
|
2019-05-02 09:10:29 +02:00
|
|
|
if (tile instanceof TileEntityMiner) {
|
|
|
|
TileEntityMiner miner = (TileEntityMiner) tile;
|
2021-02-26 22:15:48 +01:00
|
|
|
String info = miner.checkY == 0
|
|
|
|
? "Done Mining!"
|
|
|
|
: miner.checkY == -1
|
|
|
|
? "Calculating positions..."
|
2021-08-22 17:09:06 +02:00
|
|
|
: "Mining at " + (miner.getBlockPos().getX() + miner.checkX) + ", " + miner.checkY + ", " + (miner.getBlockPos().getZ() + miner.checkZ) + ".";
|
|
|
|
minecraft.font.drawShadow(matrices, info, resolution.getGuiScaledWidth() / 2f + 5, resolution.getGuiScaledHeight() / 2f - 20, StringUtil.DECIMAL_COLOR_WHITE);
|
2021-03-01 20:14:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
|
2021-08-22 17:09:06 +02:00
|
|
|
switch (state.getValue(FACING)) {
|
2021-03-01 20:14:50 +01:00
|
|
|
case NORTH:
|
|
|
|
return Shapes.MinerShapes.SHAPE_N;
|
|
|
|
case EAST:
|
|
|
|
return Shapes.MinerShapes.SHAPE_E;
|
|
|
|
case SOUTH:
|
|
|
|
return Shapes.MinerShapes.SHAPE_S;
|
|
|
|
case WEST:
|
|
|
|
return Shapes.MinerShapes.SHAPE_W;
|
|
|
|
default:
|
|
|
|
return Shapes.MinerShapes.SHAPE_N;
|
2015-12-21 22:18:33 +01:00
|
|
|
}
|
|
|
|
}
|
2021-02-26 22:15:48 +01:00
|
|
|
}
|