mirror of https://github.com/cabaletta/baritone
Replace creation of new Helper instances in Utils
This commit is contained in:
parent
2a8575caa8
commit
30b63abb73
|
@ -35,6 +35,11 @@ import net.minecraft.util.text.TextFormatting;
|
|||
*/
|
||||
public interface Helper {
|
||||
|
||||
/**
|
||||
* Instance of {@link Helper}. Used for static-context reference.
|
||||
*/
|
||||
Helper HELPER = new Helper() {};
|
||||
|
||||
ITextComponent MESSAGE_PREFIX = new TextComponentString(String.format(
|
||||
"%s[%sBaritone%s]%s",
|
||||
TextFormatting.DARK_PURPLE,
|
||||
|
|
|
@ -27,6 +27,8 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import static baritone.utils.Helper.HELPER;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
* @since 8/1/2018 12:56 AM
|
||||
|
@ -115,12 +117,12 @@ public final class Utils {
|
|||
}
|
||||
|
||||
public static double playerDistanceToCenter(BlockPos pos) {
|
||||
EntityPlayerSP player = (new Helper() {}).player();
|
||||
EntityPlayerSP player = HELPER.player();
|
||||
return distanceToCenter(pos, player.posX, player.posY, player.posZ);
|
||||
}
|
||||
|
||||
public static double playerFlatDistanceToCenter(BlockPos pos) {
|
||||
EntityPlayerSP player = (new Helper() {}).player();
|
||||
EntityPlayerSP player = HELPER.player();
|
||||
return distanceToCenter(pos, player.posX, pos.getY() + 0.5, player.posZ);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue