Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Nov 1, 2023
1 parent 078fbcb commit 545c552
Show file tree
Hide file tree
Showing 33 changed files with 156 additions and 117 deletions.
26 changes: 19 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
import net.fabricmc.loom.task.RemapJarTask

plugins {
id 'org.quiltmc.loom' version '1.+'
id 'io.github.ladysnake.chenille' version "0.9.0"
id 'io.github.juuxel.loom-quiltflower' version "1.6.0"
id 'org.quiltmc.loom' version '1.4.+'
id 'io.github.ladysnake.chenille' version "0.11.3"
}

group project.maven_group
Expand Down Expand Up @@ -82,6 +81,11 @@ repositories {
jamieswhiteshirt()
}

maven {
name = 'Quilt Snapshots'
url = 'https://maven.quiltmc.org/repository/snapshot'
}

mavenLocal()
}

Expand All @@ -93,10 +97,18 @@ dependencies {
modImplementation "org.quiltmc:qsl:${qsl_version}+${minecraft_version}"
modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilted_fabric_api_version}-${minecraft_version}"
implementation 'com.google.code.findbugs:jsr305:3.0.2'
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-world:${cca_version}"
modImplementation "com.jamieswhiteshirt:reach-entity-attributes:${reach_version}"
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${cca_version}") {
transitive = false
}
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${cca_version}") {
transitive = false
}
modImplementation("dev.onyxstudios.cardinal-components-api:cardinal-components-world:${cca_version}") {
transitive = false
}
modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_version}") {
transitive = false
}
modLocalImplementation("io.github.ladysnake:elmendorf:${elmendorf_version}") {
transitive = false
}
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
------------------------------------------------------
Version 0.11.0
------------------------------------------------------
Updated to 1.20.1

- Merged fix from 0.9.1

------------------------------------------------------
Version 0.10.0
------------------------------------------------------
Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
org.gradle.jvmargs = -Xmx3G

mod_name = Automatone
mod_version = 0.10.0
mod_version = 0.11.0
maven_group = io.github.ladysnake

