generated from LabyMod/addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from RappyLabyAddons/feat/update
Add support for `1.20.2`
- Loading branch information
Showing
3 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
game-runner/src/v1_20_2/java/com/rappytv/waila/v1_20_2/ImplWailaApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.rappytv.waila.v1_20_2; | ||
|
||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters