This commit is contained in:
Wagyourtail
2022-05-31 02:38:55 -06:00
parent db9ee98762
commit 9e021d2875
25 changed files with 105 additions and 102 deletions

View File

@@ -237,11 +237,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
if (current != null) {
switch (event.getState()) {
case PRE:
lastAutoJump = mc.options.autoJump;
mc.options.autoJump = false;
lastAutoJump = mc.options.autoJump().get();
mc.options.autoJump().set(false);
break;
case POST:
mc.options.autoJump = lastAutoJump;
mc.options.autoJump().set(lastAutoJump);
break;
default:
break;

View File

@@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.PalettedContainer;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.phys.Vec3;
import java.util.*;
@@ -171,7 +172,7 @@ public final class ChunkPacker {
if (dimension.ultraWarm()) {
return Blocks.NETHERRACK.defaultBlockState();
}
if (dimension.createDragonFight()) {
if (dimension.effectsLocation().equals(BuiltinDimensionTypes.END_EFFECTS)) {
return Blocks.END_STONE.defaultBlockState();
}
default:

View File

@@ -35,10 +35,8 @@ import baritone.command.argument.CommandArguments;
import baritone.command.manager.CommandManager;
import baritone.utils.accessor.IGuiScreen;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Tuple;
import java.net.URI;
import java.net.URISyntaxException;
@@ -78,12 +76,12 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
if (settings.echoCommands.value) {
String msg = command + rest;
String toDisplay = settings.censorRanCommands.value ? command + " ..." : msg;
BaseComponent component = new TextComponent(String.format("> %s", toDisplay));
MutableComponent component = Component.literal(String.format("> %s", toDisplay));
component.setStyle(component.getStyle()
.withColor(ChatFormatting.WHITE)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to rerun command")
Component.literal("Click to rerun command")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,

View File

@@ -25,16 +25,18 @@ import baritone.api.command.exception.CommandException;
import baritone.api.command.exception.CommandNotFoundException;
import baritone.api.command.helpers.Paginator;
import baritone.api.command.helpers.TabCompleteHelper;
import java.awt.*;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.MutableComponent;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@@ -58,17 +60,17 @@ public class HelpCommand extends Command {
command -> {
String names = String.join("/", command.getNames());
String name = command.getNames().get(0);
TextComponent shortDescComponent = new TextComponent(" - " + command.getShortDesc());
MutableComponent shortDescComponent = Component.literal(" - " + command.getShortDesc());
shortDescComponent.setStyle(shortDescComponent.getStyle().withColor(ChatFormatting.DARK_GRAY));
TextComponent namesComponent = new TextComponent(names);
MutableComponent namesComponent = Component.literal(names);
namesComponent.setStyle(namesComponent.getStyle().withColor(ChatFormatting.WHITE));
TextComponent hoverComponent = new TextComponent("");
MutableComponent hoverComponent = Component.literal("");
hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY));
hoverComponent.append(namesComponent);
hoverComponent.append("\n" + command.getShortDesc());
hoverComponent.append("\n\nClick to view full help");
String clickCommand = FORCE_COMMAND_PREFIX + String.format("%s %s", label, command.getNames().get(0));
TextComponent component = new TextComponent(name);
MutableComponent component = Component.literal(name);
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
component.append(shortDescComponent);
component.setStyle(component.getStyle()
@@ -88,7 +90,7 @@ public class HelpCommand extends Command {
logDirect("");
command.getLongDesc().forEach(this::logDirect);
logDirect("");
BaseComponent returnComponent = new TextComponent("Click to return to the help menu");
MutableComponent returnComponent = Component.literal("Click to return to the help menu");
returnComponent.setStyle(returnComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
FORCE_COMMAND_PREFIX + label

View File

@@ -37,7 +37,7 @@ public class RenderCommand extends Command {
public void execute(String label, IArgConsumer args) throws CommandException {
args.requireMax(0);
BetterBlockPos origin = ctx.playerFeet();
int renderDistance = (mc.options.renderDistance + 1) * 16;
int renderDistance = (mc.options.renderDistance().get() + 1) * 16;
mc.levelRenderer.setBlocksDirty(
origin.x - renderDistance,
0,

View File

@@ -34,10 +34,8 @@ import java.util.Locale;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.*;
import net.minecraft.network.chat.MutableComponent;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
import static baritone.api.utils.SettingsUtil.*;
@@ -77,19 +75,19 @@ public class SetCommand extends Command {
: String.format("All %ssettings:", viewModified ? "modified " : "")
),
setting -> {
TextComponent typeComponent = new TextComponent(String.format(
MutableComponent typeComponent = Component.literal(String.format(
" (%s)",
settingTypeToString(setting)
));
typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY);
TextComponent hoverComponent = new TextComponent("");
MutableComponent hoverComponent = Component.literal("");
hoverComponent.getStyle().withColor(ChatFormatting.GRAY);
hoverComponent.append(setting.getName());
hoverComponent.append(String.format("\nType: %s", settingTypeToString(setting)));
hoverComponent.append(String.format("\n\nValue:\n%s", settingValueToString(setting)));
hoverComponent.append(String.format("\n\nDefault Value:\n%s", settingDefaultToString(setting)));
String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName());
TextComponent component = new TextComponent(setting.getName());
MutableComponent component = Component.literal(setting.getName());
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
component.append(typeComponent);
component.setStyle(component.getStyle()
@@ -169,12 +167,12 @@ public class SetCommand extends Command {
settingValueToString(setting)
));
}
BaseComponent oldValueComponent = new TextComponent(String.format("Old value: %s", oldValue));
MutableComponent oldValueComponent = Component.literal(String.format("Old value: %s", oldValue));
oldValueComponent.setStyle(oldValueComponent.getStyle()
.withColor(ChatFormatting.GRAY)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to set the setting back to this value")
Component.literal("Click to set the setting back to this value")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,

View File

@@ -40,11 +40,11 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.MutableComponent;
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
@@ -63,13 +63,13 @@ public class WaypointsCommand extends Command {
throw new CommandInvalidTypeException(args.consumed(), "an action");
}
BiFunction<IWaypoint, Action, Component> toComponent = (waypoint, _action) -> {
BaseComponent component = new TextComponent("");
BaseComponent tagComponent = new TextComponent(waypoint.getTag().name() + " ");
MutableComponent component = Component.literal("");
MutableComponent tagComponent = Component.literal(waypoint.getTag().name() + " ");
tagComponent.setStyle(tagComponent.getStyle().withColor(ChatFormatting.GRAY));
String name = waypoint.getName();
BaseComponent nameComponent = new TextComponent(!name.isEmpty() ? name : "<empty>");
MutableComponent nameComponent = Component.literal(!name.isEmpty() ? name : "<empty>");
nameComponent.setStyle(nameComponent.getStyle().withColor(!name.isEmpty() ? ChatFormatting.GRAY : ChatFormatting.DARK_GRAY));
BaseComponent timestamp = new TextComponent(" @ " + new Date(waypoint.getCreationTimestamp()));
MutableComponent timestamp = Component.literal(" @ " + new Date(waypoint.getCreationTimestamp()));
timestamp.setStyle(timestamp.getStyle().withColor(ChatFormatting.DARK_GRAY));
component.append(tagComponent);
component.append(nameComponent);
@@ -77,7 +77,7 @@ public class WaypointsCommand extends Command {
component.setStyle(component.getStyle()
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
new TextComponent("Click to select")
Component.literal("Click to select")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
@@ -143,7 +143,7 @@ public class WaypointsCommand extends Command {
args.requireMax(0);
IWaypoint waypoint = new Waypoint(name, tag, pos);
ForWaypoints.waypoints(this.baritone).addWaypoint(waypoint);
BaseComponent component = new TextComponent("Waypoint added: ");
MutableComponent component = Component.literal("Waypoint added: ");
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
component.append(toComponent.apply(waypoint, Action.INFO));
logDirect(component);
@@ -155,8 +155,8 @@ public class WaypointsCommand extends Command {
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
}
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.<IWaypoint>asList(waypoints));
TextComponent textComponent = new TextComponent(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
textComponent.getStyle().withClickEvent(new ClickEvent(
MutableComponent MutableComponent = Component.literal(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
MutableComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
"%s%s restore @ %s",
@@ -165,7 +165,7 @@ public class WaypointsCommand extends Command {
Stream.of(waypoints).map(wp -> Long.toString(wp.getCreationTimestamp())).collect(Collectors.joining(" "))
)
));
logDirect(textComponent);
logDirect(MutableComponent);
} else if (action == Action.RESTORE) {
List<IWaypoint> waypoints = new ArrayList<>();
List<IWaypoint> deletedWaypoints = this.deletedWaypoints.getOrDefault(baritone.getWorldProvider().getCurrentWorld(), Collections.emptyList());
@@ -236,7 +236,7 @@ public class WaypointsCommand extends Command {
if (action == Action.INFO) {
logDirect(transform.apply(waypoint));
logDirect(String.format("Position: %s", waypoint.getLocation()));
BaseComponent deleteComponent = new TextComponent("Click to delete this waypoint");
MutableComponent deleteComponent = Component.literal("Click to delete this waypoint");
deleteComponent.setStyle(deleteComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -247,7 +247,7 @@ public class WaypointsCommand extends Command {
waypoint.getCreationTimestamp()
)
)));
BaseComponent goalComponent = new TextComponent("Click to set goal to this waypoint");
MutableComponent goalComponent = Component.literal("Click to set goal to this waypoint");
goalComponent.setStyle(goalComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -258,7 +258,7 @@ public class WaypointsCommand extends Command {
waypoint.getCreationTimestamp()
)
)));
BaseComponent recreateComponent = new TextComponent("Click to show a command to recreate this waypoint");
MutableComponent recreateComponent = Component.literal("Click to show a command to recreate this waypoint");
recreateComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.SUGGEST_COMMAND,
String.format(
@@ -272,7 +272,7 @@ public class WaypointsCommand extends Command {
waypoint.getLocation().z
)
));
BaseComponent backComponent = new TextComponent("Click to return to the waypoints list");
MutableComponent backComponent = Component.literal("Click to return to the waypoints list");
backComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
@@ -288,8 +288,8 @@ public class WaypointsCommand extends Command {
} else if (action == Action.DELETE) {
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint);
TextComponent textComponent = new TextComponent("That waypoint has successfully been deleted, click to restore it");
textComponent.getStyle().withClickEvent(new ClickEvent(
MutableComponent MutableComponent = Component.literal("That waypoint has successfully been deleted, click to restore it");
MutableComponent.getStyle().withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
String.format(
"%s%s restore @ %s",
@@ -298,7 +298,7 @@ public class WaypointsCommand extends Command {
waypoint.getCreationTimestamp()
)
));
logDirect(textComponent);
logDirect(MutableComponent);
} else if (action == Action.GOAL) {
Goal goal = new GoalBlock(waypoint.getLocation());
baritone.getCustomGoalProcess().setGoal(goal);

View File

@@ -30,15 +30,16 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.BaseComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import java.awt.*;
import java.util.Collections;
@@ -53,7 +54,7 @@ public class GuiClick extends Screen implements Helper {
private BlockPos currentMouseOver;
public GuiClick() {
super(new TextComponent("CLICK"));
super(Component.literal("CLICK"));
}
@Override
@@ -90,7 +91,7 @@ public class GuiClick extends Screen implements Helper {
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections();
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver));
BaseComponent component = new TextComponent("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
MutableComponent component = Component.literal("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
component.getStyle()
.withColor(ChatFormatting.WHITE)
.withClickEvent(new ClickEvent(

View File

@@ -28,7 +28,7 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input {
}
@Override
public void tick(boolean p_225607_1_) {
public void tick(boolean p_225607_1_, float f) {
this.leftImpulse = 0.0F;
this.forwardImpulse = 0.0F;

View File

@@ -73,7 +73,7 @@ public class Avoidance {
if (mobCoeff != 1.0D) {
ctx.entitiesStream()
.filter(entity -> entity instanceof Mob)
.filter(entity -> (!(entity instanceof Spider)) || ctx.player().getBrightness() < 0.5)
.filter(entity -> (!(entity instanceof Spider)) || ctx.player().getLightLevelDependentMagicValue() < 0.5)
.filter(entity -> !(entity instanceof ZombifiedPiglin) || ((ZombifiedPiglin) entity).getLastHurtByMob() != null)
.filter(entity -> !(entity instanceof EnderMan) || ((EnderMan) entity).isCreepy())
.forEach(entity -> res.add(new Avoidance(entity.blockPosition(), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));

View File

@@ -76,12 +76,12 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
@Override
public InteractionResult processRightClickBlock(LocalPlayer player, Level world, InteractionHand hand, BlockHitResult result) {
// primaryplayercontroller is always in a ClientWorld so this is ok
return mc.gameMode.useItemOn(player, (ClientLevel) world, hand, result);
return mc.gameMode.useItemOn(player, hand, result);
}
@Override
public InteractionResult processRightClick(LocalPlayer player, Level world, InteractionHand hand) {
return mc.gameMode.useItem(player, world, hand);
return mc.gameMode.useItem(player, hand);
}
@Override