minecraft_version = 1.19.3
quilt_mappings = 20
quilt_loader_version=0.18.1-beta.60
qsl_version = 4.0.0-beta.9
quilted_fabric_api_version = 5.0.0-beta.1+0.73.0
cca_version = 5.0.1
reach_version = 2.3.1
elmendorf_version = 0.9.0
minecraft_version = 1.20.1
quilt_mappings = 7
quilt_loader_version=0.21.1
qsl_version = 6.0.3
quilted_fabric_api_version = 7.0.4+0.84.0
cca_version = 5.2.1
reach_version = 2.4.0
elmendorf_version = 0.11.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 9 additions & 7 deletions src/api/java/baritone/api/command/ICommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ default boolean hiddenFromHelp() {
* @param components The components to send
*/
default void logDirect(ServerCommandSource source, Text... components) {
MutableText component = Text.literal("");
// If we are not logging as a Toast
// Append the prefix to the base component line
component.append(BaritoneAPI.getPrefix());
component.append(Text.literal(" "));
Arrays.asList(components).forEach(component::append);
source.sendFeedback(component, false);
source.sendFeedback(() -> {
MutableText component = Text.literal("");
// If we are not logging as a Toast
// Append the prefix to the base component line
component.append(BaritoneAPI.getPrefix());
component.append(Text.literal(" "));
for (Text t : components) component.append(t);
return component;
}, false);
}

/**
Expand Down
21 changes: 12 additions & 9 deletions src/api/java/baritone/api/command/helpers/Paginator.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ public void display(Function<E, Text> transform, String commandPrefix) {
int offset = (page - 1) * pageSize;
for (int i = offset; i < offset + pageSize; i++) {
if (i < entries.size()) {
source.sendFeedback(transform.apply(entries.get(i)), false);
E entry = entries.get(i);
source.sendFeedback(() -> transform.apply(entry), false);
} else {
source.sendFeedback(Text.literal("--").formatted(Formatting.DARK_GRAY), false);
source.sendFeedback(() -> Text.literal("--").formatted(Formatting.DARK_GRAY), false);
}
}
boolean hasPrevPage = commandPrefix != null && validPage(page - 1);
Expand Down Expand Up @@ -100,13 +101,15 @@ public void display(Function<E, Text> transform, String commandPrefix) {
} else {
nextPageComponent.setStyle(nextPageComponent.getStyle().withFormatting(Formatting.DARK_GRAY));
}
MutableText pagerComponent = Text.literal("");
pagerComponent.setStyle(pagerComponent.getStyle().withFormatting(Formatting.GRAY));
pagerComponent.append(prevPageComponent);
pagerComponent.append(" | ");
pagerComponent.append(nextPageComponent);
pagerComponent.append(String.format(" %d/%d", page, getMaxPage()));
source.sendFeedback(pagerComponent, false);
source.sendFeedback(() -> {
MutableText pagerComponent = Text.literal("");
pagerComponent.setStyle(pagerComponent.getStyle().withFormatting(Formatting.GRAY));
pagerComponent.append(prevPageComponent);
pagerComponent.append(" | ");
pagerComponent.append(nextPageComponent);
pagerComponent.append(String.format(" %d/%d", page, getMaxPage()));
return pagerComponent;
}, false);
}

public static <T> void paginate(IArgConsumer consumer, Paginator<T> pagi, Runnable pre, Function<T, Text> transform, String commandPrefix) throws CommandException {
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/event/events/PacketEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import baritone.api.event.events.type.EventState;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.Packet;

/**
* @author Brady
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ public void setDisplayProfile(@CheckForNull GameProfile profile) {
@Override
public void playSound(SoundEvent sound, float volume, float pitch) {
if (!this.isSilent()) {
this.world.playSound(this.getX(), this.getY(), this.getZ(), sound, this.getSoundCategory(), volume, pitch, false);
this.getWorld().playSound(this.getX(), this.getY(), this.getZ(), sound, this.getSoundCategory(), volume, pitch, false);
}
}

@Override
public void playSound(SoundEvent event, SoundCategory category, float volume, float pitch) {
this.world.playSound(this.getX(), this.getY(), this.getZ(), event, category, volume, pitch, false);
this.getWorld().playSound(this.getX(), this.getY(), this.getZ(), event, category, volume, pitch, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import net.minecraft.nbt.NbtHelper;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.NetworkSide;
import net.minecraft.network.Packet;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
Expand Down Expand Up @@ -80,7 +80,7 @@ public FakeServerPlayerEntity(EntityType<? extends PlayerEntity> type, ServerWor
public FakeServerPlayerEntity(EntityType<? extends PlayerEntity> type, ServerWorld world, GameProfile profile) {
super(world.getServer(), world, profile);
((IEntityAccessor)this).automatone$setType(type);
this.stepHeight = 0.6f; // same step height as LivingEntity
this.setStepHeight(0.6f); // same step height as LivingEntity
// Side effects go brr
new ServerPlayNetworkHandler(world.getServer(), new ClientConnection(NetworkSide.S2C), this);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ public void takeKnockback(double strength, double x, double z) {

@Override
protected void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition) {
this.handleFall(heightDifference, onGround);
this.handleFall(0, heightDifference, 0, onGround);
}

@Override
Expand Down
18 changes: 10 additions & 8 deletions src/api/java/baritone/api/utils/BlockOptionalMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.loot.LootTables;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameterSet;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.server.world.ServerWorld;
Expand Down Expand Up @@ -142,14 +143,15 @@ private static synchronized List<Item> drops(ServerWorld world, Block b) {
} else {
List<Item> items = new ArrayList<>();

world.getServer().getLootManager().getTable(lootTableLocation).generateLoot(
new LootContext.Builder(world)
.random(world.random)
.parameter(LootContextParameters.ORIGIN, Vec3d.of(BlockPos.ZERO))
.parameter(LootContextParameters.TOOL, ItemStack.EMPTY)
.optionalParameter(LootContextParameters.BLOCK_ENTITY, null)
.parameter(LootContextParameters.BLOCK_STATE, block.getDefaultState())
.build(LootContextTypes.BLOCK),
world.getServer().getLootManager().getLootTable(lootTableLocation).generateLoot(
new LootContext.Builder(new LootContextParameterSet.Builder(world)
.add(LootContextParameters.ORIGIN, Vec3d.of(BlockPos.ZERO))
.add(LootContextParameters.TOOL, ItemStack.EMPTY)
.addOptional(LootContextParameters.BLOCK_ENTITY, null)
.add(LootContextParameters.BLOCK_STATE, block.getDefaultState())
.build(LootContextTypes.BLOCK))
.withRandomSeed(world.getSeed())
.build(null),
stack -> items.add(stack.getItem())
);
return items;
Expand Down
2 changes: 1 addition & 1 deletion src/api/java/baritone/api/utils/RayTraceUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static HitResult rayTraceTowards(Entity entity, Rotation rotation, double
direction.y * blockReachDistance,
direction.z * blockReachDistance
);
return entity.world.raycast(new RaycastContext(start, end, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, entity));
return entity.getWorld().raycast(new RaycastContext(start, end, RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, entity));
}

public static Vec3d inferSneakingEyePosition(Entity entity) {
Expand Down
8 changes: 4 additions & 4 deletions src/api/java/baritone/api/utils/RotationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ public static Optional<Rotation> reachable(LivingEntity entity, BlockPos pos, do
return possibleRotation;
}

BlockState state = entity.world.getBlockState(pos);
VoxelShape shape = state.getOutlineShape(entity.world, pos);
BlockState state = entity.getWorld().getBlockState(pos);
VoxelShape shape = state.getOutlineShape(entity.getWorld(), pos);
if (shape.isEmpty()) {
shape = VoxelShapes.fullCube();
}
Expand Down Expand Up @@ -234,7 +234,7 @@ public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Ve
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation);
}
if (entity.world.getBlockState(pos).getBlock() instanceof AbstractFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.down())) {
if (entity.getWorld().getBlockState(pos).getBlock() instanceof AbstractFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.down())) {
return Optional.of(rotation);
}
}
Expand All @@ -251,6 +251,6 @@ public static Optional<Rotation> reachableOffset(Entity entity, BlockPos pos, Ve
* @return The optional rotation
*/
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.world, pos), blockReachDistance, wouldSneak);
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.getWorld(), pos), blockReachDistance, wouldSneak);
}
}
2 changes: 1 addition & 1 deletion src/main/java/baritone/AutomatoneClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private <P extends PlayerEntity & AutomatoneFakePlayer> void spawnPlayer(int id,
P other = FakeClientPlayerEntity.createClientFakePlayer(playerType, world, new GameProfile(uuid, name));
other.setId(id);
other.setPosition(x, y, z);
other.getPacketPositionCodec().m_tnxpdgof(new Vec3d(x, y, z));
other.getPacketPositionCodec().setPos(new Vec3d(x, y, z));
other.bodyYaw = headYaw;
other.prevBodyYaw = headYaw;
other.headYaw = headYaw;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/Baritone.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public Baritone(LivingEntity player) {

this.commandManager = new BaritoneCommandManager(this);
this.execControlProcess = DefaultCommands.controlCommands.registerProcess(this);
this.clientPathingBehaviour = player.world.isClient ? new ClientPathingBehaviour(player) : null;
this.clientPathingBehaviour = player.getWorld().isClient ? new ClientPathingBehaviour(player) : null;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/BaritoneProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BaritoneProvider() {

@Override
public IBaritone getBaritone(LivingEntity entity) {
if (entity.world.isClient()) throw new IllegalStateException("Lol we only support servers now");
if (entity.getWorld().isClient()) throw new IllegalStateException("Lol we only support servers now");
return IBaritone.KEY.get(entity);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/command/defaults/BuildCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void execute(ServerCommandSource source, String label, IArgConsumer args,
if (FilenameUtils.getExtension(file.getAbsolutePath()).isEmpty()) {
file = new File(file.getAbsolutePath() + "." + baritone.settings().schematicFallbackExtension.get());
}
BetterBlockPos origin = new BetterBlockPos(new BlockPos(source.getPosition()));
BetterBlockPos origin = new BetterBlockPos(BlockPos.fromPosition(source.getPosition()));
BetterBlockPos buildOrigin;
if (args.hasAny()) {
args.requireMax(3);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/baritone/command/defaults/ComeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public ComeCommand() {
@Override
public void execute(ServerCommandSource source, String label, IArgConsumer args, IBaritone baritone) throws CommandException {
args.requireMax(0);
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(new BlockPos(source.getPosition())));
baritone.getCustomGoalProcess().setGoalAndPath(new GoalBlock(BlockPos.fromPosition(source.getPosition())));
logDirect(source, "Coming");
}

Expand Down
28 changes: 15 additions & 13 deletions src/main/java/baritone/command/defaults/DefaultCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,26 @@ private static void logRanCommand(ServerCommandSource source, String command, St
if (BaritoneAPI.getGlobalSettings().echoCommands.get()) {
String msg = command + rest;
String toDisplay = BaritoneAPI.getGlobalSettings().censorRanCommands.get() ? command + " ..." : msg;
MutableText component = Text.literal(String.format("> %s", toDisplay));
component.setStyle(component.getStyle()
.withFormatting(Formatting.WHITE)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
Text.literal("Click to rerun command")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
FORCE_COMMAND_PREFIX + msg
)));
source.sendFeedback(component, false);
source.sendFeedback(() -> {
MutableText component = Text.literal(String.format("> %s", toDisplay));
component.setStyle(component.getStyle()
.withFormatting(Formatting.WHITE)
.withHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT,
Text.literal("Click to rerun command")
))
.withClickEvent(new ClickEvent(
ClickEvent.Action.RUN_COMMAND,
FORCE_COMMAND_PREFIX + msg
)));
return component;
}, false);
}
}

public static boolean runCommand(ServerCommandSource source, String msg, IBaritone baritone) throws CommandException {
if (msg.trim().equalsIgnoreCase("damn")) {
source.sendFeedback(Text.literal("daniel"), false);
source.sendFeedback(() -> Text.literal("daniel"), false);
return false;
} else if (msg.trim().equalsIgnoreCase("orderpizza")) {
Automatone.LOGGER.fatal("No pizza :(");
Expand Down
1 change: 1 addition & 0 deletions src/main/java/baritone/command/defaults/SelCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public List<String> getLongDesc() {

public void renderSelectionBox() {
Settings settings = BaritoneAPI.getGlobalSettings();
BetterBlockPos pos1 = this.pos1;
if (!settings.renderSelectionCorners.get() || pos1 == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static boolean isReplaceable(int x, int y, int z, BlockState state, BlockStateIn
if (block == Blocks.LARGE_FERN || block == Blocks.TALL_GRASS) {
return true;
}
return state.getMaterial().isReplaceable();
return state.materialReplaceable();
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public MovementState updateState(MovementState state) {
if (!blockIsThere) {
BlockState frState = BlockStateInterface.get(ctx, src);
// TODO: Evaluate usage of getMaterial().isReplaceable()
if (!(frState.isAir() || frState.getMaterial().isReplaceable())) {
if (!(frState.isAir() || frState.materialReplaceable())) {
RotationUtils.reachable(ctx.entity(), src, ctx.playerController().getBlockReachDistance())
.map(rot -> new MovementState.MovementTarget(rot, true))
.ifPresent(state::setTarget);
Expand Down
Loading

0 comments on commit 545c552

Please sign in to comment.