diff --git a/build.gradle b/build.gradle index 27ad8fbb6..f9391f8f1 100755 --- a/build.gradle +++ b/build.gradle @@ -81,9 +81,9 @@ repositories { dependencies { if (compileType.equals("FORGE")) { - forge "net.minecraftforge:forge:1.16.5-36.1.0" + //forge "net.minecraftforge:forge:1.16.5-36.1.0" } - minecraft "com.mojang:minecraft:1.16.5" + minecraft "com.mojang:minecraft:1.17" mappings minecraft.officialMojangMappings() if (!compileType.equals("FORGE")) { modImplementation "net.fabricmc:fabric-loader:0.9.1+build.205" diff --git a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java index 89d066619..1aaf3578f 100644 --- a/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java +++ b/buildSrc/src/main/java/baritone/gradle/task/BaritoneGradleTask.java @@ -99,7 +99,7 @@ class BaritoneGradleTask extends DefaultTask { } protected Path getRelativeFile(String file) { - return Paths.get(new File(getProject().getBuildDir(), file).getAbsolutePath()); + return Paths.get(new File(new File(getProject().getBuildDir(), "../"), file).getAbsolutePath()); } protected Path getTemporaryFile(String file) { @@ -107,6 +107,6 @@ class BaritoneGradleTask extends DefaultTask { } protected Path getBuildFile(String file) { - return getRelativeFile("libs/" + file); + return getRelativeFile("build/libs/" + file); } } diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index 89b03b535..14f00055e 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -30,6 +30,7 @@ import java.lang.reflect.Field; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.*; +import java.util.List; import java.util.function.Consumer; /** diff --git a/src/api/java/baritone/api/utils/BlockOptionalMeta.java b/src/api/java/baritone/api/utils/BlockOptionalMeta.java index f01c88c24..d7b1b8148 100644 --- a/src/api/java/baritone/api/utils/BlockOptionalMeta.java +++ b/src/api/java/baritone/api/utils/BlockOptionalMeta.java @@ -21,7 +21,6 @@ import baritone.api.utils.accessor.IItemStack; import com.google.common.collect.ImmutableSet; import io.netty.util.concurrent.ThreadPerTaskExecutor; import net.minecraft.core.BlockPos; -import net.minecraft.loot.*; import net.minecraft.resources.*; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.packs.PackResources; @@ -145,7 +144,7 @@ public final class BlockOptionalMeta { public static LootTables getManager() { if (manager == null) { - PackRepository rpl = new PackRepository(Pack::new, new ServerPacksSource()); + PackRepository rpl = new PackRepository(PackType.SERVER_DATA, new ServerPacksSource()); rpl.reload(); PackResources thePack = rpl.getAvailablePacks().iterator().next().open(); ReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(PackType.SERVER_DATA); diff --git a/src/api/java/baritone/api/utils/IPlayerContext.java b/src/api/java/baritone/api/utils/IPlayerContext.java index dd91bdab3..4e29b1459 100644 --- a/src/api/java/baritone/api/utils/IPlayerContext.java +++ b/src/api/java/baritone/api/utils/IPlayerContext.java @@ -86,7 +86,7 @@ public interface IPlayerContext { } default Rotation playerRotations() { - return new Rotation(player().yRot, player().xRot); + return new Rotation(player().getYRot(), player().getXRot()); } static double eyeHeight(boolean ifSneaking) { diff --git a/src/api/java/baritone/api/utils/IPlayerController.java b/src/api/java/baritone/api/utils/IPlayerController.java index 7919654be..48142d13b 100644 --- a/src/api/java/baritone/api/utils/IPlayerController.java +++ b/src/api/java/baritone/api/utils/IPlayerController.java @@ -25,7 +25,6 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.ClickType; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; @@ -44,7 +43,7 @@ public interface IPlayerController { void resetBlockRemoving(); - ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player); + void windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player); GameType getGameType(); diff --git a/src/api/java/baritone/api/utils/RotationUtils.java b/src/api/java/baritone/api/utils/RotationUtils.java index 4c90be512..a6156354e 100644 --- a/src/api/java/baritone/api/utils/RotationUtils.java +++ b/src/api/java/baritone/api/utils/RotationUtils.java @@ -179,7 +179,7 @@ public final class RotationUtils { * * or if you're a normal person literally all this does it ensure that we don't nudge the pitch to a normal level */ - Rotation hypothetical = new Rotation(entity.yRot, entity.xRot + 0.0001F); + Rotation hypothetical = new Rotation(entity.getYRot(), entity.getXRot() + 0.0001F); if (wouldSneak) { // the concern here is: what if we're looking at it now, but as soon as we start sneaking we no longer are HitResult result = RayTraceUtils.rayTraceTowards(entity, hypothetical, blockReachDistance, true); @@ -226,7 +226,7 @@ public final class RotationUtils { */ public static Optional reachableOffset(Entity entity, BlockPos pos, Vec3 offsetPos, double blockReachDistance, boolean wouldSneak) { Vec3 eyes = wouldSneak ? RayTraceUtils.inferSneakingEyePosition(entity) : entity.getEyePosition(1.0F); - Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.yRot, entity.xRot)); + Rotation rotation = calcRotationFromVec3d(eyes, offsetPos, new Rotation(entity.getYRot(), entity.getXRot())); HitResult result = RayTraceUtils.rayTraceTowards(entity, rotation, blockReachDistance, wouldSneak); //System.out.println(result); if (result != null && result.getType() == HitResult.Type.BLOCK) { diff --git a/src/api/java/baritone/api/utils/gui/BaritoneToast.java b/src/api/java/baritone/api/utils/gui/BaritoneToast.java index 3429aa2df..3ed665e3e 100644 --- a/src/api/java/baritone/api/utils/gui/BaritoneToast.java +++ b/src/api/java/baritone/api/utils/gui/BaritoneToast.java @@ -43,8 +43,10 @@ public class BaritoneToast implements Toast { this.newDisplay = false; } - toastGui.getMinecraft().getTextureManager().bind(new ResourceLocation("textures/gui/toasts.png")); - GlStateManager._color4f(1.0F, 1.0F, 1.0F, 255.0f); + + //TODO: fix + toastGui.getMinecraft().getTextureManager().bindForSetup(new ResourceLocation("textures/gui/toasts.png")); + //GlStateManager._color4f(1.0F, 1.0F, 1.0F, 255.0F); toastGui.blit(matrixStack, 0, 0, 0, 32, 160, 32); if (this.subtitle == null) { diff --git a/src/launch/java/baritone/launch/mixins/MixinChunkArray.java b/src/launch/java/baritone/launch/mixins/MixinChunkArray.java index f6372c33e..a40fe4d31 100644 --- a/src/launch/java/baritone/launch/mixins/MixinChunkArray.java +++ b/src/launch/java/baritone/launch/mixins/MixinChunkArray.java @@ -25,23 +25,23 @@ import java.util.concurrent.atomic.AtomicReferenceArray; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.LevelChunk; -@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkProvider$ChunkArray") +@Mixin(targets = "net.minecraft.client.multiplayer.ClientChunkCache$Storage") public abstract class MixinChunkArray implements IChunkArray { @Shadow private AtomicReferenceArray chunks; @Shadow - private int viewDistance; + private int chunkRadius; @Shadow - private int sideLength; + private int viewRange; @Shadow - private int centerX; + private int viewCenterX; @Shadow - private int centerZ; + private int viewCenterZ; @Shadow - private int loaded; + private int chunkCount; @Shadow - protected abstract boolean inView(int x, int z); + protected abstract boolean inRange(int x, int z); @Shadow protected abstract int getIndex(int x, int z); @@ -51,17 +51,17 @@ public abstract class MixinChunkArray implements IChunkArray { @Override public int centerX() { - return centerX; + return viewCenterX; } @Override public int centerZ() { - return centerZ; + return viewCenterZ; } @Override public int viewDistance() { - return viewDistance; + return chunkRadius; } @Override @@ -71,15 +71,15 @@ public abstract class MixinChunkArray implements IChunkArray { @Override public void copyFrom(IChunkArray other) { - centerX = other.centerX(); - centerZ = other.centerZ(); + viewCenterX = other.centerX(); + viewCenterZ = other.centerZ(); AtomicReferenceArray copyingFrom = other.getChunks(); for (int k = 0; k < copyingFrom.length(); ++k) { LevelChunk chunk = copyingFrom.get(k); if (chunk != null) { ChunkPos chunkpos = chunk.getPos(); - if (inView(chunkpos.x, chunkpos.z)) { + if (inRange(chunkpos.x, chunkpos.z)) { int index = getIndex(chunkpos.x, chunkpos.z); if (chunks.get(index) != null) { throw new IllegalStateException("Doing this would mutate the client's REAL loaded chunks?!"); diff --git a/src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java b/src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java index fe89bc4e3..de465b82a 100644 --- a/src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientChunkProvider.java @@ -19,6 +19,7 @@ package baritone.launch.mixins; import baritone.utils.accessor.IChunkArray; import baritone.utils.accessor.IClientChunkProvider; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -30,13 +31,14 @@ import net.minecraft.client.multiplayer.ClientLevel; @Mixin(ClientChunkCache.class) public class MixinClientChunkProvider implements IClientChunkProvider { + @Final @Shadow - private ClientLevel world; + ClientLevel level; @Override public ClientChunkCache createThreadSafeCopy() { IChunkArray arr = extractReferenceArray(); - ClientChunkCache result = new ClientChunkCache(world, arr.viewDistance() - 3); // -3 because its adds 3 for no reason lmao + ClientChunkCache result = new ClientChunkCache(level, arr.viewDistance() - 3); // -3 because its adds 3 for no reason lmao IChunkArray copyArr = ((IClientChunkProvider) result).extractReferenceArray(); copyArr.copyFrom(arr); if (copyArr.viewDistance() != arr.viewDistance()) { diff --git a/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java index b5348eb97..e3b1d04d2 100644 --- a/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayNetHandler.java @@ -25,12 +25,7 @@ import baritone.api.event.events.type.EventState; import baritone.cache.CachedChunk; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.player.LocalPlayer; -import net.minecraft.network.play.server.*; -import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; -import net.minecraft.network.protocol.game.ClientboundForgetLevelChunkPacket; -import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket; -import net.minecraft.network.protocol.game.ClientboundPlayerCombatPacket; -import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; +import net.minecraft.network.protocol.game.*; import net.minecraft.world.level.ChunkPos; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -69,7 +64,7 @@ public class MixinClientPlayNetHandler { }*/ @Inject( - method = "handleChunkData", + method = "handleLevelChunk", at = @At("RETURN") ) private void postHandleChunkData(ClientboundLevelChunkPacket packetIn, CallbackInfo ci) { @@ -79,7 +74,7 @@ public class MixinClientPlayNetHandler { ibaritone.getGameEventHandler().onChunkEvent( new ChunkEvent( EventState.POST, - packetIn.isFullChunk() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL, + !packetIn.isSkippable() ? ChunkEvent.Type.POPULATE_FULL : ChunkEvent.Type.POPULATE_PARTIAL, packetIn.getX(), packetIn.getZ() ) @@ -89,7 +84,7 @@ public class MixinClientPlayNetHandler { } @Inject( - method = "processChunkUnload", + method = "handleForgetLevelChunk", at = @At("HEAD") ) private void preChunkUnload(ClientboundForgetLevelChunkPacket packet, CallbackInfo ci) { @@ -104,7 +99,7 @@ public class MixinClientPlayNetHandler { } @Inject( - method = "processChunkUnload", + method = "handleForgetLevelChunk", at = @At("RETURN") ) private void postChunkUnload(ClientboundForgetLevelChunkPacket packet, CallbackInfo ci) { @@ -119,7 +114,7 @@ public class MixinClientPlayNetHandler { } @Inject( - method = "handleBlockChange", + method = "handleBlockUpdate", at = @At("RETURN") ) private void postHandleBlockChange(ClientboundBlockUpdatePacket packetIn, CallbackInfo ci) { @@ -145,7 +140,7 @@ public class MixinClientPlayNetHandler { } @Inject( - method = "handleMultiBlockChange", + method = "handleChunkBlocksUpdate", at = @At("RETURN") ) private void postHandleMultiBlockChange(ClientboundSectionBlocksUpdatePacket packetIn, CallbackInfo ci) { @@ -177,13 +172,13 @@ public class MixinClientPlayNetHandler { } @Inject( - method = "handleCombatEvent", + method = "handlePlayerCombatKill", at = @At( value = "INVOKE", - target = "net/minecraft/client/Minecraft.displayGuiScreen(Lnet/minecraft/client/gui/screen/Screen;)V" + target = "net/minecraft/client/Minecraft.setScreen(Lnet/minecraft/client/gui/screen/Screen;)V" ) ) - private void onPlayerDeath(ClientboundPlayerCombatPacket packetIn, CallbackInfo ci) { + private void onPlayerDeath(ClientboundPlayerCombatKillPacket packetIn, CallbackInfo ci) { for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { LocalPlayer player = ibaritone.getPlayerContext().player(); if (player != null && player.connection == (ClientPacketListener) (Object) this) { diff --git a/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java b/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java index 49e875ad8..c87875810 100644 --- a/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinClientPlayerEntity.java @@ -41,7 +41,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinClientPlayerEntity { @Inject( - method = "sendChatMessage", + method = "chat", at = @At("HEAD"), cancellable = true ) @@ -61,7 +61,7 @@ public class MixinClientPlayerEntity { method = "tick", at = @At( value = "INVOKE", - target = "net/minecraft/client/entity/player/ClientPlayerEntity.isPassenger()Z", + target = "net/minecraft/client/player/LocalPlayer.isPassenger()Z", shift = At.Shift.BY, by = -3 ) @@ -77,7 +77,7 @@ public class MixinClientPlayerEntity { method = "tick", at = @At( value = "INVOKE", - target = "net/minecraft/client/entity/player/ClientPlayerEntity.onUpdateWalkingPlayer()V", + target = "net/minecraft/client/player/LocalPlayer.sendPosition()V", shift = At.Shift.BY, by = 2 ) @@ -90,10 +90,10 @@ public class MixinClientPlayerEntity { } @Redirect( - method = "livingTick", + method = "aiStep", at = @At( value = "FIELD", - target = "net/minecraft/entity/player/PlayerAbilities.allowFlying:Z" + target = "net/minecraft/world/entity/player/Abilities.mayfly:Z" ) ) private boolean isAllowFlying(Abilities capabilities) { @@ -105,10 +105,10 @@ public class MixinClientPlayerEntity { } @Redirect( - method = "livingTick", + method = "aiStep", at = @At( value = "INVOKE", - target = "net/minecraft/client/settings/KeyBinding.isKeyDown()Z" + target = "net/minecraft/client/KeyMapping.isDown()Z" ) ) private boolean isKeyDown(KeyMapping keyBinding) { @@ -129,7 +129,7 @@ public class MixinClientPlayerEntity { } @Inject( - method = "updateRidden", + method = "rideTick", at = @At( value = "HEAD" ) diff --git a/src/launch/java/baritone/launch/mixins/MixinCommandSuggestionHelper.java b/src/launch/java/baritone/launch/mixins/MixinCommandSuggestionHelper.java index 0d3d1a2b4..63331502f 100644 --- a/src/launch/java/baritone/launch/mixins/MixinCommandSuggestionHelper.java +++ b/src/launch/java/baritone/launch/mixins/MixinCommandSuggestionHelper.java @@ -45,23 +45,23 @@ public class MixinCommandSuggestionHelper { @Shadow @Final - private EditBox inputField; + EditBox input; @Shadow @Final - private List exceptionList; + private List commandUsage; @Shadow - private CompletableFuture suggestionsFuture; + private CompletableFuture pendingSuggestions; @Inject( - method = "init", + method = "updateCommandInfo", at = @At("HEAD"), cancellable = true ) private void preUpdateSuggestion(CallbackInfo ci) { // Anything that is present in the input text before the cursor position - String prefix = this.inputField.getValue().substring(0, Math.min(this.inputField.getValue().length(), this.inputField.getCursorPosition())); + String prefix = this.input.getValue().substring(0, Math.min(this.input.getValue().length(), this.input.getCursorPosition())); TabCompleteEvent event = new TabCompleteEvent(prefix); BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onPreTabComplete(event); @@ -75,14 +75,14 @@ public class MixinCommandSuggestionHelper { ci.cancel(); // TODO: Support populating the command usage - this.exceptionList.clear(); + this.commandUsage.clear(); if (event.completions.length == 0) { - this.suggestionsFuture = Suggestions.empty(); + this.pendingSuggestions = Suggestions.empty(); } else { - int offset = this.inputField.getValue().endsWith(" ") - ? this.inputField.getCursorPosition() - : this.inputField.getValue().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes + int offset = this.input.getValue().endsWith(" ") + ? this.input.getCursorPosition() + : this.input.getValue().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes List suggestionList = Stream.of(event.completions) .map(s -> new Suggestion(StringRange.between(offset, offset + s.length()), s)) @@ -92,8 +92,8 @@ public class MixinCommandSuggestionHelper { StringRange.between(offset, offset + suggestionList.stream().mapToInt(s -> s.getText().length()).max().orElse(0)), suggestionList); - this.suggestionsFuture = new CompletableFuture<>(); - this.suggestionsFuture.complete(suggestions); + this.pendingSuggestions = new CompletableFuture<>(); + this.pendingSuggestions.complete(suggestions); } } } diff --git a/src/launch/java/baritone/launch/mixins/MixinEntity.java b/src/launch/java/baritone/launch/mixins/MixinEntity.java index 5e86039f3..b48e919f2 100644 --- a/src/launch/java/baritone/launch/mixins/MixinEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinEntity.java @@ -31,7 +31,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; public class MixinEntity { @Shadow - private float rotationYaw; + private float yRot; float yawRestore; @@ -40,14 +40,14 @@ public class MixinEntity { at = @At("HEAD") ) private void moveRelativeHead(CallbackInfo info) { - this.yawRestore = this.rotationYaw; + this.yawRestore = this.yRot; // noinspection ConstantConditions if (!LocalPlayer.class.isInstance(this) || BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this) == null) { return; } - RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.rotationYaw); + RotationMoveEvent motionUpdateRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.yRot); BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this).getGameEventHandler().onPlayerRotationMove(motionUpdateRotationEvent); - this.rotationYaw = motionUpdateRotationEvent.getYaw(); + this.yRot = motionUpdateRotationEvent.getYaw(); } @Inject( @@ -55,6 +55,6 @@ public class MixinEntity { at = @At("RETURN") ) private void moveRelativeReturn(CallbackInfo info) { - this.rotationYaw = this.yawRestore; + this.yRot = this.yawRestore; } } diff --git a/src/launch/java/baritone/launch/mixins/MixinItemStack.java b/src/launch/java/baritone/launch/mixins/MixinItemStack.java index 110196e90..1582bc880 100644 --- a/src/launch/java/baritone/launch/mixins/MixinItemStack.java +++ b/src/launch/java/baritone/launch/mixins/MixinItemStack.java @@ -39,10 +39,10 @@ public abstract class MixinItemStack implements IItemStack { private int baritoneHash; @Shadow - protected abstract int getDamage(); + protected abstract int getDamageValue(); private void recalculateHash() { - baritoneHash = item == null ? -1 : item.hashCode() + getDamage(); + baritoneHash = item == null ? -1 : item.hashCode() + getDamageValue(); } @Inject( @@ -54,7 +54,7 @@ public abstract class MixinItemStack implements IItemStack { } @Inject( - method = "setDamage", + method = "setDamageValue", at = @At("TAIL") ) private void onItemDamageSet(CallbackInfo ci) { diff --git a/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java b/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java index 363a36028..44a5c1e32 100644 --- a/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java +++ b/src/launch/java/baritone/launch/mixins/MixinLivingEntity.java @@ -50,7 +50,7 @@ public abstract class MixinLivingEntity extends Entity { } @Inject( - method = "jump", + method = "jumpFromGround", at = @At("HEAD") ) private void preMoveRelative(CallbackInfo ci) { @@ -58,25 +58,24 @@ public abstract class MixinLivingEntity extends Entity { if (LocalPlayer.class.isInstance(this)) { IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this); if (baritone != null) { - this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.yRot); + this.jumpRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.JUMP, this.getYRot()); baritone.getGameEventHandler().onPlayerRotationMove(this.jumpRotationEvent); } } } @Redirect( - method = "jump", + method = "jumpFromGround", at = @At( - value = "FIELD", - opcode = GETFIELD, - target = "net/minecraft/entity/LivingEntity.rotationYaw:F" + value = "INVOKE", + target = "net/minecraft/world/entity/LivingEntity.getYRot()F" ) ) private float overrideYaw(LivingEntity self) { if (self instanceof LocalPlayer && BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this) != null) { return this.jumpRotationEvent.getYaw(); } - return self.yRot; + return self.getYRot(); } diff --git a/src/launch/java/baritone/launch/mixins/MixinLootContext.java b/src/launch/java/baritone/launch/mixins/MixinLootContext.java index 64d890cf9..2fe767d8e 100644 --- a/src/launch/java/baritone/launch/mixins/MixinLootContext.java +++ b/src/launch/java/baritone/launch/mixins/MixinLootContext.java @@ -31,10 +31,10 @@ import org.spongepowered.asm.mixin.injection.Redirect; public class MixinLootContext { @Redirect( - method = "build", + method = "create", at = @At( value = "INVOKE", - target = "net/minecraft/world/server/ServerWorld.getServer()Lnet/minecraft/server/MinecraftServer;" + target = "net/minecraft/server/level/ServerLevel.getServer()Lnet/minecraft/server/MinecraftServer;" ) ) private MinecraftServer getServer(ServerLevel world) { @@ -45,7 +45,7 @@ public class MixinLootContext { } @Redirect( - method = "build", + method = "create", at = @At( value = "INVOKE", target = "net/minecraft/server/MinecraftServer.getLootTableManager()Lnet/minecraft/loot/LootTableManager;" @@ -59,7 +59,7 @@ public class MixinLootContext { } @Redirect( - method = "build", + method = "create", at = @At( value = "INVOKE", target = "net/minecraft/server/MinecraftServer.func_229736_aP_()Lnet/minecraft/loot/LootPredicateManager;" diff --git a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java index b1d2974ac..424082495 100644 --- a/src/launch/java/baritone/launch/mixins/MixinMinecraft.java +++ b/src/launch/java/baritone/launch/mixins/MixinMinecraft.java @@ -46,7 +46,7 @@ public class MixinMinecraft { @Shadow public LocalPlayer player; @Shadow - public ClientLevel world; + public ClientLevel level; @Inject( method = "", @@ -83,12 +83,12 @@ public class MixinMinecraft { } @Inject( - method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V", + method = "setLevel", at = @At("HEAD") ) private void preLoadWorld(ClientLevel world, CallbackInfo ci) { // If we're unloading the world but one doesn't exist, ignore it - if (this.world == null && world == null) { + if (this.level == null && world == null) { return; } @@ -103,7 +103,7 @@ public class MixinMinecraft { } @Inject( - method = "loadWorld(Lnet/minecraft/client/world/ClientWorld;)V", + method = "setLevel", at = @At("RETURN") ) private void postLoadWorld(ClientLevel world, CallbackInfo ci) { @@ -123,7 +123,7 @@ public class MixinMinecraft { at = @At( value = "FIELD", opcode = Opcodes.GETFIELD, - target = "net/minecraft/client/gui/screen/Screen.passEvents:Z" + target = "net/minecraft/client/gui/screens/Screen.passEvents:Z" ) ) private boolean passEvents(Screen screen) { diff --git a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java index 29cebebab..632bdb4d1 100644 --- a/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java +++ b/src/launch/java/baritone/launch/mixins/MixinNetworkManager.java @@ -47,35 +47,35 @@ public class MixinNetworkManager { @Shadow @Final - private PacketFlow direction; + private PacketFlow receiving; @Inject( - method = "dispatchPacket", + method = "sendPacket", at = @At("HEAD") ) private void preDispatchPacket(Packet inPacket, final GenericFutureListener> futureListeners, CallbackInfo ci) { - if (this.direction != PacketFlow.CLIENTBOUND) { + if (this.receiving != PacketFlow.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (Connection) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) { ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.PRE, inPacket)); } } } @Inject( - method = "dispatchPacket", + method = "sendPacket", at = @At("RETURN") ) private void postDispatchPacket(Packet inPacket, final GenericFutureListener> futureListeners, CallbackInfo ci) { - if (this.direction != PacketFlow.CLIENTBOUND) { + if (this.receiving != PacketFlow.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (Connection) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) { ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((Connection) (Object) this, EventState.POST, inPacket)); } } @@ -85,15 +85,15 @@ public class MixinNetworkManager { method = "channelRead0", at = @At( value = "INVOKE", - target = "net/minecraft/network/NetworkManager.processPacket(Lnet/minecraft/network/IPacket;Lnet/minecraft/network/INetHandler;)V" + target = "net/minecraft/network/Connection.genericsFtw(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketListener;)V" ) ) private void preProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (this.direction != PacketFlow.CLIENTBOUND) { + if (this.receiving != PacketFlow.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (Connection) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) { ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((Connection) (Object) this, EventState.PRE, packet)); } } @@ -104,11 +104,11 @@ public class MixinNetworkManager { at = @At("RETURN") ) private void postProcessPacket(ChannelHandlerContext context, Packet packet, CallbackInfo ci) { - if (!this.channel.isOpen() || this.direction != PacketFlow.CLIENTBOUND) { + if (!this.channel.isOpen() || this.receiving != PacketFlow.CLIENTBOUND) { return; } for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) { - if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (Connection) (Object) this) { + if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getConnection() == (Connection) (Object) this) { ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((Connection) (Object) this, EventState.POST, packet)); } } diff --git a/src/launch/java/baritone/launch/mixins/MixinPlayerController.java b/src/launch/java/baritone/launch/mixins/MixinPlayerController.java index 18fdd4aec..34f39aee9 100644 --- a/src/launch/java/baritone/launch/mixins/MixinPlayerController.java +++ b/src/launch/java/baritone/launch/mixins/MixinPlayerController.java @@ -27,15 +27,15 @@ import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(MultiPlayerGameMode.class) public abstract class MixinPlayerController implements IPlayerControllerMP { - @Accessor + @Accessor("isDestroying") @Override public abstract void setIsHittingBlock(boolean isHittingBlock); - @Accessor + @Accessor("destroyBlockPos") @Override public abstract BlockPos getCurrentBlock(); - @Invoker + @Invoker("ensureHasSentCarriedItem") @Override public abstract void callSyncCurrentPlayItem(); } diff --git a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java index 34dbc9174..622721281 100644 --- a/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java +++ b/src/launch/java/baritone/launch/mixins/MixinWorldRenderer.java @@ -40,7 +40,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture; public class MixinWorldRenderer { @Inject( - method = "updateCameraAndRender", + method = "renderLevel", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILSOFT ) diff --git a/src/main/java/baritone/Baritone.java b/src/main/java/baritone/Baritone.java index 2af9086e7..e5a9a453f 100755 --- a/src/main/java/baritone/Baritone.java +++ b/src/main/java/baritone/Baritone.java @@ -217,7 +217,7 @@ public class Baritone implements IBaritone { new Thread(() -> { try { Thread.sleep(100); - Helper.mc.execute(() -> Helper.mc.displayGuiScreen(new GuiClick())); + Helper.mc.execute(() -> Helper.mc.setScreen(new GuiClick())); } catch (Exception ignored) {} }).start(); } diff --git a/src/main/java/baritone/behavior/InventoryBehavior.java b/src/main/java/baritone/behavior/InventoryBehavior.java index 9dc47d12b..788753c32 100644 --- a/src/main/java/baritone/behavior/InventoryBehavior.java +++ b/src/main/java/baritone/behavior/InventoryBehavior.java @@ -23,7 +23,6 @@ import baritone.utils.ToolSet; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; -import net.minecraft.item.*; import net.minecraft.world.InteractionHand; import net.minecraft.world.inventory.ClickType; import net.minecraft.world.item.BlockItem; @@ -57,7 +56,7 @@ public final class InventoryBehavior extends Behavior { if (event.getType() == TickEvent.Type.OUT) { return; } - if (ctx.player().openContainer != ctx.player().container) { + if (ctx.player().containerMenu != ctx.player().inventoryMenu) { // we have a crafting table or a chest or something open return; } @@ -81,7 +80,7 @@ public final class InventoryBehavior extends Behavior { // we're using 0 and 8 for pickaxe and throwaway ArrayList candidates = new ArrayList<>(); for (int i = 1; i < 8; i++) { - if (ctx.player().inventory.mainInventory.get(i).isEmpty() && !disallowedHotbar.test(i)) { + if (ctx.player().getInventory().items.get(i).isEmpty() && !disallowedHotbar.test(i)) { candidates.add(i); } } @@ -99,11 +98,11 @@ public final class InventoryBehavior extends Behavior { } private void swapWithHotBar(int inInventory, int inHotbar) { - ctx.playerController().windowClick(ctx.player().container.windowId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ClickType.SWAP, ctx.player()); + ctx.playerController().windowClick(ctx.player().inventoryMenu.containerId, inInventory < 9 ? inInventory + 36 : inInventory, inHotbar, ClickType.SWAP, ctx.player()); } private int firstValidThrowaway() { // TODO offhand idk - NonNullList invy = ctx.player().inventory.mainInventory; + NonNullList invy = ctx.player().getInventory().items; for (int i = 0; i < invy.size(); i++) { if (Baritone.settings().acceptableThrowawayItems.value.contains(invy.get(i).getItem())) { return i; @@ -113,7 +112,7 @@ public final class InventoryBehavior extends Behavior { } private int bestToolAgainst(Block against, Class cla$$) { - NonNullList invy = ctx.player().inventory.mainInventory; + NonNullList invy = ctx.player().getInventory().items; int bestInd = -1; double bestSpeed = -1; for (int i = 0; i < invy.size(); i++) { @@ -143,7 +142,7 @@ public final class InventoryBehavior extends Behavior { public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) { BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z, baritone.bsi.get0(x, y, z)); - if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {}))))) { + if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}))))) { return true; // gotem } if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) { @@ -159,7 +158,7 @@ public final class InventoryBehavior extends Behavior { public boolean throwaway(boolean select, Predicate desired) { LocalPlayer p = ctx.player(); - NonNullList inv = p.inventory.items; + NonNullList inv = p.getInventory().items; for (int i = 0; i < 9; i++) { ItemStack item = inv.get(i); // this usage of settings() is okay because it's only called once during pathing @@ -169,12 +168,12 @@ public final class InventoryBehavior extends Behavior { // acceptableThrowawayItems to the CalculationContext if (desired.test(item)) { if (select) { - p.inventory.selected = i; + p.getInventory().selected = i; } return true; } } - if (desired.test(p.inventory.offhand.get(0))) { + if (desired.test(p.getInventory().offhand.get(0))) { // main hand takes precedence over off hand // that means that if we have block A selected in main hand and block B in off hand, right clicking places block B // we've already checked above ^ and the main hand can't possible have an acceptablethrowawayitem @@ -184,7 +183,7 @@ public final class InventoryBehavior extends Behavior { ItemStack item = inv.get(i); if (item.isEmpty() || item.getItem() instanceof PickaxeItem) { if (select) { - p.inventory.selected = i; + p.getInventory().selected = i; } return true; } diff --git a/src/main/java/baritone/behavior/LookBehavior.java b/src/main/java/baritone/behavior/LookBehavior.java index 801a5e43e..e9b0ca661 100644 --- a/src/main/java/baritone/behavior/LookBehavior.java +++ b/src/main/java/baritone/behavior/LookBehavior.java @@ -72,26 +72,26 @@ public final class LookBehavior extends Behavior implements ILookBehavior { switch (event.getState()) { case PRE: { if (this.force) { - ctx.player().rotationYaw = this.target.getYaw(); - float oldPitch = ctx.player().rotationPitch; + ctx.player().setYRot(this.target.getYaw()); + float oldPitch = ctx.player().getXRot(); float desiredPitch = this.target.getPitch(); - ctx.player().rotationPitch = desiredPitch; - ctx.player().rotationYaw += (Math.random() - 0.5) * Baritone.settings().randomLooking.value; - ctx.player().rotationPitch += (Math.random() - 0.5) * Baritone.settings().randomLooking.value; + ctx.player().setXRot(desiredPitch); + ctx.player().setYRot((float) (ctx.player().getYRot() + (Math.random() - 0.5) * Baritone.settings().randomLooking.value)); + ctx.player().setXRot((float) (ctx.player().getXRot() + (Math.random() - 0.5) * Baritone.settings().randomLooking.value)); if (desiredPitch == oldPitch && !Baritone.settings().freeLook.value) { nudgeToLevel(); } this.target = null; } if (silent) { - this.lastYaw = ctx.player().rotationYaw; - ctx.player().rotationYaw = this.target.getYaw(); + this.lastYaw = ctx.player().getYRot(); + ctx.player().setYRot(this.target.getYaw()); } break; } case POST: { if (silent) { - ctx.player().rotationYaw = this.lastYaw; + ctx.player().setYRot(this.lastYaw); this.target = null; } break; @@ -103,7 +103,7 @@ public final class LookBehavior extends Behavior implements ILookBehavior { public void pig() { if (this.target != null) { - ctx.player().rotationYaw = this.target.getYaw(); + ctx.player().setYRot(this.target.getYaw()); } } @@ -125,10 +125,10 @@ public final class LookBehavior extends Behavior implements ILookBehavior { * Nudges the player's pitch to a regular level. (Between {@code -20} and {@code 10}, increments are by {@code 1}) */ private void nudgeToLevel() { - if (ctx.player().rotationPitch < -20) { - ctx.player().rotationPitch++; - } else if (ctx.player().rotationPitch > 10) { - ctx.player().rotationPitch--; + if (ctx.player().getXRot() < -20) { + ctx.player().setXRot(ctx.player().getXRot() + 1); + } else if (ctx.player().getXRot() > 10) { + ctx.player().setXRot(ctx.player().getXRot() - 1); } } } diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 48b9cdbb3..387d4715e 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -60,7 +60,7 @@ public final class MemoryBehavior extends Behavior { public EnderChestMemory getCurrent() { Path path = baritone.getWorldProvider().getCurrentWorld().directory; - return EnderChestMemory.getByServerAndPlayer(path.getParent(), ctx.player().getUniqueID()); + return EnderChestMemory.getByServerAndPlayer(path.getParent(), ctx.player().getUUID()); } public static class EnderChestMemory { diff --git a/src/main/java/baritone/behavior/PathingBehavior.java b/src/main/java/baritone/behavior/PathingBehavior.java index 1c089df57..bebd28925 100644 --- a/src/main/java/baritone/behavior/PathingBehavior.java +++ b/src/main/java/baritone/behavior/PathingBehavior.java @@ -151,7 +151,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, queuePathEvent(PathEvent.AT_GOAL); next = null; if (Baritone.settings().disconnectOnArrival.value) { - ctx.world().sendQuittingDisconnectingPacket(); + ctx.world().disconnect(); } return; } @@ -232,11 +232,11 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, if (current != null) { switch (event.getState()) { case PRE: - lastAutoJump = mc.gameSettings.autoJump; - mc.gameSettings.autoJump = false; + lastAutoJump = mc.options.autoJump; + mc.options.autoJump = false; break; case POST: - mc.gameSettings.autoJump = lastAutoJump; + mc.options.autoJump = lastAutoJump; break; default: break; @@ -378,10 +378,10 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, */ public BetterBlockPos pathStart() { // TODO move to a helper or util class BetterBlockPos feet = ctx.playerFeet(); - if (!MovementHelper.canWalkOn(ctx, feet.down())) { + if (!MovementHelper.canWalkOn(ctx, feet.below())) { if (ctx.player().isOnGround()) { - double playerX = ctx.player().getPositionVec().x; - double playerZ = ctx.player().getPositionVec().z; + double playerX = ctx.player().position().x; + double playerZ = ctx.player().position().z; ArrayList closest = new ArrayList<>(); for (int dx = -1; dx <= 1; dx++) { for (int dz = -1; dz <= 1; dz++) { @@ -397,7 +397,7 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, // can't possibly be sneaking off of this one, we're too far away continue; } - if (MovementHelper.canWalkOn(ctx, possibleSupport.down()) && MovementHelper.canWalkThrough(ctx, possibleSupport) && MovementHelper.canWalkThrough(ctx, possibleSupport.up())) { + if (MovementHelper.canWalkOn(ctx, possibleSupport.below()) && MovementHelper.canWalkThrough(ctx, possibleSupport) && MovementHelper.canWalkThrough(ctx, possibleSupport.above())) { // this is plausible //logDebug("Faking path start assuming player is standing off the edge of a block"); return possibleSupport; @@ -407,9 +407,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior, } else { // !onGround // we're in the middle of a jump - if (MovementHelper.canWalkOn(ctx, feet.down().down())) { + if (MovementHelper.canWalkOn(ctx, feet.below().below())) { //logDebug("Faking path start assuming player is midair and falling"); - return feet.down(); + return feet.below(); } } } diff --git a/src/main/java/baritone/cache/CachedChunk.java b/src/main/java/baritone/cache/CachedChunk.java index 2e9aba140..56485fd72 100644 --- a/src/main/java/baritone/cache/CachedChunk.java +++ b/src/main/java/baritone/cache/CachedChunk.java @@ -196,7 +196,7 @@ public final class CachedChunk { if (special != null) { String str = special.get(index); if (str != null) { - return BlockUtils.stringToBlockRequired(str).getDefaultState(); + return BlockUtils.stringToBlockRequired(str).defaultBlockState(); } } diff --git a/src/main/java/baritone/cache/CachedRegion.java b/src/main/java/baritone/cache/CachedRegion.java index 4e8597fbc..7581e2bdc 100644 --- a/src/main/java/baritone/cache/CachedRegion.java +++ b/src/main/java/baritone/cache/CachedRegion.java @@ -242,7 +242,7 @@ public final class CachedRegion implements ICachedRegion { for (int z = 0; z < 32; z++) { if (present[x][z]) { for (int i = 0; i < 256; i++) { - overview[x][z][i] = BlockUtils.stringToBlockRequired(in.readUTF()).getDefaultState(); + overview[x][z][i] = BlockUtils.stringToBlockRequired(in.readUTF()).defaultBlockState(); } } } diff --git a/src/main/java/baritone/cache/ChunkPacker.java b/src/main/java/baritone/cache/ChunkPacker.java index 12507ffcb..f85fc3cce 100644 --- a/src/main/java/baritone/cache/ChunkPacker.java +++ b/src/main/java/baritone/cache/ChunkPacker.java @@ -20,7 +20,6 @@ package baritone.cache; import baritone.api.utils.BlockUtils; import baritone.pathing.movement.MovementHelper; import baritone.utils.pathing.PathingBlockType; -import net.minecraft.block.*; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.Level; diff --git a/src/main/java/baritone/cache/ContainerMemory.java b/src/main/java/baritone/cache/ContainerMemory.java index 0fa1b8f2f..cd9d2f587 100644 --- a/src/main/java/baritone/cache/ContainerMemory.java +++ b/src/main/java/baritone/cache/ContainerMemory.java @@ -176,7 +176,7 @@ public class ContainerMemory implements IContainerMemory { public void updateFromOpenWindow(IPlayerContext ctx) { items.clear(); - items.addAll(ctx.player().openContainer.getInventory().subList(0, size)); + items.addAll(ctx.player().containerMenu.getItems().subList(0, size)); } } } diff --git a/src/main/java/baritone/cache/WorldProvider.java b/src/main/java/baritone/cache/WorldProvider.java index 221ca4a51..7f992e6dc 100644 --- a/src/main/java/baritone/cache/WorldProvider.java +++ b/src/main/java/baritone/cache/WorldProvider.java @@ -60,14 +60,14 @@ public class WorldProvider implements IWorldProvider, Helper { File directory; File readme; - IntegratedServer integratedServer = mc.getIntegratedServer(); + IntegratedServer integratedServer = mc.getSingleplayerServer(); // If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file - if (mc.isSingleplayer()) { + if (mc.hasSingleplayerServer()) { directory = DimensionType.getStorageFolder(world, integratedServer.getWorldPath(LevelResource.ROOT).toFile()); // Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world - if (directory.toPath().relativize(mc.gameDir.toPath()).getNameCount() != 2) { + if (directory.toPath().relativize(mc.gameDirectory.toPath()).getNameCount() != 2) { // subdirectory of the main save directory for this world directory = directory.getParentFile(); } @@ -75,7 +75,7 @@ public class WorldProvider implements IWorldProvider, Helper { directory = new File(directory, "baritone"); readme = directory; } else { // Otherwise, the server must be remote... - String folderName = mc.isConnectedToRealms() ? "realms" : mc.getCurrentServerData().serverIP; + String folderName = mc.isConnectedToRealms() ? "realms" : mc.getCurrentServer().ip; if (SystemUtils.IS_OS_WINDOWS) { folderName = folderName.replace(":", "_"); } diff --git a/src/main/java/baritone/cache/WorldScanner.java b/src/main/java/baritone/cache/WorldScanner.java index 3459f086d..b4ec4afc8 100644 --- a/src/main/java/baritone/cache/WorldScanner.java +++ b/src/main/java/baritone/cache/WorldScanner.java @@ -46,7 +46,7 @@ public enum WorldScanner implements IWorldScanner { if (filter.blocks().isEmpty()) { return res; } - ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkProvider(); + ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkSource(); int maxSearchRadiusSq = maxSearchRadius * maxSearchRadius; int playerChunkX = ctx.playerFeet().getX() >> 4; @@ -96,7 +96,7 @@ public enum WorldScanner implements IWorldScanner { return Collections.emptyList(); } - ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkProvider(); + ClientChunkCache chunkProvider = (ClientChunkCache) ctx.world().getChunkSource(); LevelChunk chunk = chunkProvider.getChunk(pos.x, pos.z, null, false); int playerY = ctx.playerFeet().getY(); @@ -116,7 +116,7 @@ public enum WorldScanner implements IWorldScanner { @Override public int repack(IPlayerContext ctx, int range) { - ChunkSource chunkProvider = ctx.world().getChunkProvider(); + ChunkSource chunkProvider = ctx.world().getChunkSource(); ICachedWorld cachedWorld = ctx.worldData().getCachedWorld(); BetterBlockPos playerPos = ctx.playerFeet(); diff --git a/src/main/java/baritone/command/ExampleBaritoneControl.java b/src/main/java/baritone/command/ExampleBaritoneControl.java index 81ea02e50..eac4ccf24 100644 --- a/src/main/java/baritone/command/ExampleBaritoneControl.java +++ b/src/main/java/baritone/command/ExampleBaritoneControl.java @@ -99,7 +99,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener return false; } else if (msg.trim().equalsIgnoreCase("orderpizza")) { try { - ((IGuiScreen) mc.currentScreen).openLinkInvoker(new URI("https://www.dominos.com/en/pages/order/")); + ((IGuiScreen) mc.screen).openLinkInvoker(new URI("https://www.dominos.com/en/pages/order/")); } catch (NullPointerException | URISyntaxException ignored) {} return false; } diff --git a/src/main/java/baritone/command/defaults/BuildCommand.java b/src/main/java/baritone/command/defaults/BuildCommand.java index 75c1673d4..622aef4f8 100644 --- a/src/main/java/baritone/command/defaults/BuildCommand.java +++ b/src/main/java/baritone/command/defaults/BuildCommand.java @@ -35,7 +35,7 @@ import java.util.stream.Stream; public class BuildCommand extends Command { - private static final File schematicsDir = new File(mc.gameDir, "schematics"); + private static final File schematicsDir = new File(mc.gameDirectory, "schematics"); public BuildCommand(IBaritone baritone) { super(baritone, "build"); diff --git a/src/main/java/baritone/command/defaults/ComeCommand.java b/src/main/java/baritone/command/defaults/ComeCommand.java index eb06e4ff0..5cbed55bc 100644 --- a/src/main/java/baritone/command/defaults/ComeCommand.java +++ b/src/main/java/baritone/command/defaults/ComeCommand.java @@ -37,7 +37,7 @@ public class ComeCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(0); - Entity entity = mc.getRenderViewEntity(); + Entity entity = mc.getCameraEntity(); if (entity == null) { throw new CommandInvalidStateException("render view entity is null"); } diff --git a/src/main/java/baritone/command/defaults/ExploreFilterCommand.java b/src/main/java/baritone/command/defaults/ExploreFilterCommand.java index c2057551f..504f7c146 100644 --- a/src/main/java/baritone/command/defaults/ExploreFilterCommand.java +++ b/src/main/java/baritone/command/defaults/ExploreFilterCommand.java @@ -41,7 +41,7 @@ public class ExploreFilterCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(2); - File file = args.getDatatypePost(RelativeFile.INSTANCE, mc.gameDir.getAbsoluteFile().getParentFile()); + File file = args.getDatatypePost(RelativeFile.INSTANCE, mc.gameDirectory.getAbsoluteFile().getParentFile()); boolean invert = false; if (args.hasAny()) { if (args.getString().equalsIgnoreCase("invert")) { diff --git a/src/main/java/baritone/command/defaults/HelpCommand.java b/src/main/java/baritone/command/defaults/HelpCommand.java index b1c9783d5..f111b4476 100644 --- a/src/main/java/baritone/command/defaults/HelpCommand.java +++ b/src/main/java/baritone/command/defaults/HelpCommand.java @@ -29,8 +29,11 @@ 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.HoverEvent; import net.minecraft.network.chat.TextComponent; import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX; @@ -55,22 +58,22 @@ public class HelpCommand extends Command { command -> { String names = String.join("/", command.getNames()); String name = command.getNames().get(0); - TextComponent shortDescComponent = new StringTextComponent(" - " + command.getShortDesc()); - shortDescComponent.setStyle(shortDescComponent.getStyle().setFormatting(TextFormatting.DARK_GRAY)); - TextComponent namesComponent = new StringTextComponent(names); - namesComponent.setStyle(namesComponent.getStyle().setFormatting(TextFormatting.WHITE)); - TextComponent hoverComponent = new StringTextComponent(""); - hoverComponent.setStyle(hoverComponent.getStyle().setFormatting(TextFormatting.GRAY)); + TextComponent shortDescComponent = new TextComponent(" - " + command.getShortDesc()); + shortDescComponent.setStyle(shortDescComponent.getStyle().withColor(ChatFormatting.DARK_GRAY)); + TextComponent namesComponent = new TextComponent(names); + namesComponent.setStyle(namesComponent.getStyle().withColor(ChatFormatting.WHITE)); + TextComponent hoverComponent = new TextComponent(""); + hoverComponent.setStyle(hoverComponent.getStyle().withColor(ChatFormatting.GRAY)); hoverComponent.append(namesComponent); - hoverComponent.appendString("\n" + command.getShortDesc()); - hoverComponent.appendString("\n\nClick to view full help"); + 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 StringTextComponent(name); - component.setStyle(component.getStyle().setFormatting(TextFormatting.GRAY)); + TextComponent component = new TextComponent(name); + component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY)); component.append(shortDescComponent); component.setStyle(component.getStyle() - .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)) - .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand))); + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)) + .withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand))); return component; }, FORCE_COMMAND_PREFIX + label diff --git a/src/main/java/baritone/command/defaults/RenderCommand.java b/src/main/java/baritone/command/defaults/RenderCommand.java index a77add6e6..2bbfa87cd 100644 --- a/src/main/java/baritone/command/defaults/RenderCommand.java +++ b/src/main/java/baritone/command/defaults/RenderCommand.java @@ -37,8 +37,8 @@ public class RenderCommand extends Command { public void execute(String label, IArgConsumer args) throws CommandException { args.requireMax(0); BetterBlockPos origin = ctx.playerFeet(); - int renderDistance = (mc.gameSettings.renderDistanceChunks + 1) * 16; - mc.worldRenderer.markBlockRangeForRenderUpdate( + int renderDistance = (mc.options.renderDistance + 1) * 16; + mc.levelRenderer.setBlocksDirty( origin.x - renderDistance, 0, origin.z - renderDistance, diff --git a/src/main/java/baritone/command/defaults/SelCommand.java b/src/main/java/baritone/command/defaults/SelCommand.java index e2f94ccf4..635e0a240 100644 --- a/src/main/java/baritone/command/defaults/SelCommand.java +++ b/src/main/java/baritone/command/defaults/SelCommand.java @@ -39,6 +39,7 @@ import baritone.api.utils.BlockOptionalMetaLookup; import baritone.utils.IRenderer; import java.awt.*; import java.util.*; +import java.util.List; import java.util.function.Function; import java.util.stream.Stream; import net.minecraft.core.Direction; @@ -64,7 +65,7 @@ public class SelCommand extends Command { float lineWidth = Baritone.settings().selectionLineWidth.value; boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value; IRenderer.startLines(color, opacity, lineWidth, ignoreDepth); - IRenderer.drawAABB(event.getModelViewStack(), new AABB(pos1, pos1.add(1, 1, 1))); + IRenderer.drawAABB(event.getModelViewStack(), new AABB(pos1, pos1.offset(1, 1, 1))); IRenderer.endLines(ignoreDepth); } }); @@ -80,7 +81,7 @@ public class SelCommand extends Command { if (action == Action.POS2 && pos1 == null) { throw new CommandInvalidStateException("Set pos1 first before using pos2"); } - BetterBlockPos playerPos = mc.getRenderViewEntity() != null ? BetterBlockPos.from(mc.getRenderViewEntity().getPosition()) : ctx.playerFeet(); + BetterBlockPos playerPos = mc.getCameraEntity() != null ? BetterBlockPos.from(mc.getCameraEntity().blockPosition()) : ctx.playerFeet(); BetterBlockPos pos = args.hasAny() ? args.getDatatypePost(RelativeBlockPos.INSTANCE, playerPos) : playerPos; args.requireMax(0); if (action == Action.POS1) { diff --git a/src/main/java/baritone/command/defaults/SetCommand.java b/src/main/java/baritone/command/defaults/SetCommand.java index b9ddc7a79..0c3597e20 100644 --- a/src/main/java/baritone/command/defaults/SetCommand.java +++ b/src/main/java/baritone/command/defaults/SetCommand.java @@ -77,23 +77,23 @@ public class SetCommand extends Command { : String.format("All %ssettings:", viewModified ? "modified " : "") ), setting -> { - TextComponent typeComponent = new StringTextComponent(String.format( + TextComponent typeComponent = new TextComponent(String.format( " (%s)", settingTypeToString(setting) )); - typeComponent.setStyle(typeComponent.getStyle().setFormatting(TextFormatting.DARK_GRAY)); - TextComponent hoverComponent = new StringTextComponent(""); - hoverComponent.setStyle(hoverComponent.getStyle().setFormatting(TextFormatting.GRAY)); - hoverComponent.appendString(setting.getName()); - hoverComponent.appendString(String.format("\nType: %s", settingTypeToString(setting))); - hoverComponent.appendString(String.format("\n\nValue:\n%s", settingValueToString(setting))); + typeComponent.setStyle(typeComponent.getStyle().withColor(ChatFormatting.DARK_GRAY)); + TextComponent hoverComponent = new TextComponent(""); + hoverComponent.setStyle(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))); String commandSuggestion = Baritone.settings().prefix.value + String.format("set %s ", setting.getName()); - TextComponent component = new StringTextComponent(setting.getName()); - component.setStyle(component.getStyle().setFormatting(TextFormatting.GRAY)); + TextComponent component = new TextComponent(setting.getName()); + component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY)); component.append(typeComponent); component.setStyle(component.getStyle() - .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)) - .setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion))); + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)) + .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion))); return component; }, FORCE_COMMAND_PREFIX + "set " + arg + " " + search diff --git a/src/main/java/baritone/command/defaults/SurfaceCommand.java b/src/main/java/baritone/command/defaults/SurfaceCommand.java index 9eeacc742..3bbd4d738 100644 --- a/src/main/java/baritone/command/defaults/SurfaceCommand.java +++ b/src/main/java/baritone/command/defaults/SurfaceCommand.java @@ -43,7 +43,7 @@ public class SurfaceCommand extends Command { // Ensure this command will not run if you are above the surface level and the block above you is air // As this would imply that your are already on the open surface - if (playerPos.getY() > surfaceLevel && mc.world.getBlockState(playerPos.up()).getBlock() instanceof AirBlock) { + if (playerPos.getY() > surfaceLevel && mc.level.getBlockState(playerPos.above()).getBlock() instanceof AirBlock) { logDirect("Already at surface"); return; } @@ -53,8 +53,8 @@ public class SurfaceCommand extends Command { for (int currentIteratedY = startingYPos; currentIteratedY < worldHeight; currentIteratedY++) { final BetterBlockPos newPos = new BetterBlockPos(playerPos.getX(), currentIteratedY, playerPos.getZ()); - if (!(mc.world.getBlockState(newPos).getBlock() instanceof AirBlock) && newPos.getY() > playerPos.getY()) { - Goal goal = new GoalBlock(newPos.up()); + if (!(mc.level.getBlockState(newPos).getBlock() instanceof AirBlock) && newPos.getY() > playerPos.getY()) { + Goal goal = new GoalBlock(newPos.above()); logDirect(String.format("Going to: %s", goal.toString())); baritone.getCustomGoalProcess().setGoalAndPath(goal); return; diff --git a/src/main/java/baritone/command/defaults/ThisWayCommand.java b/src/main/java/baritone/command/defaults/ThisWayCommand.java index 0c10bba30..d6c59f078 100644 --- a/src/main/java/baritone/command/defaults/ThisWayCommand.java +++ b/src/main/java/baritone/command/defaults/ThisWayCommand.java @@ -38,7 +38,7 @@ public class ThisWayCommand extends Command { args.requireExactly(1); GoalXZ goal = GoalXZ.fromDirection( ctx.playerFeetAsVec(), - ctx.player().rotationYawHead, + ctx.player().getYHeadRot(), args.getAs(Double.class) ); baritone.getCustomGoalProcess().setGoal(goal); diff --git a/src/main/java/baritone/command/defaults/TunnelCommand.java b/src/main/java/baritone/command/defaults/TunnelCommand.java index f958c9d20..dec304a03 100644 --- a/src/main/java/baritone/command/defaults/TunnelCommand.java +++ b/src/main/java/baritone/command/defaults/TunnelCommand.java @@ -54,7 +54,7 @@ public class TunnelCommand extends Command { width--; BlockPos corner1; BlockPos corner2; - Direction enumFacing = ctx.player().getHorizontalFacing(); + Direction enumFacing = ctx.player().getDirection(); int addition = ((width % 2 == 0) ? 0 : 1); switch (enumFacing) { case EAST: @@ -82,7 +82,7 @@ public class TunnelCommand extends Command { } else { Goal goal = new GoalStrictDirection( ctx.playerFeet(), - ctx.player().getHorizontalFacing() + ctx.player().getDirection() ); baritone.getCustomGoalProcess().setGoalAndPath(goal); logDirect(String.format("Goal: %s", goal.toString())); diff --git a/src/main/java/baritone/event/GameEventHandler.java b/src/main/java/baritone/event/GameEventHandler.java index 0f36fb444..5056b6a0b 100644 --- a/src/main/java/baritone/event/GameEventHandler.java +++ b/src/main/java/baritone/event/GameEventHandler.java @@ -114,7 +114,7 @@ public final class GameEventHandler implements IEventBus, Helper { if (event.getState() == EventState.POST) { cache.closeWorld(); if (event.getWorld() != null) { - cache.initWorld(event.getWorld().getDimensionKey()); + cache.initWorld(event.getWorld().dimension()); } } diff --git a/src/main/java/baritone/pathing/movement/CalculationContext.java b/src/main/java/baritone/pathing/movement/CalculationContext.java index 9792238ce..e8b7ab142 100644 --- a/src/main/java/baritone/pathing/movement/CalculationContext.java +++ b/src/main/java/baritone/pathing/movement/CalculationContext.java @@ -85,7 +85,7 @@ public class CalculationContext { this.bsi = new BlockStateInterface(world, worldData, forUseOnAnotherThread); this.toolSet = new ToolSet(player); this.hasThrowaway = Baritone.settings().allowPlace.value && ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway(); - this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && Inventory.isHotbarSlot(player.inventory.findSlotMatchingItem(STACK_BUCKET_WATER)) && world.dimension() != Level.NETHER; + this.hasWaterBucket = Baritone.settings().allowWaterBucketFall.value && Inventory.isHotbarSlot(player.getInventory().findSlotMatchingItem(STACK_BUCKET_WATER)) && world.dimension() != Level.NETHER; this.canSprint = Baritone.settings().allowSprint.value && player.getFoodData().getFoodLevel() > 6; this.placeBlockCost = Baritone.settings().blockPlacementPenalty.value; this.allowBreak = Baritone.settings().allowBreak.value; diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index 312bb0f28..ac502b269 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -17,8 +17,6 @@ package baritone.pathing.movement; -import BetterBlockPos; -import IPlayerContext; import baritone.Baritone; import baritone.api.IBaritone; import baritone.api.pathing.movement.IMovement; @@ -123,12 +121,12 @@ public abstract class Movement implements IMovement, MovementHelper { */ @Override public MovementStatus update() { - ctx.player().abilities.isFlying = false; + ctx.player().getAbilities().flying = false; currentState = updateState(currentState); if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) { currentState.setInput(Input.JUMP, true); } - if (ctx.player().isEntityInsideOpaqueBlock()) { + if (ctx.player().isInWall()) { ctx.getSelectedBlock().ifPresent(pos -> MovementHelper.switchToBestToolFor(ctx, BlockStateInterface.get(ctx, pos))); currentState.setInput(Input.CLICK_LEFT, true); } @@ -158,7 +156,7 @@ public abstract class Movement implements IMovement, MovementHelper { } boolean somethingInTheWay = false; for (BetterBlockPos blockPos : positionsToBreak) { - if (!ctx.world().getEntitiesWithinAABB(FallingBlockEntity.class, new AABB(0, 0, 0, 1, 1.1, 1).move(blockPos)).isEmpty() && Baritone.settings().pauseMiningForFallingBlocks.value) { + if (!ctx.world().getEntities(null, new AABB(0, 0, 0, 1, 1.1, 1).move(blockPos)).isEmpty() && Baritone.settings().pauseMiningForFallingBlocks.value) { return false; } if (!MovementHelper.canWalkThrough(ctx, blockPos)) { // can't break air, so don't try diff --git a/src/main/java/baritone/pathing/movement/MovementHelper.java b/src/main/java/baritone/pathing/movement/MovementHelper.java index f27c4d62b..b2b3d05b0 100644 --- a/src/main/java/baritone/pathing/movement/MovementHelper.java +++ b/src/main/java/baritone/pathing/movement/MovementHelper.java @@ -27,10 +27,8 @@ import baritone.api.utils.input.Input; import baritone.pathing.movement.MovementState.MovementTarget; import baritone.utils.BlockStateInterface; import baritone.utils.ToolSet; -import net.minecraft.block.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.fluid.*; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.AbstractSkullBlock; import net.minecraft.world.level.block.AirBlock; @@ -334,7 +332,7 @@ public interface MovementHelper extends ActionCosts, Helper { if (block == Blocks.LADDER || (block == Blocks.VINE && Baritone.settings().allowVines.value)) { // TODO reconsider this return true; } - if (block == Blocks.FARMLAND || block == Blocks.GRASS_PATH) { + if (block == Blocks.FARMLAND || block == Blocks.DIRT_PATH) { return true; } if (block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST) { @@ -465,7 +463,7 @@ public interface MovementHelper extends ActionCosts, Helper { */ static void switchToBestToolFor(IPlayerContext ctx, BlockState b, ToolSet ts, boolean preferSilkTouch) { if (!Baritone.settings().disableAutoTool.value && !Baritone.settings().assumeExternalAutoTool.value) { - ctx.player().inventory.currentItem = ts.getBestSlot(b.getBlock(), preferSilkTouch); + ctx.player().getInventory().selected = ts.getBestSlot(b.getBlock(), preferSilkTouch); } } @@ -473,7 +471,7 @@ public interface MovementHelper extends ActionCosts, Helper { state.setTarget(new MovementTarget( new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(pos), - ctx.playerRotations()).getYaw(), ctx.player().rotationPitch), + ctx.playerRotations()).getYaw(), ctx.player().getXRot()), false )).setInput(Input.MOVE_FORWARD, true); } diff --git a/src/main/java/baritone/pathing/movement/Moves.java b/src/main/java/baritone/pathing/movement/Moves.java index a76bf81fd..87b5db6ac 100644 --- a/src/main/java/baritone/pathing/movement/Moves.java +++ b/src/main/java/baritone/pathing/movement/Moves.java @@ -31,7 +31,7 @@ public enum Moves { DOWNWARD(0, -1, 0) { @Override public Movement apply0(CalculationContext context, BetterBlockPos src) { - return new MovementDownward(context.getBaritone(), src, src.down()); + return new MovementDownward(context.getBaritone(), src, src.below()); } @Override @@ -43,7 +43,7 @@ public enum Moves { PILLAR(0, +1, 0) { @Override public Movement apply0(CalculationContext context, BetterBlockPos src) { - return new MovementPillar(context.getBaritone(), src, src.up()); + return new MovementPillar(context.getBaritone(), src, src.above()); } @Override diff --git a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java index a735f0f7a..fa70b6ddd 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementAscend.java @@ -39,7 +39,7 @@ public class MovementAscend extends Movement { private int ticksWithoutPlacement = 0; public MovementAscend(IBaritone baritone, BetterBlockPos src, BetterBlockPos dest) { - super(baritone, src, dest, new BetterBlockPos[]{dest, src.up(2), dest.up()}, dest.down()); + super(baritone, src, dest, new BetterBlockPos[]{dest, src.above(2), dest.above()}, dest.below()); } @Override @@ -55,12 +55,12 @@ public class MovementAscend extends Movement { @Override protected Set calculateValidPositions() { - BetterBlockPos prior = new BetterBlockPos(src.subtract(getDirection()).up()); // sometimes we back up to place the block, also sprint ascends, also skip descend to straight ascend + BetterBlockPos prior = new BetterBlockPos(src.subtract(getDirection()).above()); // sometimes we back up to place the block, also sprint ascends, also skip descend to straight ascend return ImmutableSet.of(src, - src.up(), + src.above(), dest, prior, - prior.up() + prior.above() ); } @@ -167,14 +167,14 @@ public class MovementAscend extends Movement { return state; } - if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.add(getDirection().below()))) { + if (ctx.playerFeet().equals(dest) || ctx.playerFeet().equals(dest.offset(getDirection().below()))) { return state.setStatus(MovementStatus.SUCCESS); } BlockState jumpingOnto = BlockStateInterface.get(ctx, positionToPlace); if (!MovementHelper.canWalkOn(ctx, positionToPlace, jumpingOnto)) { ticksWithoutPlacement++; - if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true) == PlaceResult.READY_TO_PLACE) { + if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), false, true) == PlaceResult.READY_TO_PLACE) { state.setInput(Input.SNEAK, true); if (ctx.player().isCrouching()) { state.setInput(Input.CLICK_RIGHT, true); @@ -188,21 +188,21 @@ public class MovementAscend extends Movement { return state; } MovementHelper.moveTowards(ctx, state, dest); - if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.down()))) { + if (MovementHelper.isBottomSlab(jumpingOnto) && !MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.below()))) { return state; // don't jump while walking from a non double slab into a bottom slab } - if (Baritone.settings().assumeStep.value || ctx.playerFeet().equals(src.up())) { + if (Baritone.settings().assumeStep.value || ctx.playerFeet().equals(src.above())) { // no need to hit space if we're already jumping return state; } int xAxis = Math.abs(src.getX() - dest.getX()); // either 0 or 1 int zAxis = Math.abs(src.getZ() - dest.getZ()); // either 0 or 1 - double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().getPositionVec().x) + zAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().getPositionVec().z); - double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().getPositionVec().x) + xAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().getPositionVec().z); + double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().position().x) + zAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().position().z); + double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().position().x) + xAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().position().z); - double lateralMotion = xAxis * ctx.player().getMotion().z + zAxis * ctx.player().getMotion().x; + double lateralMotion = xAxis * ctx.player().getDeltaMovement().z + zAxis * ctx.player().getDeltaMovement().x; if (Math.abs(lateralMotion) > 0.1) { return state; } @@ -222,9 +222,9 @@ public class MovementAscend extends Movement { } public boolean headBonkClear() { - BetterBlockPos startUp = src.up(2); + BetterBlockPos startUp = src.above(2); for (int i = 0; i < 4; i++) { - BetterBlockPos check = startUp.offset(Direction.from2DDataValue(i)); + BetterBlockPos check = startUp.relative(Direction.from2DDataValue(i)); if (!MovementHelper.canWalkThrough(ctx, check)) { // We might bonk our head return false; diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java index a4639cdab..7024e28b9 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDescend.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDescend.java @@ -44,7 +44,7 @@ public class MovementDescend extends Movement { private int numTicks = 0; public MovementDescend(IBaritone baritone, BetterBlockPos start, BetterBlockPos end) { - super(baritone, start, end, new BetterBlockPos[]{end.up(2), end.up(), end}, end.down()); + super(baritone, start, end, new BetterBlockPos[]{end.above(2), end.above(), end}, end.below()); } @Override @@ -65,7 +65,7 @@ public class MovementDescend extends Movement { @Override protected Set calculateValidPositions() { - return ImmutableSet.of(src, dest.up(), dest); + return ImmutableSet.of(src, dest.above(), dest); } public static void cost(CalculationContext context, int x, int y, int z, int destX, int destZ, MutableMoveResult res) { @@ -211,11 +211,11 @@ public class MovementDescend extends Movement { BlockPos playerFeet = ctx.playerFeet(); BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ()); - if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().getPositionVec().y - dest.getY() < 0.5)) { // lilypads + if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().position().y - dest.getY() < 0.5)) { // lilypads // Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately return state.setStatus(MovementStatus.SUCCESS); /* else { - // System.out.println(player().getPositionVec().y + " " + playerFeet.getY() + " " + (player().getPositionVec().y - playerFeet.getY())); + // System.out.println(player().position().y + " " + playerFeet.getY() + " " + (player().position().y - playerFeet.getY())); }*/ } if (safeMode()) { @@ -225,16 +225,16 @@ public class MovementDescend extends Movement { state.setTarget(new MovementState.MovementTarget( new Rotation(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3(destX, dest.getY(), destZ), - new Rotation(player.yRot, player.xRot)).getYaw(), player.xRot), + new Rotation(player.getYRot(), player.getXRot())).getYaw(), player.getXRot()), false )).setInput(Input.MOVE_FORWARD, true); return state; } - double diffX = ctx.player().getPositionVec().x - (dest.getX() + 0.5); - double diffZ = ctx.player().getPositionVec().z - (dest.getZ() + 0.5); + double diffX = ctx.player().position().x - (dest.getX() + 0.5); + double diffZ = ctx.player().position().z - (dest.getZ() + 0.5); double ab = Math.sqrt(diffX * diffX + diffZ * diffZ); - double x = ctx.player().getPositionVec().x - (src.getX() + 0.5); - double z = ctx.player().getPositionVec().z - (src.getZ() + 0.5); + double x = ctx.player().position().x - (src.getX() + 0.5); + double z = ctx.player().position().z - (src.getZ() + 0.5); double fromStart = Math.sqrt(x * x + z * z); if (!playerFeet.equals(dest) || ab > 0.25) { if (numTicks++ < 20 && fromStart < 1.25) { @@ -249,7 +249,7 @@ public class MovementDescend extends Movement { public boolean safeMode() { // (dest - src) + dest is offset 1 more in the same direction // so it's the block we'd need to worry about running into if we decide to sprint straight through this descend - BlockPos into = dest.subtract(src.down()).add(dest); + BlockPos into = dest.subtract(src.below()).offset(dest); if (skipToAscend()) { // if dest extends into can't walk through, but the two above are can walk through, then we can overshoot and glitch in that weird way return true; @@ -263,7 +263,7 @@ public class MovementDescend extends Movement { } public boolean skipToAscend() { - BlockPos into = dest.subtract(src.down()).add(dest); - return !MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into)) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up()) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).up(2)); + BlockPos into = dest.subtract(src.below()).offset(dest); + return !MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into)) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).above()) && MovementHelper.canWalkThrough(ctx, new BetterBlockPos(into).above(2)); } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java index f5947c639..fc3fa2f45 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDiagonal.java @@ -44,16 +44,16 @@ public class MovementDiagonal extends Movement { private static final double SQRT_2 = Math.sqrt(2); public MovementDiagonal(IBaritone baritone, BetterBlockPos start, Direction dir1, Direction dir2, int dy) { - this(baritone, start, start.offset(dir1), start.offset(dir2), dir2, dy); + this(baritone, start, start.relative(dir1), start.relative(dir2), dir2, dy); // super(start, start.offset(dir1).offset(dir2), new BlockPos[]{start.offset(dir1), start.offset(dir1).up(), start.offset(dir2), start.offset(dir2).up(), start.offset(dir1).offset(dir2), start.offset(dir1).offset(dir2).up()}, new BlockPos[]{start.offset(dir1).offset(dir2).down()}); } private MovementDiagonal(IBaritone baritone, BetterBlockPos start, BetterBlockPos dir1, BetterBlockPos dir2, Direction drr2, int dy) { - this(baritone, start, dir1.offset(drr2).up(dy), dir1, dir2); + this(baritone, start, dir1.relative(drr2).above(dy), dir1, dir2); } private MovementDiagonal(IBaritone baritone, BetterBlockPos start, BetterBlockPos end, BetterBlockPos dir1, BetterBlockPos dir2) { - super(baritone, start, end, new BetterBlockPos[]{dir1, dir1.up(), dir2, dir2.up(), end, end.up()}); + super(baritone, start, end, new BetterBlockPos[]{dir1, dir1.above(), dir2, dir2.above(), end, end.above()}); } @Override @@ -100,10 +100,10 @@ public class MovementDiagonal extends Movement { BetterBlockPos diagA = new BetterBlockPos(src.x, src.y, dest.z); BetterBlockPos diagB = new BetterBlockPos(dest.x, src.y, src.z); if (dest.y < src.y) { - return ImmutableSet.of(src, dest.up(), diagA, diagB, dest, diagA.down(), diagB.down()); + return ImmutableSet.of(src, dest.above(), diagA, diagB, dest, diagA.below(), diagB.below()); } if (dest.y > src.y) { - return ImmutableSet.of(src, src.up(), diagA, diagB, dest, diagA.up(), diagB.up()); + return ImmutableSet.of(src, src.above(), diagA, diagB, dest, diagA.above(), diagB.above()); } return ImmutableSet.of(src, dest, diagA, diagB); } @@ -252,10 +252,10 @@ public class MovementDiagonal extends Movement { if (ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); - } else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) { + } else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().above()))) { return state.setStatus(MovementStatus.UNREACHABLE); } - if (dest.y > src.y && ctx.player().getPositionVec().y < src.y + 0.1 && ctx.player().collidedHorizontally) { + if (dest.y > src.y && ctx.player().position().y < src.y + 0.1 && ctx.player().horizontalCollision) { state.setInput(Input.JUMP, true); } if (sprint()) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java index 7e32cd4f2..474886c5f 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementDownward.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementDownward.java @@ -83,8 +83,8 @@ public class MovementDownward extends Movement { } else if (!playerInValidPosition()) { return state.setStatus(MovementStatus.UNREACHABLE); } - double diffX = ctx.player().getPositionVec().x - (dest.getX() + 0.5); - double diffZ = ctx.player().getPositionVec().z - (dest.getZ() + 0.5); + double diffX = ctx.player().position().x - (dest.getX() + 0.5); + double diffZ = ctx.player().position().z - (dest.getZ() + 0.5); double ab = Math.sqrt(diffX * diffX + diffZ * diffZ); if (numTicks++ < 10 && ab < 0.2) { diff --git a/src/main/java/baritone/pathing/movement/movements/MovementFall.java b/src/main/java/baritone/pathing/movement/movements/MovementFall.java index ed230dc6c..669f0a7dd 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementFall.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementFall.java @@ -71,7 +71,7 @@ public class MovementFall extends Movement { Set set = new HashSet<>(); set.add(src); for (int y = src.y - dest.y; y >= 0; y--) { - set.add(dest.up(y)); + set.add(dest.above(y)); } return set; } @@ -96,16 +96,16 @@ public class MovementFall extends Movement { Block destBlock = destState.getBlock(); boolean isWater = destState.getFluidState().getType() instanceof WaterFluid; if (!isWater && willPlaceBucket() && !playerFeet.equals(dest)) { - if (!Inventory.isHotbarSlot(ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER)) || ctx.world().getDimensionKey() == Level.NETHER) { + if (!Inventory.isHotbarSlot(ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_WATER)) || ctx.world().dimension() == Level.NETHER) { return state.setStatus(MovementStatus.UNREACHABLE); } - if (ctx.player().getPositionVec().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().isOnGround()) { - ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER); + if (ctx.player().position().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().isOnGround()) { + ctx.player().getInventory().selected = ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_WATER); targetRotation = new Rotation(toDest.getYaw(), 90.0F); - if (ctx.isLookingAt(dest) || ctx.isLookingAt(dest.down())) { + if (ctx.isLookingAt(dest) || ctx.isLookingAt(dest.below())) { state.setInput(Input.CLICK_RIGHT, true); } } @@ -115,17 +115,17 @@ public class MovementFall extends Movement { } else { state.setTarget(new MovementTarget(toDest, false)); } - if (playerFeet.equals(dest) && (ctx.player().getPositionVec().y - playerFeet.getY() < 0.094 || isWater)) { // 0.094 because lilypads + if (playerFeet.equals(dest) && (ctx.player().position().y - playerFeet.getY() < 0.094 || isWater)) { // 0.094 because lilypads if (isWater) { // only match water, not flowing water (which we cannot pick up with a bucket) - if (Inventory.isHotbarSlot(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) { - ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY); - if (ctx.player().getMotion().y >= 0) { + if (Inventory.isHotbarSlot(ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_EMPTY))) { + ctx.player().getInventory().selected = ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_EMPTY); + if (ctx.player().getDeltaMovement().y >= 0) { return state.setInput(Input.CLICK_RIGHT, true); } else { return state; } } else { - if (ctx.player().getMotion().y >= 0) { + if (ctx.player().getDeltaMovement().y >= 0) { return state.setStatus(MovementStatus.SUCCESS); } // don't else return state; we need to stay centered because this water might be flowing under the surface } @@ -134,8 +134,8 @@ public class MovementFall extends Movement { } } Vec3 destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder) - if (Math.abs(ctx.player().getPositionVec().x + ctx.player().getMotion().x - destCenter.x) > 0.1 || Math.abs(ctx.player().getPositionVec().z + ctx.player().getMotion().z - destCenter.z) > 0.1) { - if (!ctx.player().isOnGround() && Math.abs(ctx.player().getMotion().y) > 0.4) { + if (Math.abs(ctx.player().position().x + ctx.player().getDeltaMovement().x - destCenter.x) > 0.1 || Math.abs(ctx.player().position().z + ctx.player().getDeltaMovement().z - destCenter.z) > 0.1) { + if (!ctx.player().isOnGround() && Math.abs(ctx.player().getDeltaMovement().y) > 0.4) { state.setInput(Input.SNEAK, true); } state.setInput(Input.MOVE_FORWARD, true); @@ -144,7 +144,7 @@ public class MovementFall extends Movement { if (avoid == null) { avoid = src.subtract(dest); } else { - double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().getPositionVec().x)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().getPositionVec().z)); + double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().position().x)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().position().z)); if (dist < 0.6) { state.setInput(Input.MOVE_FORWARD, true); } else if (!ctx.player().isOnGround()) { @@ -160,7 +160,7 @@ public class MovementFall extends Movement { private Direction avoid() { for (int i = 0; i < 15; i++) { - BlockState state = ctx.world().getBlockState(ctx.playerFeet().down(i)); + BlockState state = ctx.world().getBlockState(ctx.playerFeet().below(i)); if (state.getBlock() == Blocks.LADDER) { return state.getValue(LadderBlock.FACING); } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java index 845e96b22..b72b2a692 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementParkour.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementParkour.java @@ -46,7 +46,7 @@ public class MovementParkour extends Movement { private final boolean ascend; private MovementParkour(IBaritone baritone, BetterBlockPos src, int dist, Direction dir, boolean ascend) { - super(baritone, src, src.offset(dir, dist).up(ascend ? 1 : 0), EMPTY, src.offset(dir, dist).down(ascend ? 0 : 1)); + super(baritone, src, src.relative(dir, dist).above(ascend ? 1 : 0), EMPTY, src.relative(dir, dist).below(ascend ? 0 : 1)); this.direction = dir; this.dist = dist; this.ascend = ascend; @@ -209,7 +209,7 @@ public class MovementParkour extends Movement { Set set = new HashSet<>(); for (int i = 0; i <= dist; i++) { for (int y = 0; y < 2; y++) { - set.add(src.offset(direction, i).up(y)); + set.add(src.relative(direction, i).above(y)); } } return set; @@ -245,19 +245,19 @@ public class MovementParkour extends Movement { // but i did it anyway return state.setStatus(MovementStatus.SUCCESS); } - if (ctx.player().getPositionVec().y - ctx.playerFeet().getY() < 0.094) { // lilypads + if (ctx.player().position().y - ctx.playerFeet().getY() < 0.094) { // lilypads state.setStatus(MovementStatus.SUCCESS); } } else if (!ctx.playerFeet().equals(src)) { - if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().getPositionVec().y - src.y > 0.0001) { - if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().isOnGround() && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true, false) == PlaceResult.READY_TO_PLACE) { + if (ctx.playerFeet().equals(src.relative(direction)) || ctx.player().position().y - src.y > 0.0001) { + if (!MovementHelper.canWalkOn(ctx, dest.below()) && !ctx.player().isOnGround() && MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), true, false) == PlaceResult.READY_TO_PLACE) { // go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory state.setInput(Input.CLICK_RIGHT, true); } // prevent jumping too late by checking for ascend if (dist == 3 && !ascend) { // this is a 2 block gap, dest = src + direction * 3 - double xDiff = (src.x + 0.5) - ctx.player().getPositionVec().x; - double zDiff = (src.z + 0.5) - ctx.player().getPositionVec().z; + double xDiff = (src.x + 0.5) - ctx.player().position().x; + double zDiff = (src.z + 0.5) - ctx.player().position().z; double distFromStart = Math.max(Math.abs(xDiff), Math.abs(zDiff)); if (distFromStart < 0.7) { return state; @@ -265,12 +265,12 @@ public class MovementParkour extends Movement { } state.setInput(Input.JUMP, true); - } else if (!ctx.playerFeet().equals(dest.offset(direction, -1))) { + } else if (!ctx.playerFeet().equals(dest.relative(direction, -1))) { state.setInput(Input.SPRINT, false); - if (ctx.playerFeet().equals(src.offset(direction, -1))) { + if (ctx.playerFeet().equals(src.relative(direction, -1))) { MovementHelper.moveTowards(ctx, state, src); } else { - MovementHelper.moveTowards(ctx, state, src.offset(direction, -1)); + MovementHelper.moveTowards(ctx, state, src.relative(direction, -1)); } } } diff --git a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java index e84f851d8..9b775b973 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementPillar.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementPillar.java @@ -31,7 +31,6 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import com.google.common.collect.ImmutableSet; -import net.minecraft.block.*; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.AirBlock; import net.minecraft.world.level.block.Block; @@ -48,7 +47,7 @@ import java.util.Set; public class MovementPillar extends Movement { public MovementPillar(IBaritone baritone, BetterBlockPos start, BetterBlockPos end) { - super(baritone, start, end, new BetterBlockPos[]{start.up(2)}, start); + super(baritone, start, end, new BetterBlockPos[]{start.above(2)}, start); } @Override @@ -179,7 +178,7 @@ public class MovementPillar extends Movement { // stay centered while swimming up a water column state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false)); Vec3 destCenter = VecUtils.getBlockPosCenter(dest); - if (Math.abs(ctx.player().getPositionVec().x - destCenter.x) > 0.2 || Math.abs(ctx.player().getPositionVec().z - destCenter.z) > 0.2) { + if (Math.abs(ctx.player().position().x - destCenter.x) > 0.2 || Math.abs(ctx.player().position().z - destCenter.z) > 0.2) { state.setInput(Input.MOVE_FORWARD, true); } if (ctx.playerFeet().equals(dest)) { @@ -191,14 +190,14 @@ public class MovementPillar extends Movement { boolean vine = fromDown.getBlock() == Blocks.VINE; Rotation rotation = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(positionToPlace), - new Rotation(ctx.player().rotationYaw, ctx.player().rotationPitch)); + new Rotation(ctx.player().getYRot(), ctx.player().getXRot())); if (!ladder) { - state.setTarget(new MovementState.MovementTarget(new Rotation(ctx.player().rotationYaw, rotation.getPitch()), true)); + state.setTarget(new MovementState.MovementTarget(new Rotation(ctx.player().getYRot(), rotation.getPitch()), true)); } boolean blockIsThere = MovementHelper.canWalkOn(ctx, src) || ladder; if (ladder) { - BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.offset(fromDown.getValue(LadderBlock.FACING).getOpposite()); + BlockPos against = vine ? getAgainst(new CalculationContext(baritone), src) : src.relative(fromDown.getValue(LadderBlock.FACING).getOpposite()); if (against == null) { logDirect("Unable to climb vines. Consider disabling allowVines."); return state.setStatus(MovementStatus.UNREACHABLE); @@ -207,7 +206,7 @@ public class MovementPillar extends Movement { if (ctx.playerFeet().equals(against.above()) || ctx.playerFeet().equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); } - if (MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.down()))) { + if (MovementHelper.isBottomSlab(BlockStateInterface.get(ctx, src.below()))) { state.setInput(Input.JUMP, true); } /* @@ -225,13 +224,13 @@ public class MovementPillar extends Movement { } - state.setInput(Input.SNEAK, ctx.player().getPositionVec().y > dest.getY() || ctx.player().getPositionVec().y < src.getY() + 0.2D); // delay placement by 1 tick for ncp compatibility + state.setInput(Input.SNEAK, ctx.player().position().y > dest.getY() || ctx.player().position().y < src.getY() + 0.2D); // delay placement by 1 tick for ncp compatibility // since (lower down) we only right click once player.isSneaking, and that happens the tick after we request to sneak - double diffX = ctx.player().getPositionVec().x - (dest.getX() + 0.5); - double diffZ = ctx.player().getPositionVec().z - (dest.getZ() + 0.5); + double diffX = ctx.player().position().x - (dest.getX() + 0.5); + double diffZ = ctx.player().position().z - (dest.getZ() + 0.5); double dist = Math.sqrt(diffX * diffX + diffZ * diffZ); - double flatMotion = Math.sqrt(ctx.player().getMotion().x * ctx.player().getMotion().x + ctx.player().getMotion().z * ctx.player().getMotion().z); + double flatMotion = Math.sqrt(ctx.player().getDeltaMovement().x * ctx.player().getDeltaMovement().x + ctx.player().getDeltaMovement().z * ctx.player().getDeltaMovement().z); if (dist > 0.17) {//why 0.17? because it seemed like a good number, that's why //[explanation added after baritone port lol] also because it needs to be less than 0.2 because of the 0.3 sneak limit //and 0.17 is reasonably less than 0.2 @@ -243,7 +242,7 @@ public class MovementPillar extends Movement { state.setTarget(new MovementState.MovementTarget(rotation, true)); } else if (flatMotion < 0.05) { // If our Y coordinate is above our goal, stop jumping - state.setInput(Input.JUMP, ctx.player().getPositionVec().y < dest.getY()); + state.setInput(Input.JUMP, ctx.player().position().y < dest.getY()); } @@ -258,7 +257,7 @@ public class MovementPillar extends Movement { state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping state.setInput(Input.CLICK_LEFT, true); blockIsThere = false; - } else if (ctx.player().isCrouching() && (ctx.isLookingAt(src.down()) || ctx.isLookingAt(src)) && ctx.player().getPositionVec().y > dest.getY() + 0.1) { + } else if (ctx.player().isCrouching() && (ctx.isLookingAt(src.below()) || ctx.isLookingAt(src)) && ctx.player().position().y > dest.getY() + 0.1) { state.setInput(Input.CLICK_RIGHT, true); } } @@ -274,13 +273,13 @@ public class MovementPillar extends Movement { @Override protected boolean prepared(MovementState state) { - if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.down())) { - Block block = BlockStateInterface.getBlock(ctx, src.down()); + if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.below())) { + Block block = BlockStateInterface.getBlock(ctx, src.below()); if (block == Blocks.LADDER || block == Blocks.VINE) { state.setInput(Input.SNEAK, true); } } - if (MovementHelper.isWater(ctx, dest.up())) { + if (MovementHelper.isWater(ctx, dest.above())) { return true; } return super.prepared(state); diff --git a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java index e79b8ba5e..91128b950 100644 --- a/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/pathing/movement/movements/MovementTraverse.java @@ -31,7 +31,6 @@ import baritone.pathing.movement.MovementHelper; import baritone.pathing.movement.MovementState; import baritone.utils.BlockStateInterface; import com.google.common.collect.ImmutableSet; -import net.minecraft.block.*; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.AirBlock; import net.minecraft.world.level.block.Block; @@ -55,7 +54,7 @@ public class MovementTraverse extends Movement { private boolean wasTheBridgeBlockAlwaysThere = true; public MovementTraverse(IBaritone baritone, BetterBlockPos from, BetterBlockPos to) { - super(baritone, from, to, new BetterBlockPos[]{to.up(), to}, to.down()); + super(baritone, from, to, new BetterBlockPos[]{to.above(), to}, to.below()); } @Override @@ -182,7 +181,7 @@ public class MovementTraverse extends Movement { return state; } // and we aren't already pressed up against the block - double dist = Math.max(Math.abs(ctx.player().getPositionVec().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().getPositionVec().z - (dest.getZ() + 0.5D))); + double dist = Math.max(Math.abs(ctx.player().position().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().position().z - (dest.getZ() + 0.5D))); if (dist < 0.83) { return state; } @@ -208,7 +207,7 @@ public class MovementTraverse extends Movement { //sneak may have been set to true in the PREPPING state while mining an adjacent block state.setInput(Input.SNEAK, false); - Block fd = BlockStateInterface.get(ctx, src.down()).getBlock(); + Block fd = BlockStateInterface.get(ctx, src.below()).getBlock(); boolean ladder = fd == Blocks.LADDER || fd == Blocks.VINE; if (pb0.getBlock() instanceof DoorBlock || pb1.getBlock() instanceof DoorBlock) { @@ -222,7 +221,7 @@ public class MovementTraverse extends Movement { } if (pb0.getBlock() instanceof FenceGateBlock || pb1.getBlock() instanceof FenceGateBlock) { - BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.up()) ? positionsToBreak[0] + BlockPos blocked = !MovementHelper.isGatePassable(ctx, positionsToBreak[0], src.above()) ? positionsToBreak[0] : !MovementHelper.isGatePassable(ctx, positionsToBreak[1], src) ? positionsToBreak[1] : null; if (blocked != null) { @@ -247,27 +246,27 @@ public class MovementTraverse extends Movement { if (feet.equals(dest)) { return state.setStatus(MovementStatus.SUCCESS); } - if (Baritone.settings().overshootTraverse.value && (feet.equals(dest.add(getDirection())) || feet.equals(dest.add(getDirection()).add(getDirection())))) { + if (Baritone.settings().overshootTraverse.value && (feet.equals(dest.offset(getDirection())) || feet.equals(dest.offset(getDirection()).offset(getDirection())))) { return state.setStatus(MovementStatus.SUCCESS); } Block low = BlockStateInterface.get(ctx, src).getBlock(); - Block high = BlockStateInterface.get(ctx, src.up()).getBlock(); - if (ctx.player().getPositionVec().y > src.y + 0.1D && !ctx.player().isOnGround() && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) { + Block high = BlockStateInterface.get(ctx, src.above()).getBlock(); + if (ctx.player().position().y > src.y + 0.1D && !ctx.player().isOnGround() && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) { // hitting W could cause us to climb the ladder instead of going forward // wait until we're on the ground return state; } - BlockPos into = dest.subtract(src).add(dest); + BlockPos into = dest.subtract(src).offset(dest); BlockState intoBelow = BlockStateInterface.get(ctx, into); BlockState intoAbove = BlockStateInterface.get(ctx, into.above()); if (wasTheBridgeBlockAlwaysThere && (!MovementHelper.isLiquid(ctx, feet) || Baritone.settings().sprintInWater.value) && (!MovementHelper.avoidWalkingInto(intoBelow) || MovementHelper.isWater(intoBelow)) && !MovementHelper.avoidWalkingInto(intoAbove)) { state.setInput(Input.SPRINT, true); } - BlockState destDown = BlockStateInterface.get(ctx, dest.down()); + BlockState destDown = BlockStateInterface.get(ctx, dest.below()); BlockPos against = positionsToBreak[0]; if (feet.getY() != dest.getY() && ladder && (destDown.getBlock() == Blocks.VINE || destDown.getBlock() == Blocks.LADDER)) { - against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.down()) : dest.offset(destDown.getValue(LadderBlock.FACING).getOpposite()); + against = destDown.getBlock() == Blocks.VINE ? MovementPillar.getAgainst(new CalculationContext(baritone), dest.below()) : dest.relative(destDown.getValue(LadderBlock.FACING).getOpposite()); if (against == null) { logDirect("Unable to climb vines. Consider disabling allowVines."); return state.setStatus(MovementStatus.UNREACHABLE); @@ -279,15 +278,15 @@ public class MovementTraverse extends Movement { wasTheBridgeBlockAlwaysThere = false; Block standingOn = BlockStateInterface.get(ctx, feet.below()).getBlock(); if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof SlabBlock) { // see issue #118 - double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().getPositionVec().x), Math.abs(dest.getZ() + 0.5 - ctx.player().getPositionVec().z)); + double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().position().x), Math.abs(dest.getZ() + 0.5 - ctx.player().position().z)); if (dist < 0.85) { // 0.5 + 0.3 + epsilon MovementHelper.moveTowards(ctx, state, dest); return state.setInput(Input.MOVE_FORWARD, false) .setInput(Input.MOVE_BACK, true); } } - double dist1 = Math.max(Math.abs(ctx.player().getPositionVec().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().getPositionVec().z - (dest.getZ() + 0.5D))); - PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false, true); + double dist1 = Math.max(Math.abs(ctx.player().position().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().position().z - (dest.getZ() + 0.5D))); + PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.below(), false, true); if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) { state.setInput(Input.SNEAK, true); } @@ -322,11 +321,11 @@ public class MovementTraverse extends Movement { double faceY = (dest.getY() + src.getY() - 1.0D) * 0.5D; double faceZ = (dest.getZ() + src.getZ() + 1.0D) * 0.5D; // faceX, faceY, faceZ is the middle of the face between from and to - BlockPos goalLook = src.down(); // this is the block we were just standing on, and the one we want to place against + BlockPos goalLook = src.below(); // this is the block we were just standing on, and the one we want to place against Rotation backToFace = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3(faceX, faceY, faceZ), ctx.playerRotations()); float pitch = backToFace.getPitch(); - double dist2 = Math.max(Math.abs(ctx.player().getPositionVec().x - faceX), Math.abs(ctx.player().getPositionVec().z - faceZ)); + double dist2 = Math.max(Math.abs(ctx.player().position().x - faceX), Math.abs(ctx.player().position().z - faceZ)); if (dist2 < 0.29) { // see issue #208 float yaw = RotationUtils.calcRotationFromVec3d(VecUtils.getBlockPosCenter(dest), ctx.playerHead(), ctx.playerRotations()).getYaw(); state.setTarget(new MovementState.MovementTarget(new Rotation(yaw, pitch), true)); @@ -354,13 +353,13 @@ public class MovementTraverse extends Movement { // if we're in the process of breaking blocks before walking forwards // or if this isn't a sneak place (the block is already there) // then it's safe to cancel this - return state.getStatus() != MovementStatus.RUNNING || MovementHelper.canWalkOn(ctx, dest.down()); + return state.getStatus() != MovementStatus.RUNNING || MovementHelper.canWalkOn(ctx, dest.below()); } @Override protected boolean prepared(MovementState state) { - if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.down())) { - Block block = BlockStateInterface.getBlock(ctx, src.down()); + if (ctx.playerFeet().equals(src) || ctx.playerFeet().equals(src.below())) { + Block block = BlockStateInterface.getBlock(ctx, src.below()); if (block == Blocks.LADDER || block == Blocks.VINE) { state.setInput(Input.SNEAK, true); } diff --git a/src/main/java/baritone/pathing/path/PathExecutor.java b/src/main/java/baritone/pathing/path/PathExecutor.java index 524163a45..2b35d6f3c 100644 --- a/src/main/java/baritone/pathing/path/PathExecutor.java +++ b/src/main/java/baritone/pathing/path/PathExecutor.java @@ -40,8 +40,6 @@ import java.util.*; import static baritone.api.pathing.movement.MovementStatus.*; -import IPlayerContext; - /** * Behavior to execute a precomputed path * @@ -277,11 +275,11 @@ public class PathExecutor implements IPathExecutor, Helper { if (!ctx.player().isOnGround()) { return false; } - if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().down())) { + if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().below())) { // we're in some kind of sketchy situation, maybe parkouring return false; } - if (!MovementHelper.canWalkThrough(ctx, ctx.playerFeet()) || !MovementHelper.canWalkThrough(ctx, ctx.playerFeet().up())) { + if (!MovementHelper.canWalkThrough(ctx, ctx.playerFeet()) || !MovementHelper.canWalkThrough(ctx, ctx.playerFeet().above())) { // suffocating? return false; } @@ -328,7 +326,7 @@ public class PathExecutor implements IPathExecutor, Helper { return false; } else { // we are either onGround or in liquid - if (ctx.player().getMotion().y < -0.1) { + if (ctx.player().getDeltaMovement().y < -0.1) { // if we are strictly moving downwards (not stationary) // we could be falling through water, which could be unsafe to splice return false; // so don't @@ -387,7 +385,7 @@ public class PathExecutor implements IPathExecutor, Helper { if (pathPosition < path.length() - 2) { IMovement next = path.movements().get(pathPosition + 1); - if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { + if (next instanceof MovementAscend && current.getDirection().above().equals(next.getDirection().below())) { // a descend then an ascend in the same direction pathPosition++; onChangeInPathPosition(); @@ -409,12 +407,12 @@ public class PathExecutor implements IPathExecutor, Helper { } if (current instanceof MovementAscend && pathPosition != 0) { IMovement prev = path.movements().get(pathPosition - 1); - if (prev instanceof MovementDescend && prev.getDirection().up().equals(current.getDirection().down())) { - BlockPos center = current.getSrc().up(); + if (prev instanceof MovementDescend && prev.getDirection().above().equals(current.getDirection().below())) { + BlockPos center = current.getSrc().above(); // playerFeet adds 0.1251 to account for soul sand // farmland is 0.9375 // 0.07 is to account for farmland - if (ctx.player().getPositionVec().y >= center.getY() - 0.07) { + if (ctx.player().position().y >= center.getY() - 0.07) { behavior.baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, false); return true; } @@ -470,7 +468,7 @@ public class PathExecutor implements IPathExecutor, Helper { break outer; } } - if (!MovementHelper.canWalkOn(ctx, next.getDest().down())) { + if (!MovementHelper.canWalkOn(ctx, next.getDest().below())) { break; } } @@ -481,21 +479,21 @@ public class PathExecutor implements IPathExecutor, Helper { double len = i - pathPosition - 0.4; return new Tuple<>( new Vec3(flatDir.getX() * len + movement.getDest().x + 0.5, movement.getDest().y, flatDir.getZ() * len + movement.getDest().z + 0.5), - movement.getDest().add(flatDir.getX() * (i - pathPosition), 0, flatDir.getZ() * (i - pathPosition))); + movement.getDest().offset(flatDir.getX() * (i - pathPosition), 0, flatDir.getZ() * (i - pathPosition))); } private static boolean skipNow(IPlayerContext ctx, IMovement current) { - double offTarget = Math.abs(current.getDirection().getX() * (current.getSrc().z + 0.5D - ctx.player().getPositionVec().z)) + Math.abs(current.getDirection().getZ() * (current.getSrc().x + 0.5D - ctx.player().getPositionVec().x)); + double offTarget = Math.abs(current.getDirection().getX() * (current.getSrc().z + 0.5D - ctx.player().position().z)) + Math.abs(current.getDirection().getZ() * (current.getSrc().x + 0.5D - ctx.player().position().x)); if (offTarget > 0.1) { return false; } // we are centered - BlockPos headBonk = current.getSrc().subtract(current.getDirection()).up(2); + BlockPos headBonk = current.getSrc().subtract(current.getDirection()).above(2); if (MovementHelper.fullyPassable(ctx, headBonk)) { return true; } // wait 0.3 - double flatDist = Math.abs(current.getDirection().getX() * (headBonk.getX() + 0.5D - ctx.player().getPositionVec().x)) + Math.abs(current.getDirection().getZ() * (headBonk.getZ() + 0.5 - ctx.player().getPositionVec().z)); + double flatDist = Math.abs(current.getDirection().getX() * (headBonk.getX() + 0.5D - ctx.player().position().x)) + Math.abs(current.getDirection().getZ() * (headBonk.getZ() + 0.5 - ctx.player().position().z)); return flatDist > 0.8; } @@ -509,10 +507,10 @@ public class PathExecutor implements IPathExecutor, Helper { if (nextnext.getDirection().getX() != next.getDirection().getX() || nextnext.getDirection().getZ() != next.getDirection().getZ()) { return false; } - if (!MovementHelper.canWalkOn(ctx, current.getDest().down())) { + if (!MovementHelper.canWalkOn(ctx, current.getDest().below())) { return false; } - if (!MovementHelper.canWalkOn(ctx, next.getDest().down())) { + if (!MovementHelper.canWalkOn(ctx, next.getDest().below())) { return false; } if (!next.toBreakCached.isEmpty()) { @@ -520,7 +518,7 @@ public class PathExecutor implements IPathExecutor, Helper { } for (int x = 0; x < 2; x++) { for (int y = 0; y < 3; y++) { - BlockPos chk = current.getSrc().up(y); + BlockPos chk = current.getSrc().above(y); if (x == 1) { chk = chk.offset(current.getDirection()); } @@ -529,20 +527,20 @@ public class PathExecutor implements IPathExecutor, Helper { } } } - if (MovementHelper.avoidWalkingInto(ctx.world().getBlockState(current.getSrc().up(3)))) { + if (MovementHelper.avoidWalkingInto(ctx.world().getBlockState(current.getSrc().above(3)))) { return false; } - return !MovementHelper.avoidWalkingInto(ctx.world().getBlockState(next.getDest().up(2))); // codacy smh my head + return !MovementHelper.avoidWalkingInto(ctx.world().getBlockState(next.getDest().above(2))); // codacy smh my head } private static boolean canSprintFromDescendInto(IPlayerContext ctx, IMovement current, IMovement next) { if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) { return true; } - if (!MovementHelper.canWalkOn(ctx, current.getDest().add(current.getDirection()))) { + if (!MovementHelper.canWalkOn(ctx, current.getDest().offset(current.getDirection()))) { return false; } - if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection())) { + if (next instanceof MovementTraverse && next.getDirection().equals(current.getDirection())) { return true; } return next instanceof MovementDiagonal && Baritone.settings().allowOvershootDiagonalDescend.value; diff --git a/src/main/java/baritone/process/BackfillProcess.java b/src/main/java/baritone/process/BackfillProcess.java index 5d245c2eb..79073860d 100644 --- a/src/main/java/baritone/process/BackfillProcess.java +++ b/src/main/java/baritone/process/BackfillProcess.java @@ -104,7 +104,7 @@ public final class BackfillProcess extends BaritoneProcessHelper { .filter(pos -> ctx.world().getBlockState(pos).getBlock() == Blocks.AIR) .filter(pos -> baritone.getBuilderProcess().placementPlausible(pos, Blocks.DIRT.defaultBlockState())) .filter(pos -> !partOfCurrentMovement(pos)) - .sorted(Comparator.comparingDouble(ctx.playerFeet()::distanceSq).reversed()) + .sorted(Comparator.comparingDouble(ctx.playerFeet()::distSqr).reversed()) .collect(Collectors.toList()); } diff --git a/src/main/java/baritone/process/BuilderProcess.java b/src/main/java/baritone/process/BuilderProcess.java index 98e6db93f..e10d32b7e 100644 --- a/src/main/java/baritone/process/BuilderProcess.java +++ b/src/main/java/baritone/process/BuilderProcess.java @@ -275,12 +275,12 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil public boolean placementPlausible(BlockPos pos, BlockState state) { VoxelShape voxelshape = state.getCollisionShape(ctx.world(), pos); - return voxelshape.isEmpty() || ctx.world().checkNoEntityCollision(null, voxelshape.move(pos.getX(), pos.getY(), pos.getZ())); + return voxelshape.isEmpty() || ctx.world().isUnobstructed(null, voxelshape.move(pos.getX(), pos.getY(), pos.getZ())); } private Optional possibleToPlace(BlockState toPlace, int x, int y, int z, BlockStateInterface bsi) { for (Direction against : Direction.values()) { - BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).offset(against); + BetterBlockPos placeAgainstPos = new BetterBlockPos(x, y, z).relative(against); BlockState placeAgainstState = bsi.get0(placeAgainstPos); if (MovementHelper.isReplaceable(placeAgainstPos.x, placeAgainstPos.y, placeAgainstPos.z, placeAgainstState, bsi)) { continue; @@ -291,7 +291,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (!placementPlausible(new BetterBlockPos(x, y, z), toPlace)) { continue; } - AABB aabb = placeAgainstState.getShape(ctx.world(), placeAgainstPos).getBoundingBox(); + AABB aabb = placeAgainstState.getShape(ctx.world(), placeAgainstPos).bounds(); for (Vec3 placementMultiplier : aabbSideMultipliers(against)) { double placeX = placeAgainstPos.x + aabb.minX * placementMultiplier.x + aabb.maxX * (1 - placementMultiplier.x); double placeY = placeAgainstPos.y + aabb.minY * placementMultiplier.y + aabb.maxY * (1 - placementMultiplier.y); @@ -311,15 +311,15 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil private OptionalInt hasAnyItemThatWouldPlace(BlockState desired, HitResult result, Rotation rot) { for (int i = 0; i < 9; i++) { - ItemStack stack = ctx.player().inventory.mainInventory.get(i); + ItemStack stack = ctx.player().getInventory().items.get(i); if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) { continue; } - float originalYaw = ctx.player().rotationYaw; - float originalPitch = ctx.player().rotationPitch; + float originalYaw = ctx.player().getYRot(); + float originalPitch = ctx.player().getXRot(); // the state depends on the facing of the player sometimes - ctx.player().rotationYaw = rot.getYaw(); - ctx.player().rotationPitch = rot.getPitch(); + ctx.player().setYRot(rot.getYaw()); + ctx.player().setXRot(rot.getPitch()); BlockPlaceContext meme = new BlockPlaceContext(new UseOnContext( ctx.world(), ctx.player(), @@ -328,8 +328,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil (BlockHitResult) result ) {}); // that {} gives us access to a protected constructor lmfao BlockState wouldBePlaced = ((BlockItem) stack.getItem()).getBlock().getStateForPlacement(meme); - ctx.player().rotationYaw = originalYaw; - ctx.player().rotationPitch = originalPitch; + ctx.player().setYRot(originalYaw); + ctx.player().setXRot(originalPitch); if (wouldBePlaced == null) { continue; } @@ -468,7 +468,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil if (toPlace.isPresent() && isSafeToCancel && ctx.player().isOnGround() && ticks <= 0) { Rotation rot = toPlace.get().rot; baritone.getLookBehavior().updateTarget(rot, true); - ctx.player().inventory.currentItem = toPlace.get().hotbarSelection; + ctx.player().getInventory().selected = toPlace.get().hotbarSelection; baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true); if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ((BlockHitResult) ctx.objectMouseOver()).getDirection().equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) { baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); @@ -535,7 +535,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil private void trim() { HashSet copy = new HashSet<>(incorrectPositions); - copy.removeIf(pos -> pos.distanceSq(ctx.player().getPosition()) > 200); + copy.removeIf(pos -> pos.distSqr(ctx.player().blockPosition()) > 200); if (!copy.isEmpty()) { incorrectPositions = copy; } @@ -626,7 +626,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil missing.put(desired, 1 + missing.getOrDefault(desired, 0)); } } else { - if (state.getBlock() instanceof FlowingFluidBlock) { + if (state.getBlock() instanceof LiquidBlock) { // if the block itself is JUST a liquid (i.e. not just a waterlogged block), we CANNOT break it // TODO for 1.13 make sure that this only matches pure water, not waterlogged blocks if (!MovementHelper.possiblyFlowing(state)) { @@ -644,11 +644,11 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil breakable.forEach(pos -> toBreak.add(breakGoal(pos, bcc))); List toPlace = new ArrayList<>(); placeable.forEach(pos -> { - if (!placeable.contains(pos.down()) && !placeable.contains(pos.down(2))) { + if (!placeable.contains(pos.below()) && !placeable.contains(pos.below(2))) { toPlace.add(placementGoal(pos, bcc)); } }); - sourceLiquids.forEach(pos -> toPlace.add(new GoalBlock(pos.up()))); + sourceLiquids.forEach(pos -> toPlace.add(new GoalBlock(pos.above()))); if (!toPlace.isEmpty()) { return new JankyGoalComposite(new GoalComposite(toPlace.toArray(new Goal[0])), new GoalComposite(toBreak.toArray(new Goal[0]))); @@ -810,13 +810,13 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil private List approxPlaceable(int size) { List result = new ArrayList<>(); for (int i = 0; i < size; i++) { - ItemStack stack = ctx.player().inventory.mainInventory.get(i); + ItemStack stack = ctx.player().getInventory().items.get(i); if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) { result.add(Blocks.AIR.defaultBlockState()); continue; } // - result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {}))); + result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockPlaceContext(new UseOnContext(ctx.world(), ctx.player(), InteractionHand.MAIN_HAND, stack, new BlockHitResult(new Vec3(ctx.player().position().x, ctx.player().position().y, ctx.player().position().z), Direction.UP, ctx.playerFeet(), false)) {}))); // } return result; diff --git a/src/main/java/baritone/process/CustomGoalProcess.java b/src/main/java/baritone/process/CustomGoalProcess.java index f925bec79..86099860b 100644 --- a/src/main/java/baritone/process/CustomGoalProcess.java +++ b/src/main/java/baritone/process/CustomGoalProcess.java @@ -92,7 +92,7 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC if (this.goal == null || (this.goal.isInGoal(ctx.playerFeet()) && this.goal.isInGoal(baritone.getPathingBehavior().pathStart()))) { onLostControl(); // we're there xd if (Baritone.settings().disconnectOnArrival.value) { - ctx.world().sendQuittingDisconnectingPacket(); + ctx.world().disconnect(); } if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnPathComplete.value) { NotificationHelper.notify("Pathing complete", false); diff --git a/src/main/java/baritone/process/FarmProcess.java b/src/main/java/baritone/process/FarmProcess.java index 243e29cc6..db312884b 100644 --- a/src/main/java/baritone/process/FarmProcess.java +++ b/src/main/java/baritone/process/FarmProcess.java @@ -32,7 +32,6 @@ import baritone.cache.WorldScanner; import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.NotificationHelper; -import net.minecraft.block.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.entity.Entity; @@ -230,7 +229,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro } if (state.getBlock() instanceof BonemealableBlock) { BonemealableBlock ig = (BonemealableBlock) state.getBlock(); - if (ig.isValidBonemealTarget(ctx.world(), pos, state, true) && ig.isBonemealSuccess(ctx.world(), ctx.world().rand, pos, state)) { + if (ig.isValidBonemealTarget(ctx.world(), pos, state, true) && ig.isBonemealSuccess(ctx.world(), ctx.world().random, pos, state)) { bonemealable.add(pos); } } diff --git a/src/main/java/baritone/process/GetToBlockProcess.java b/src/main/java/baritone/process/GetToBlockProcess.java index 21bbaf4e0..28037dca0 100644 --- a/src/main/java/baritone/process/GetToBlockProcess.java +++ b/src/main/java/baritone/process/GetToBlockProcess.java @@ -17,7 +17,6 @@ package baritone.process; -import Goal; import baritone.Baritone; import baritone.api.pathing.goals.*; import baritone.api.process.IGetToBlockProcess; @@ -124,7 +123,7 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG // blacklist the closest block and its adjacent blocks public synchronized boolean blacklistClosest() { List newBlacklist = new ArrayList<>(); - knownLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)).ifPresent(newBlacklist::add); + knownLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distSqr)).ifPresent(newBlacklist::add); outer: while (true) { for (BlockPos known : knownLocations) { @@ -196,8 +195,8 @@ public final class GetToBlockProcess extends BaritoneProcessHelper implements IG baritone.getLookBehavior().updateTarget(reachable.get(), true); if (knownLocations.contains(ctx.getSelectedBlock().orElse(null))) { baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true); // TODO find some way to right click even if we're in an ESC menu - System.out.println(ctx.player().openContainer); - if (!(ctx.player().openContainer instanceof InventoryMenu)) { + System.out.println(ctx.player().containerMenu); + if (!(ctx.player().containerMenu instanceof InventoryMenu)) { return true; } } diff --git a/src/main/java/baritone/process/MineProcess.java b/src/main/java/baritone/process/MineProcess.java index 2222ed134..34ae75e8c 100644 --- a/src/main/java/baritone/process/MineProcess.java +++ b/src/main/java/baritone/process/MineProcess.java @@ -31,7 +31,6 @@ import baritone.pathing.movement.MovementHelper; import baritone.utils.BaritoneProcessHelper; import baritone.utils.BlockStateInterface; import baritone.utils.NotificationHelper; -import net.minecraft.block.*; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; @@ -47,10 +46,6 @@ import java.util.stream.Collectors; import static baritone.api.pathing.movement.ActionCosts.COST_INF; -import BlockOptionalMetaLookup; -import Goal; -import GoalRunAway; - /** * Mine blocks of a certain type * @@ -81,7 +76,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro @Override public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) { if (desiredQuantity > 0) { - int curr = ctx.player().inventory.mainInventory.stream() + int curr = ctx.player().getInventory().items.stream() .filter(stack -> filter.has(stack)) .mapToInt(ItemStack::getCount).sum(); System.out.println("Currently have " + curr + " valid items"); @@ -97,7 +92,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro if (Baritone.settings().desktopNotifications.value && Baritone.settings().notificationOnMineFail.value) { NotificationHelper.notify("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...", true); } - knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)).ifPresent(blacklist::add); + knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distSqr)).ifPresent(blacklist::add); knownOreLocations.removeIf(blacklist::contains); } else { logDirect("Unable to find any path to " + filter + ", canceling mine"); @@ -127,7 +122,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro .filter(pos -> pos.getX() == ctx.playerFeet().getX() && pos.getZ() == ctx.playerFeet().getZ()) .filter(pos -> pos.getY() >= ctx.playerFeet().getY()) .filter(pos -> !(BlockStateInterface.get(ctx, pos).getBlock() instanceof AirBlock)) // after breaking a block, it takes mineGoalUpdateInterval ticks for it to actually update this list =( - .min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)); + .min(Comparator.comparingDouble(ctx.playerFeet()::distSqr)); baritone.getInputOverrideHandler().clearAllKeys(); if (shaft.isPresent() && ctx.player().isOnGround()) { BlockPos pos = shaft.get(); @@ -427,7 +422,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro .filter(pos -> !blacklist.contains(pos)) - .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player().getPosition()::distanceSq)) + .sorted(Comparator.comparingDouble(ctx.getBaritone().getPlayerContext().player().blockPosition()::distSqr)) .collect(Collectors.toList()); if (locs.size() > max) { diff --git a/src/main/java/baritone/selection/Selection.java b/src/main/java/baritone/selection/Selection.java index 730856943..d4b115de4 100644 --- a/src/main/java/baritone/selection/Selection.java +++ b/src/main/java/baritone/selection/Selection.java @@ -37,7 +37,7 @@ public class Selection implements ISelection { max.z - min.z + 1 ); - this.aabb = new AABB(this.min, this.max.add(1, 1, 1)); + this.aabb = new AABB(this.min, this.max.offset(1, 1, 1)); } @Override @@ -108,23 +108,23 @@ public class Selection implements ISelection { @Override public ISelection expand(Direction direction, int blocks) { if (isPos2(direction)) { - return new Selection(pos1, pos2.offset(direction, blocks)); + return new Selection(pos1, pos2.relative(direction, blocks)); } else { - return new Selection(pos1.offset(direction, blocks), pos2); + return new Selection(pos1.relative(direction, blocks), pos2); } } @Override public ISelection contract(Direction direction, int blocks) { if (isPos2(direction)) { - return new Selection(pos1.offset(direction, blocks), pos2); + return new Selection(pos1.relative(direction, blocks), pos2); } else { - return new Selection(pos1, pos2.offset(direction, blocks)); + return new Selection(pos1, pos2.relative(direction, blocks)); } } @Override public ISelection shift(Direction direction, int blocks) { - return new Selection(pos1.offset(direction, blocks), pos2.offset(direction, blocks)); + return new Selection(pos1.relative(direction, blocks), pos2.relative(direction, blocks)); } } diff --git a/src/main/java/baritone/selection/SelectionRenderer.java b/src/main/java/baritone/selection/SelectionRenderer.java index d0be61e64..90c4bca10 100644 --- a/src/main/java/baritone/selection/SelectionRenderer.java +++ b/src/main/java/baritone/selection/SelectionRenderer.java @@ -38,13 +38,13 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener { IRenderer.glColor(settings.colorSelectionPos1.value, opacity); for (ISelection selection : selections) { - IRenderer.drawAABB(stack, new AABB(selection.pos1(), selection.pos1().add(1, 1, 1))); + IRenderer.drawAABB(stack, new AABB(selection.pos1(), selection.pos1().offset(1, 1, 1))); } IRenderer.glColor(settings.colorSelectionPos2.value, opacity); for (ISelection selection : selections) { - IRenderer.drawAABB(stack, new AABB(selection.pos2(), selection.pos2().add(1, 1, 1))); + IRenderer.drawAABB(stack, new AABB(selection.pos2(), selection.pos2().offset(1, 1, 1))); } } diff --git a/src/main/java/baritone/utils/BlockBreakHelper.java b/src/main/java/baritone/utils/BlockBreakHelper.java index 62262d5a8..5edc1439b 100644 --- a/src/main/java/baritone/utils/BlockBreakHelper.java +++ b/src/main/java/baritone/utils/BlockBreakHelper.java @@ -56,12 +56,12 @@ public final class BlockBreakHelper implements Helper { if (!didBreakLastTick) { ctx.playerController().syncHeldItem(); ctx.playerController().clickBlock(((BlockHitResult) trace).getBlockPos(), ((BlockHitResult) trace).getDirection()); - ctx.player().swingArm(InteractionHand.MAIN_HAND); + ctx.player().swing(InteractionHand.MAIN_HAND); } // Attempt to break the block if (ctx.playerController().onPlayerDamageBlock(((BlockHitResult) trace).getBlockPos(), ((BlockHitResult) trace).getDirection())) { - ctx.player().swingArm(InteractionHand.MAIN_HAND); + ctx.player().swing(InteractionHand.MAIN_HAND); } ctx.playerController().setHittingBlock(false); diff --git a/src/main/java/baritone/utils/BlockPlaceHelper.java b/src/main/java/baritone/utils/BlockPlaceHelper.java index 2374bdd0c..fb8cba397 100644 --- a/src/main/java/baritone/utils/BlockPlaceHelper.java +++ b/src/main/java/baritone/utils/BlockPlaceHelper.java @@ -40,16 +40,16 @@ public class BlockPlaceHelper implements Helper { return; } HitResult mouseOver = ctx.objectMouseOver(); - if (!rightClickRequested || ctx.player().isRowingBoat() || mouseOver == null || mouseOver.getType() != HitResult.Type.BLOCK) { + if (!rightClickRequested || ctx.player().isHandsBusy() || mouseOver == null || mouseOver.getType() != HitResult.Type.BLOCK) { return; } rightClickTimer = Baritone.settings().rightClickSpeed.value; for (InteractionHand hand : InteractionHand.values()) { if (ctx.playerController().processRightClickBlock(ctx.player(), ctx.world(), hand, (BlockHitResult) mouseOver) == InteractionResult.SUCCESS) { - ctx.player().swingArm(hand); + ctx.player().swing(hand); return; } - if (!ctx.player().getHeldItem(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == InteractionResult.SUCCESS) { + if (!ctx.player().getItemInHand(hand).isEmpty() && ctx.playerController().processRightClick(ctx.player(), ctx.world(), hand) == InteractionResult.SUCCESS) { return; } } diff --git a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java index 29fbb07ba..19b04b454 100644 --- a/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java +++ b/src/main/java/baritone/utils/BlockStateInterfaceAccessWrapper.java @@ -53,4 +53,15 @@ public final class BlockStateInterfaceAccessWrapper implements BlockGetter { public FluidState getFluidState(BlockPos blockPos) { return getBlockState(blockPos).getFluidState(); } + + @Override + public int getHeight() { + return 255; + } + + @Override + public int getMinBuildHeight() { + return 0; + } + } diff --git a/src/main/java/baritone/utils/GuiClick.java b/src/main/java/baritone/utils/GuiClick.java index 70a97b077..6635016a4 100644 --- a/src/main/java/baritone/utils/GuiClick.java +++ b/src/main/java/baritone/utils/GuiClick.java @@ -33,7 +33,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.network.chat.BaseComponent; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.TextComponent; -import net.minecraft.util.math.*; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ClipContext; import net.minecraft.world.phys.AABB; @@ -64,12 +63,12 @@ public class GuiClick extends Screen implements Helper { @Override public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) { - double mx = mc.mouseHelper.getMouseX(); - double my = mc.mouseHelper.getMouseY(); + double mx = mc.mouseHandler.xpos(); + double my = mc.mouseHandler.ypos(); - my = mc.getMainWindow().getHeight() - my; - my *= mc.getMainWindow().getFramebufferHeight() / (double) mc.getMainWindow().getHeight(); - mx *= mc.getMainWindow().getFramebufferWidth() / (double) mc.getMainWindow().getWidth(); + my = mc.getWindow().getScreenHeight() - my; + my *= mc.getWindow().getHeight() / (double) mc.getWindow().getScreenHeight(); + mx *= mc.getWindow().getWidth() / (double) mc.getWindow().getScreenWidth(); Vec3 near = toWorld(mx, my, 0); Vec3 far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv @@ -123,13 +122,14 @@ public class GuiClick extends Screen implements Helper { this.projectionViewMatrix.invert(); if (currentMouseOver != null) { - Entity e = mc.getRenderViewEntity(); + Entity e = mc.getCameraEntity(); // drawSingleSelectionBox WHEN? PathRenderer.drawManySelectionBoxes(modelViewStack, e, Collections.singletonList(currentMouseOver), Color.CYAN); if (clickStart != null && !clickStart.equals(currentMouseOver)) { RenderSystem.enableBlend(); RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - RenderSystem.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F); + //TODO: fix + //RenderSystem.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F); RenderSystem.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value); RenderSystem.disableTexture(); RenderSystem.depthMask(false); @@ -151,8 +151,8 @@ public class GuiClick extends Screen implements Helper { return null; } - x /= mc.getMainWindow().getFramebufferWidth(); - y /= mc.getMainWindow().getFramebufferHeight(); + x /= mc.getWindow().getWidth(); + y /= mc.getWindow().getHeight(); x = x * 2 - 1; y = y * 2 - 1; diff --git a/src/main/java/baritone/utils/IRenderer.java b/src/main/java/baritone/utils/IRenderer.java index 3f263e91a..cb52f2a00 100644 --- a/src/main/java/baritone/utils/IRenderer.java +++ b/src/main/java/baritone/utils/IRenderer.java @@ -22,10 +22,7 @@ import baritone.api.Settings; import baritone.api.utils.Helper; import baritone.utils.accessor.IEntityRenderManager; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferBuilder; -import com.mojang.blaze3d.vertex.DefaultVertexFormat; -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.Tesselator; +import com.mojang.blaze3d.vertex.*; import com.mojang.math.Matrix4f; import java.awt.*; import net.minecraft.world.phys.AABB; @@ -36,12 +33,13 @@ public interface IRenderer { Tesselator tessellator = Tesselator.getInstance(); BufferBuilder buffer = tessellator.getBuilder(); - IEntityRenderManager renderManager = (IEntityRenderManager) Helper.mc.getRenderManager(); + IEntityRenderManager renderManager = (IEntityRenderManager) Helper.mc.getEntityRenderDispatcher(); Settings settings = BaritoneAPI.getSettings(); static void glColor(Color color, float alpha) { float[] colorComponents = color.getColorComponents(null); - RenderSystem.color4f(colorComponents[0], colorComponents[1], colorComponents[2], alpha); + //TODO: fix + //RenderSystem.color4f(colorComponents[0], colorComponents[1], colorComponents[2], alpha); } static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) { @@ -75,7 +73,8 @@ public interface IRenderer { AABB toDraw = aabb.move(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ()); Matrix4f matrix4f = stack.last().pose(); - buffer.begin(GL_LINES, DefaultVertexFormat.POSITION); + //TODO: check + buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION); // bottom buffer.vertex(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).endVertex(); buffer.vertex(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).endVertex(); diff --git a/src/main/java/baritone/utils/InputOverrideHandler.java b/src/main/java/baritone/utils/InputOverrideHandler.java index a024ab342..d91123108 100755 --- a/src/main/java/baritone/utils/InputOverrideHandler.java +++ b/src/main/java/baritone/utils/InputOverrideHandler.java @@ -94,12 +94,12 @@ public final class InputOverrideHandler extends Behavior implements IInputOverri blockPlaceHelper.tick(isInputForcedDown(Input.CLICK_RIGHT)); if (inControl()) { - if (ctx.player().movementInput.getClass() != PlayerMovementInput.class) { - ctx.player().movementInput = new PlayerMovementInput(this); + if (ctx.player().input.getClass() != PlayerMovementInput.class) { + ctx.player().input = new PlayerMovementInput(this); } } else { - if (ctx.player().movementInput.getClass() == PlayerMovementInput.class) { // allow other movement inputs that aren't this one, e.g. for a freecam - ctx.player().movementInput = new KeyboardInput(Minecraft.getInstance().options); + if (ctx.player().input.getClass() == PlayerMovementInput.class) { // allow other movement inputs that aren't this one, e.g. for a freecam + ctx.player().input = new KeyboardInput(Minecraft.getInstance().options); } } // only set it if it was previously incorrect diff --git a/src/main/java/baritone/utils/PathRenderer.java b/src/main/java/baritone/utils/PathRenderer.java index b637e0c23..ffd4985bd 100644 --- a/src/main/java/baritone/utils/PathRenderer.java +++ b/src/main/java/baritone/utils/PathRenderer.java @@ -29,6 +29,7 @@ import baritone.pathing.path.PathExecutor; import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.math.Matrix4f; import java.awt.*; import java.util.Collection; @@ -73,19 +74,19 @@ public final class PathRenderer implements IRenderer, Helper { public static void render(RenderEvent event, PathingBehavior behavior) { float partialTicks = event.getPartialTicks(); Goal goal = behavior.getGoal(); - if (Helper.mc.currentScreen instanceof GuiClick) { - ((GuiClick) Helper.mc.currentScreen).onRender(event.getModelViewStack(), event.getProjectionMatrix()); + if (Helper.mc.screen instanceof GuiClick) { + ((GuiClick) Helper.mc.screen).onRender(event.getModelViewStack(), event.getProjectionMatrix()); } - DimensionType thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimensionType(); - DimensionType currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().getDimensionType(); + DimensionType thisPlayerDimension = behavior.baritone.getPlayerContext().world().dimensionType(); + DimensionType currentRenderViewDimension = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world().dimensionType(); if (thisPlayerDimension != currentRenderViewDimension) { // this is a path for a bot in a different dimension, don't render it return; } - Entity renderView = Helper.mc.getRenderViewEntity(); + Entity renderView = Helper.mc.getCameraEntity(); if (renderView.level != BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().world()) { System.out.println("I have no idea what's going on"); @@ -188,7 +189,8 @@ public final class PathRenderer implements IRenderer, Helper { double vpZ = posZ(); boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value; - buffer.begin(renderPathAsFrickinThingy ? GL_LINE_STRIP : GL_LINES, DefaultVertexFormat.POSITION); + //TODO: check + buffer.begin(renderPathAsFrickinThingy ? VertexFormat.Mode.DEBUG_LINE_STRIP : VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION); buffer.vertex(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.5D - vpY), (float) (z1 + 0.5D - vpZ)).endVertex(); buffer.vertex(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.5D - vpY), (float) (z2 + 0.5D - vpZ)).endVertex(); @@ -249,7 +251,8 @@ public final class PathRenderer implements IRenderer, Helper { if (settings.renderGoalXZBeacon.value) { glPushAttrib(GL_LIGHTING_BIT); - Helper.mc.getTextureManager().bindTexture(TEXTURE_BEACON_BEAM); + //TODO: fix + Helper.mc.getTextureManager().bindForSetup(TEXTURE_BEACON_BEAM); if (settings.renderGoalIgnoreDepth.value) { RenderSystem.disableDepthTest(); } @@ -257,9 +260,10 @@ public final class PathRenderer implements IRenderer, Helper { stack.pushPose(); // push stack.translate(goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ); // translate + //TODO: check BeaconRenderer.renderBeaconBeam( stack, - mc.getRenderTypeBuffers().getBufferSource(), + mc.renderBuffers().bufferSource(), TEXTURE_BEACON_BEAM, partialTicks, 1.0F, @@ -320,7 +324,7 @@ public final class PathRenderer implements IRenderer, Helper { renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2); Matrix4f matrix4f = stack.last().pose(); - buffer.begin(GL_LINES, DefaultVertexFormat.POSITION); + buffer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION); buffer.vertex(matrix4f, (float) minX, (float) minY, (float) minZ).endVertex(); buffer.vertex(matrix4f, (float) minX, (float) maxY, (float) minZ).endVertex(); buffer.vertex(matrix4f, (float) maxX, (float) minY, (float) minZ).endVertex(); @@ -337,11 +341,13 @@ public final class PathRenderer implements IRenderer, Helper { private static void renderHorizontalQuad(PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) { if (y != 0) { Matrix4f matrix4f = stack.last().pose(); - buffer.begin(GL_LINE_LOOP, DefaultVertexFormat.POSITION); + //TODO: check + buffer.begin(VertexFormat.Mode.DEBUG_LINE_STRIP, DefaultVertexFormat.POSITION); buffer.vertex(matrix4f, (float) minX, (float) y, (float) minZ).endVertex(); buffer.vertex(matrix4f, (float) maxX, (float) y, (float) minZ).endVertex(); buffer.vertex(matrix4f, (float) maxX, (float) y, (float) maxZ).endVertex(); buffer.vertex(matrix4f, (float) minX, (float) y, (float) maxZ).endVertex(); + buffer.vertex(matrix4f, (float) minX, (float) y, (float) minZ).endVertex(); tessellator.end(); } } diff --git a/src/main/java/baritone/utils/ToolSet.java b/src/main/java/baritone/utils/ToolSet.java index 6dee9db9e..463037623 100644 --- a/src/main/java/baritone/utils/ToolSet.java +++ b/src/main/java/baritone/utils/ToolSet.java @@ -106,7 +106,7 @@ public class ToolSet { possible, this lets us make pathing depend on the actual tool to be used (if auto tool is disabled) */ if (Baritone.settings().disableAutoTool.value && pathingCalculation) { - return player.inventory.selected; + return player.getInventory().selected; } int best = 0; @@ -115,7 +115,7 @@ public class ToolSet { boolean bestSilkTouch = false; BlockState blockState = b.defaultBlockState(); for (int i = 0; i < 9; i++) { - ItemStack itemStack = player.inventory.getItem(i); + ItemStack itemStack = player.getInventory().getItem(i); double speed = calculateSpeedVsBlock(itemStack, blockState); boolean silkTouch = hasSilkTouch(itemStack); if (speed > highestSpeed) { @@ -144,7 +144,7 @@ public class ToolSet { * @return A double containing the destruction ticks with the best tool */ private double getBestDestructionTime(Block b) { - ItemStack stack = player.inventory.getItem(getBestSlot(b, false, true)); + ItemStack stack = player.getInventory().getItem(getBestSlot(b, false, true)); return calculateSpeedVsBlock(stack, b.defaultBlockState()) * avoidanceMultiplier(b); } diff --git a/src/main/java/baritone/utils/pathing/Avoidance.java b/src/main/java/baritone/utils/pathing/Avoidance.java index c9f3446e8..477ddf1ea 100644 --- a/src/main/java/baritone/utils/pathing/Avoidance.java +++ b/src/main/java/baritone/utils/pathing/Avoidance.java @@ -25,6 +25,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.monster.Spider; +import net.minecraft.world.entity.monster.ZombifiedPiglin; public class Avoidance { @@ -68,11 +72,11 @@ public class Avoidance { } if (mobCoeff != 1.0D) { ctx.entitiesStream() - .filter(entity -> entity instanceof MobEntity) - .filter(entity -> (!(entity instanceof SpiderEntity)) || ctx.player().getBrightness() < 0.5) - .filter(entity -> !(entity instanceof ZombifiedPiglinEntity) || ((ZombifiedPiglinEntity) entity).getRevengeTarget() != null) - .filter(entity -> !(entity instanceof EndermanEntity) || ((EndermanEntity) entity).isScreaming()) - .forEach(entity -> res.add(new Avoidance(entity.getPosition(), mobCoeff, Baritone.settings().mobAvoidanceRadius.value))); + .filter(entity -> entity instanceof Mob) + .filter(entity -> (!(entity instanceof Spider)) || ctx.player().getBrightness() < 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))); } return res; } diff --git a/src/main/java/baritone/utils/player/PrimaryPlayerContext.java b/src/main/java/baritone/utils/player/PrimaryPlayerContext.java index f3e25a7ab..0e9060379 100644 --- a/src/main/java/baritone/utils/player/PrimaryPlayerContext.java +++ b/src/main/java/baritone/utils/player/PrimaryPlayerContext.java @@ -49,7 +49,7 @@ public enum PrimaryPlayerContext implements IPlayerContext, Helper { @Override public Level world() { - return mc.world; + return mc.level; } @Override diff --git a/src/main/java/baritone/utils/player/PrimaryPlayerController.java b/src/main/java/baritone/utils/player/PrimaryPlayerController.java index d5412d501..bd91dc68b 100644 --- a/src/main/java/baritone/utils/player/PrimaryPlayerController.java +++ b/src/main/java/baritone/utils/player/PrimaryPlayerController.java @@ -28,7 +28,6 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.ClickType; -import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; @@ -46,52 +45,52 @@ public enum PrimaryPlayerController implements IPlayerController, Helper { @Override public void syncHeldItem() { - ((IPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); + ((IPlayerControllerMP) mc.gameMode).callSyncCurrentPlayItem(); } @Override public boolean hasBrokenBlock() { - return ((IPlayerControllerMP) mc.playerController).getCurrentBlock().getY() == -1; + return ((IPlayerControllerMP) mc.gameMode).getCurrentBlock().getY() == -1; } @Override public boolean onPlayerDamageBlock(BlockPos pos, Direction side) { - return mc.playerController.onPlayerDamageBlock(pos, side); + return mc.gameMode.continueDestroyBlock(pos, side); } @Override public void resetBlockRemoving() { - mc.playerController.resetBlockRemoving(); + mc.gameMode.stopDestroyBlock(); } @Override - public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player) { - return mc.playerController.windowClick(windowId, slotId, mouseButton, type, player); + public void windowClick(int windowId, int slotId, int mouseButton, ClickType type, Player player) { + mc.gameMode.handleInventoryMouseClick(windowId, slotId, mouseButton, type, player); } @Override public GameType getGameType() { - return mc.playerController.getCurrentGameType(); + return mc.gameMode.getPlayerMode(); } @Override public InteractionResult processRightClickBlock(LocalPlayer player, Level world, InteractionHand hand, BlockHitResult result) { // primaryplayercontroller is always in a ClientWorld so this is ok - return mc.playerController.func_217292_a(player, (ClientLevel) world, hand, result); + return mc.gameMode.useItemOn(player, (ClientLevel) world, hand, result); } @Override public InteractionResult processRightClick(LocalPlayer player, Level world, InteractionHand hand) { - return mc.playerController.processRightClick(player, world, hand); + return mc.gameMode.useItem(player, world, hand); } @Override public boolean clickBlock(BlockPos loc, Direction face) { - return mc.playerController.clickBlock(loc, face); + return mc.gameMode.startDestroyBlock(loc, face); } @Override public void setHittingBlock(boolean hittingBlock) { - ((IPlayerControllerMP) mc.playerController).setIsHittingBlock(hittingBlock); + ((IPlayerControllerMP) mc.gameMode).setIsHittingBlock(hittingBlock); } } diff --git a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java index cc66b1eaa..29daa04db 100644 --- a/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java +++ b/src/test/java/baritone/utils/pathing/BetterBlockPosTest.java @@ -51,30 +51,30 @@ public class BetterBlockPosTest { BlockPos pos = new BlockPos(1, 2, 3); BetterBlockPos better = new BetterBlockPos(1, 2, 3); assertEquals(pos, better); - assertEquals(pos.above(), better.up()); - assertEquals(pos.below(), better.down()); + assertEquals(pos.above(), better.above()); + assertEquals(pos.below(), better.below()); assertEquals(pos.north(), better.north()); assertEquals(pos.south(), better.south()); assertEquals(pos.east(), better.east()); assertEquals(pos.west(), better.west()); for (Direction dir : Direction.values()) { - assertEquals(pos.relative(dir), better.offset(dir)); + assertEquals(pos.relative(dir), better.relative(dir)); assertEquals(pos.relative(dir, 0), pos); - assertEquals(better.offset(dir, 0), better); + assertEquals(better.relative(dir, 0), better); for (int i = -10; i < 10; i++) { - assertEquals(pos.relative(dir, i), better.offset(dir, i)); + assertEquals(pos.relative(dir, i), better.relative(dir, i)); } - assertTrue(better.offset(dir, 0) == better); + assertTrue(better.relative(dir, 0) == better); } for (int i = -10; i < 10; i++) { - assertEquals(pos.above(i), better.up(i)); - assertEquals(pos.below(i), better.down(i)); + assertEquals(pos.above(i), better.above(i)); + assertEquals(pos.below(i), better.below(i)); assertEquals(pos.north(i), better.north(i)); assertEquals(pos.south(i), better.south(i)); assertEquals(pos.east(i), better.east(i)); assertEquals(pos.west(i), better.west(i)); } - assertTrue(better.offset(null, 0) == better); + assertTrue(better.relative((Direction) null, 0) == better); } public void benchOne() { @@ -97,7 +97,7 @@ public class BetterBlockPosTest { } long before2 = System.nanoTime() / 1000000L; for (int i = 0; i < 1000000; i++) { - pos2.up(); + pos2.above(); } long after2 = System.nanoTime() / 1000000L; System.out.println((after1 - before1) + " " + (after2 - before2)); @@ -127,11 +127,11 @@ public class BetterBlockPosTest { } long before2 = System.nanoTime() / 1000000L; for (int i = 0; i < 1000000; i++) { - pos2.up(0); - pos2.up(1); - pos2.up(2); - pos2.up(3); - pos2.up(4); + pos2.above(0); + pos2.above(1); + pos2.above(2); + pos2.above(3); + pos2.above(4); } long after2 = System.nanoTime() / 1000000L; System.out.println((after1 - before1) + " " + (after2 - before2));