Skip to content

Commit

Permalink
Add 1.20.5-1.21 implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
RappyTV committed Jun 29, 2024
1 parent e2fbb4b commit f2c6c4c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.rappytv.waila.v1_20_5;

import com.rappytv.waila.util.IWailaApi;
import net.labymod.api.models.Implements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.HitResult.Type;

@Implements(IWailaApi.class)
public class ImplWailaApi implements IWailaApi {

@Override
public String getLookingAt(boolean fluid, int range) {
Minecraft minecraft = Minecraft.getInstance();
LocalPlayer player = minecraft.player;

if(player == null) return null;
HitResult result = player.pick(range, 0f, fluid);
if(result.getType() != Type.BLOCK || minecraft.level == null) return null;

BlockState state = minecraft.level.getBlockState(((BlockHitResult) result).getBlockPos());

return state.getBlock().getName().getString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.rappytv.waila.v1_20_6;

import com.rappytv.waila.util.IWailaApi;
import net.labymod.api.models.Implements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.HitResult.Type;

@Implements(IWailaApi.class)
public class ImplWailaApi implements IWailaApi {

@Override
public String getLookingAt(boolean fluid, int range) {
Minecraft minecraft = Minecraft.getInstance();
LocalPlayer player = minecraft.player;

if(player == null) return null;
HitResult result = player.pick(range, 0f, fluid);
if(result.getType() != Type.BLOCK || minecraft.level == null) return null;

BlockState state = minecraft.level.getBlockState(((BlockHitResult) result).getBlockPos());

return state.getBlock().getName().getString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.rappytv.waila.v1_21;

import com.rappytv.waila.util.IWailaApi;
import net.labymod.api.models.Implements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.HitResult.Type;

@Implements(IWailaApi.class)
public class ImplWailaApi implements IWailaApi {

@Override
public String getLookingAt(boolean fluid, int range) {
Minecraft minecraft = Minecraft.getInstance();
LocalPlayer player = minecraft.player;

if(player == null) return null;
HitResult result = player.pick(range, 0f, fluid);
if(result.getType() != Type.BLOCK || minecraft.level == null) return null;

BlockState state = minecraft.level.getBlockState(((BlockHitResult) result).getBlockPos());

return state.getBlock().getName().getString();
}
}

0 comments on commit f2c6c4c

Please sign in to comment.