@SubscribeEvent
public static void ChiselMine(TickEvent.PlayerTickEvent mine) {
Player player = mine.player;
Item itemInHand = player.getMainHandItem().getItem();
Level pLevel = player.level;
BlockState eyeBlockstate = pLevel.getBlockState(player.eyeBlockPosition());
Block eyeBlock = eyeBlockstate.getBlock();
BlockPos eyeBlockPos = player.eyeBlockPosition();
if (itemInHand.equals(ModItems.CHISEL.get())) {
if (Minecraft.getInstance().options.keyUse.isDown()) {
System.out.println("Use is down! Time is: " + pLevel.getGameTime());
if (player.distanceToSqr(eyeBlockPos.getX(), eyeBlockPos.getY(), eyeBlockPos.getZ()) <= 5) {
System.out.println("BlockPos comparing succeeded! Time is: " + pLevel.getGameTime());
if (checkForBlock(eyeBlock)) {
System.out.println("Block comparing succeeded! Time is: " + pLevel.getGameTime());
}
}
}
}
}
public static boolean checkForBlock(Block clickedBlock) {
System.out.println("Block comparing!");
if (clickedBlock == ModBlocks.IRON_ORE_SMALL.get()){
dropItem = ModItems.IRON_CHUNK.get(); return true;
}else if (clickedBlock == ModBlocks.LEAD_ORE_SMALL.get()){
dropItem = ModItems.LEAD_CHUNK.get(); return true;
}else {
return false;
}
}
thats my code i know now that eyeblockpos isnt the block the player is looking at just ignore that but u might understand what im trying to achieve it would be way easier if i could fire a playerUseOnBlock event instead in the tickevent