Compare commits

...

33 Commits

Author SHA1 Message Date
ZacSharp
838e75f025 Merge branch '1.20.1' 1.20.2 2025-05-13 12:40:00 +02:00
ZacSharp
5f0527be71 Merge branch '1.19.4' into 1.20.1 2025-05-13 12:37:45 +02:00
ZacSharp
79f1503c8b Merge branch '1.20.1' into 1.20.2 2025-04-22 20:33:01 +02:00
ZacSharp
eace2ad161 Merge branch '1.19.4' into 1.20.1 2025-04-22 20:13:44 +02:00
leijurv
a223585daa Merge pull request #4205 from Jatc252/patch-1
Add issues link and link to Discord for ModMenu
2024-01-06 09:51:56 -10:00
Jack
163e97aad6 Add issues links and link to Discord for ModMenu 2023-11-23 20:36:51 +10:00
leijurv
a945cfaa3c Merge pull request #4172 from ZacSharp/1.20.2-update
Merge 1.19.4 into 1.20.2
2023-10-31 11:26:58 -07:00
ZacSharp
3a3b012199 Merge branch '1.19.4' into 1.20.2 2023-10-29 02:08:57 +01:00
leijurv
9bf890a7b6 Merge pull request #4136 from rfresh2/1.20.2
1.20.2
2023-09-27 22:23:00 -07:00
leijurv
e1e620a0d9 Merge pull request #4138 from rfresh2/fix-forge-1-20-1-crash
Fix forge 1.20.1 crash
2023-09-27 22:19:09 -07:00
rfresh2
f5d15927de 1.20.2 2023-09-24 15:44:15 -07:00
rfresh2
7902517663 fix forge mixin crash 2023-09-24 15:44:15 -07:00
rfresh2
4db988dbef fix forge mixin crash 2023-09-24 15:34:59 -07:00
Leijurv
97067b9078 Merge branch '1.19.4' into 1.20.1 2023-08-22 13:29:08 -07:00
Leijurv
3b30b06313 Merge branch '1.19.4' into 1.20.1 2023-08-20 13:37:07 -07:00
Leijurv
5a4500177d Merge branch '1.19.4' into 1.20.1 2023-08-20 11:54:08 -07:00
Leijurv
fa28a56e84 Merge branch '1.19.4' into 1.20.1 2023-08-18 18:20:38 -07:00
Leijurv
7668952ca8 Merge branch '1.19.4' into 1.20.1 2023-08-18 16:37:43 -07:00
Leijurv
b16590d504 Merge branch '1.20.1' of github.com:cabaletta/baritone into 1.20.1 2023-08-18 13:38:43 -07:00
Leijurv
51843f7074 Merge branch '1.19.4' into 1.20.1 2023-08-18 13:37:20 -07:00
leijurv
2821a2a0a7 Merge pull request #4078 from ZacSharp/1.20.1-update
Merge 1.19.4 into 1.20.1
2023-07-30 14:22:57 -07:00
ZacSharp
e0308dee49 Merge branch '1.19.4' into 1.20.1 2023-07-25 01:35:55 +02:00
Leijurv
7487b90d50 v1.10.1 2023-06-13 21:21:45 -07:00
leijurv
09554ab39d Merge pull request #3943 from wagyourtail/1.20/1.20
1.20
2023-06-13 20:53:05 -07:00
Wagyourtail
2ae7bc6a64 bump unimined to latest stable 2023-06-13 19:42:16 -06:00
Wagyourtail
6979bd6971 support both 2023-06-13 19:42:08 -06:00
Wagyourtail
b2bd025896 1.20.1 2023-06-13 19:32:55 -06:00
Wagyourtail
666a890088 fix frog 2023-06-11 16:46:15 -06:00
Wagyourtail
b389b573e5 add frog 2023-06-09 08:27:38 -06:00
Wagyourtail
eb28298983 confirm release version works 2023-06-07 17:03:21 -06:00
Wagyourtail
336b2c2798 pre.7 2023-05-31 07:54:16 -04:00
Wagyourtail
63d0064d69 pre.2 2023-05-18 22:37:07 -06:00
Wagyourtail
43eb4e3581 prepare for 1.20 2023-05-10 16:17:40 -06:00
31 changed files with 119 additions and 240 deletions

View File

@@ -38,7 +38,7 @@ allprojects {
group = rootProject.maven_group
sourceCompatibility = targetCompatibility = JavaVersion.toVersion(project.java_version)
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(sourceCompatibility.majorVersion.toInteger()))
@@ -90,7 +90,7 @@ allprojects {
mappings {
intermediary()
mojmap()
parchment("2023.06.26")
parchment("2023.10.22")
}
}

View File

@@ -12,7 +12,7 @@
"contact": {
"homepage": "https://github.com/cabaletta/baritone",
"sources": "https://github.com/cabaletta/baritone",
"issues": "https://github.com/cabaletta/baritone/issues"
"issues": "https://github.com/cabaletta/baritone/issues"
},
"license": "LGPL-3.0",
@@ -26,8 +26,8 @@
],
"depends": {
"fabricloader": ">=0.11.0",
"minecraft": "1.19.4"
"fabricloader": ">=0.14.22",
"minecraft": "1.20.2"
},
"custom": {
"modmenu": {

View File

@@ -6,7 +6,7 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[33,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[48,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license="https://raw.githubusercontent.com/cabaletta/baritone/1.16.2/LICENSE"
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.19.4]"
versionRange="[1.20.2]"
ordering="NONE"
side="BOTH"

View File

@@ -1,16 +1,18 @@
org.gradle.jvmargs=-Xmx4G
mod_version=1.9.3
available_loaders=fabric,forge,tweaker
mod_version=1.10.2
maven_group=baritone
archives_base_name=baritone
java_version=17
minecraft_version=1.19.4
minecraft_version=1.20.2
forge_version=45.0.43
forge_version=48.0.1
fabric_version=0.14.11
fabric_version=0.14.22
nether_pathfinder_version=1.4.1

View File

@@ -42,9 +42,6 @@ pluginManagement {
rootProject.name = 'baritone'
include("tweaker")
if (System.getProperty("Baritone.enabled_platforms") == null) {
System.setProperty("Baritone.enabled_platforms", "fabric,forge")
}
for (platform in System.getProperty("Baritone.enabled_platforms").split(",")) {
for (platform in available_loaders.split(",")) {
include(platform)
}

View File

@@ -28,12 +28,13 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.packs.*;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.server.packs.resources.ReloadableResourceManager;
import net.minecraft.util.RandomSource;
import net.minecraft.util.Unit;
import net.minecraft.world.RandomSequences;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -47,24 +48,18 @@ import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.ServerLevelData;
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.level.storage.loot.LootDataManager;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import sun.misc.Unsafe;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.regex.Matcher;
@@ -78,10 +73,9 @@ public final class BlockOptionalMeta {
private final Block block;
private final String propertiesDescription; // exists so toString() can return something more useful than a list of all blockstates
private final Set<BlockState> blockstates;
private final Set<Integer> stateHashes;
private final Set<Integer> stackHashes;
private static LootTables lootTables;
private static PredicateManager predicate = new PredicateManager();
private final ImmutableSet<Integer> stateHashes;
private final ImmutableSet<Integer> stackHashes;
private static LootDataManager lootTables;
private static Map<Block, List<Item>> drops = new HashMap<>();
public BlockOptionalMeta(@Nonnull Block block) {
@@ -224,11 +218,11 @@ public final class BlockOptionalMeta {
return null;
}
public static LootTables getManager() {
public static LootDataManager getManager() {
if (lootTables == null) {
MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack()));
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
lootTables = new LootTables(predicate);
lootTables = new LootDataManager();
resourceManager.registerReloadListener(lootTables);
try {
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get();
@@ -240,10 +234,6 @@ public final class BlockOptionalMeta {
return lootTables;
}
public static PredicateManager getPredicateManager() {
return predicate;
}
private static synchronized List<Item> drops(Block b) {
return drops.computeIfAbsent(b, block -> {
ResourceLocation lootTableLocation = block.getLootTable();
@@ -252,15 +242,18 @@ public final class BlockOptionalMeta {
} else {
List<Item> items = new ArrayList<>();
try {
getManager().get(lootTableLocation).getRandomItems(
new LootContext.Builder(ServerLevelStub.fastCreate())
.withRandom(RandomSource.create())
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
.create(LootContextParamSets.BLOCK),
stack -> items.add(stack.getItem())
getManager().getLootTable(lootTableLocation).getRandomItemsRaw(
new LootContext.Builder(
new LootParams.Builder(ServerLevelStub.fastCreate())
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
.create(LootContextParamSets.BLOCK)
).withOptionalRandomSeed(1L)
.create(null),
stack -> items.add(stack.getItem())
);
} catch (Exception e) {
e.printStackTrace();
@@ -273,8 +266,9 @@ public final class BlockOptionalMeta {
private static class ServerLevelStub extends ServerLevel {
private static Minecraft client = Minecraft.getInstance();
private static Unsafe unsafe = getUnsafe();
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10) {
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10);
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10, @Nullable RandomSequences $$11) {
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11);
}
@Override

View File

@@ -59,7 +59,7 @@ public final class RayTraceUtils {
direction.y * blockReachDistance,
direction.z * blockReachDistance
);
return entity.level.clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
return entity.level().clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity));
}
public static Vec3 inferSneakingEyePosition(Entity entity) {

View File

@@ -283,7 +283,7 @@ public final class RotationUtils {
if (((BlockHitResult) result).getBlockPos().equals(pos)) {
return Optional.of(rotation);
}
if (entity.level.getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
if (entity.level().getBlockState(pos).getBlock() instanceof BaseFireBlock && ((BlockHitResult) result).getBlockPos().equals(pos.below())) {
return Optional.of(rotation);
}
}
@@ -292,6 +292,6 @@ public final class RotationUtils {
@Deprecated
public static Optional<Rotation> reachableCenter(Entity entity, BlockPos pos, double blockReachDistance, boolean wouldSneak) {
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level, pos), blockReachDistance, wouldSneak);
return reachableOffset(entity, pos, VecUtils.calculateBlockCenter(entity.level(), pos), blockReachDistance, wouldSneak);
}
}

View File

@@ -20,6 +20,7 @@ package baritone.api.utils.gui;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import net.minecraft.network.chat.Component;
@@ -38,7 +39,7 @@ public class BaritoneToast implements Toast {
this.totalShowTime = totalShowTime;
}
public Visibility render(PoseStack matrixStack, ToastComponent toastGui, long delta) {
public Visibility render(GuiGraphics gui, ToastComponent toastGui, long delta) {
if (this.newDisplay) {
this.firstDrawTime = delta;
this.newDisplay = false;
@@ -46,15 +47,13 @@ public class BaritoneToast implements Toast {
//TODO: check
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);
gui.blit(new ResourceLocation("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
if (this.subtitle == null) {
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 12, -11534256);
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256);
} else {
toastGui.getMinecraft().font.draw(matrixStack, this.title, 18, 7, -11534256);
toastGui.getMinecraft().font.draw(matrixStack, this.subtitle, 18, 18, -16777216);
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 7, -11534256);
gui.drawString(toastGui.getMinecraft().font, this.subtitle, 18, 18, -16777216);
}
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;

View File

@@ -27,15 +27,16 @@ import baritone.api.event.events.type.EventState;
import baritone.api.utils.Pair;
import baritone.cache.CachedChunk;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.multiplayer.CommonListenerCookie;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.*;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -48,7 +49,7 @@ import java.util.List;
* @since 8/3/2018
*/
@Mixin(ClientPacketListener.class)
public class MixinClientPlayNetHandler {
public abstract class MixinClientPlayNetHandler extends ClientCommonPacketListenerImpl {
// unused lol
/*@Inject(
@@ -74,9 +75,9 @@ public class MixinClientPlayNetHandler {
}
}*/
@Shadow
@Final
private Minecraft minecraft;
protected MixinClientPlayNetHandler(final Minecraft arg, final Connection arg2, final CommonListenerCookie arg3) {
super(arg, arg2, arg3);
}
@Inject(
method = "sendChat(Ljava/lang/String;)V",
@@ -124,7 +125,7 @@ public class MixinClientPlayNetHandler {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.pos().x, packet.pos().z)
);
}
}
@@ -139,7 +140,7 @@ public class MixinClientPlayNetHandler {
LocalPlayer player = ibaritone.getPlayerContext().player();
if (player != null && player.connection == (ClientPacketListener) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.pos().x, packet.pos().z)
);
}
}

View File

@@ -50,7 +50,7 @@ public abstract class MixinFireworkRocketEntity extends Entity implements IFirew
@Override
public LivingEntity getBoostedEntity() {
if (this.isAttachedToEntity() && this.attachedToEntity == null) { // isAttachedToEntity checks if the optional is present
final Entity entity = this.level.getEntity(this.entityData.get(DATA_ATTACHED_TO_TARGET).getAsInt());
final Entity entity = this.level().getEntity(this.entityData.get(DATA_ATTACHED_TO_TARGET).getAsInt());
if (entity instanceof LivingEntity) {
this.attachedToEntity = (LivingEntity) entity;
}

View File

@@ -21,8 +21,7 @@ import baritone.api.utils.BlockOptionalMeta;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.level.storage.loot.LootDataManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@@ -48,27 +47,13 @@ public class MixinLootContext {
method = "create",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getLootTables()Lnet/minecraft/world/level/storage/loot/LootTables;"
target = "Lnet/minecraft/server/MinecraftServer;getLootData()Lnet/minecraft/world/level/storage/loot/LootDataManager;"
)
)
private LootTables getLootTableManager(MinecraftServer server) {
private LootDataManager getLootTableManager(MinecraftServer server) {
if (server == null) {
return BlockOptionalMeta.getManager();
}
return server.getLootTables();
}
@Redirect(
method = "create",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/MinecraftServer;getPredicateManager()Lnet/minecraft/world/level/storage/loot/PredicateManager;"
)
)
private PredicateManager getLootPredicateManager(MinecraftServer server) {
if (server == null) {
return BlockOptionalMeta.getPredicateManager();
}
return server.getPredicateManager();
return server.getLootData();
}
}

View File

@@ -167,12 +167,26 @@ public class MixinMinecraft {
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/gui/screens/Screen;passEvents:Z"
target = "Lnet/minecraft/client/Minecraft;screen:Lnet/minecraft/client/gui/screens/Screen;"
),
slice = @Slice(
from = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/Options;renderDebug:Z"
),
to = @At(
value = "CONSTANT",
args = "stringValue=Keybindings"
)
)
)
private boolean passEvents(Screen screen) {
private Screen passEvents(Minecraft instance) {
// allow user input is only the primary baritone
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) || screen.passEvents;
if (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && player != null) {
return null;
}
return instance.screen;
}
// TODO

View File

@@ -23,8 +23,6 @@ import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.type.EventState;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
@@ -54,7 +52,7 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("HEAD")
)
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, boolean flush, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
return;
}
@@ -70,7 +68,7 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("RETURN")
)
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, CallbackInfo ci) {
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, boolean flush, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
return;
}

View File

@@ -423,7 +423,7 @@ 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.below())) {
if (ctx.player().isOnGround()) {
if (ctx.player().onGround()) {
double playerX = ctx.player().position().x;
double playerZ = ctx.player().position().z;
ArrayList<BetterBlockPos> closest = new ArrayList<>();

View File

@@ -162,26 +162,26 @@ public enum FasterWorldScanner implements IWorldScanner {
}
private List<BlockPos> collectChunkSections(BlockOptionalMetaLookup lookup, LevelChunk chunk, long chunkX, long chunkZ, int playerSection) {
// iterate over sections relative to player
List<BlockPos> blocks = new ArrayList<>();
int chunkY = chunk.getMinBuildHeight();
LevelChunkSection[] sections = chunk.getSections();
int l = sections.length;
int i = playerSection - 1;
int j = playerSection;
for (; i >= 0 || j < l; ++j, --i) {
if (j < l) {
visitSection(lookup, sections[j], blocks, chunkX, chunkZ);
visitSection(lookup, sections[j], blocks, chunkX, chunkY + j * 16, chunkZ);
}
if (i >= 0) {
visitSection(lookup, sections[i], blocks, chunkX, chunkZ);
visitSection(lookup, sections[i], blocks, chunkX, chunkY + i * 16, chunkZ);
}
}
return blocks;
}
private void visitSection(BlockOptionalMetaLookup lookup, LevelChunkSection section, List<BlockPos> blocks, long chunkX, long chunkZ) {
private void visitSection(BlockOptionalMetaLookup lookup, LevelChunkSection section, List<BlockPos> blocks, long chunkX, int sectionY, long chunkZ) {
if (section == null || section.hasOnlyAir()) {
return;
}
@@ -192,7 +192,6 @@ public enum FasterWorldScanner implements IWorldScanner {
return;
}
int yOffset = section.bottomBlockY();
Palette<BlockState> palette = ((IPalettedContainer<BlockState>) sectionContainer).getPalette();
if (palette instanceof SingleValuePalette) {
@@ -204,7 +203,7 @@ public enum FasterWorldScanner implements IWorldScanner {
for (int z = 0; z < 16; ++z) {
blocks.add(new BlockPos(
(int) chunkX + x,
yOffset + y,
sectionY + y,
(int) chunkZ + z
));
}
@@ -233,7 +232,7 @@ public enum FasterWorldScanner implements IWorldScanner {
//noinspection DuplicateExpressions
blocks.add(new BlockPos(
(int) chunkX + ((idx & 255) & 15),
yOffset + (idx >> 8),
sectionY + (idx >> 8),
(int) chunkZ + ((idx & 255) >> 4)
));
}

View File

@@ -140,7 +140,7 @@ public class WorldProvider implements IWorldProvider {
String folderName;
final ServerData serverData = ctx.minecraft().getCurrentServer();
if (serverData != null) {
folderName = ctx.minecraft().isConnectedToRealms() ? "realms" : serverData.ip;
folderName = serverData.isRealm() ? "realms" : serverData.ip;
} else {
//replaymod causes null currentServer and false singleplayer.
System.out.println("World seems to be a replay. Not loading Baritone cache.");

View File

@@ -43,7 +43,6 @@ import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.WaterFluid;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.BlockHitResult;
@@ -327,7 +326,7 @@ public interface MovementHelper extends ActionCosts, Helper {
if (block == Blocks.LARGE_FERN || block == Blocks.TALL_GRASS) {
return true;
}
return state.getMaterial().isReplaceable();
return state.canBeReplaced();
}
@Deprecated
@@ -511,14 +510,14 @@ public interface MovementHelper extends ActionCosts, Helper {
static boolean canUseFrostWalker(CalculationContext context, BlockState state) {
return context.frostWalker != 0
&& state.getMaterial() == Material.WATER
&& state == FrostedIceBlock.meltsInto()
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
}
static boolean canUseFrostWalker(IPlayerContext ctx, BlockPos pos) {
BlockState state = BlockStateInterface.get(ctx, pos);
return EnchantmentHelper.hasFrostWalker(ctx.player())
&& state.getMaterial() == Material.WATER
&& state == FrostedIceBlock.meltsInto()
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
}

View File

@@ -100,7 +100,7 @@ public class MovementFall extends Movement {
return state.setStatus(MovementStatus.UNREACHABLE);
}
if (ctx.player().position().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().isOnGround()) {
if (ctx.player().position().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().onGround()) {
ctx.player().getInventory().selected = ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_WATER);
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
@@ -135,7 +135,7 @@ 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().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) {
if (!ctx.player().onGround() && Math.abs(ctx.player().getDeltaMovement().y) > 0.4) {
state.setInput(Input.SNEAK, true);
}
state.setInput(Input.MOVE_FORWARD, true);
@@ -147,7 +147,7 @@ public class MovementFall extends Movement {
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()) {
} else if (!ctx.player().onGround()) {
state.setInput(Input.SNEAK, false);
}
}

View File

@@ -278,7 +278,7 @@ public class MovementParkour extends Movement {
if (Baritone.settings().allowPlace.value // see PR #3775
&& ((Baritone) baritone).getInventoryBehavior().hasGenericThrowaway()
&& !MovementHelper.canWalkOn(ctx, dest.below())
&& !ctx.player().isOnGround()
&& !ctx.player().onGround()
&& 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

View File

@@ -32,14 +32,7 @@ import baritone.pathing.movement.MovementState;
import baritone.utils.BlockStateInterface;
import com.google.common.collect.ImmutableSet;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.CarpetBlock;
import net.minecraft.world.level.block.FallingBlock;
import net.minecraft.world.level.block.FenceGateBlock;
import net.minecraft.world.level.block.LadderBlock;
import net.minecraft.world.level.block.SlabBlock;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.SlabType;
import net.minecraft.world.phys.Vec3;
@@ -256,7 +249,7 @@ public class MovementPillar extends Movement {
BlockState frState = BlockStateInterface.get(ctx, src);
Block fr = frState.getBlock();
// TODO: Evaluate usage of getMaterial().isReplaceable()
if (!(fr instanceof AirBlock || frState.getMaterial().isReplaceable())) {
if (!(fr instanceof AirBlock || frState.canBeReplaced())) {
RotationUtils.reachable(ctx, src, ctx.playerController().getBlockReachDistance())
.map(rot -> new MovementState.MovementTarget(rot, true))
.ifPresent(state::setTarget);

View File

@@ -261,7 +261,7 @@ public class MovementTraverse extends Movement {
}
Block low = BlockStateInterface.get(ctx, src).getBlock();
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)) {
if (ctx.player().position().y > src.y + 0.1D && !ctx.player().onGround() && (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;

View File

@@ -272,7 +272,7 @@ public class PathExecutor implements IPathExecutor, Helper {
if (!current.isPresent()) {
return false;
}
if (!ctx.player().isOnGround()) {
if (!ctx.player().onGround()) {
return false;
}
if (!MovementHelper.canWalkOn(ctx, ctx.playerFeet().below())) {
@@ -321,7 +321,7 @@ public class PathExecutor implements IPathExecutor, Helper {
* @return Whether or not it was possible to snap to the current player feet
*/
public boolean snipsnapifpossible() {
if (!ctx.player().isOnGround() && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
if (!ctx.player().onGround() && ctx.world().getFluidState(ctx.playerFeet()).isEmpty()) {
// if we're falling in the air, and not in water, don't splice
return false;
} else {

View File

@@ -545,7 +545,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
Optional<Tuple<BetterBlockPos, Rotation>> toBreak = toBreakNearPlayer(bcc);
if (toBreak.isPresent() && isSafeToCancel && ctx.player().isOnGround()) {
if (toBreak.isPresent() && isSafeToCancel && ctx.player().onGround()) {
// we'd like to pause to break this block
// only change look direction if it's safe (don't want to fuck up an in progress parkour for example
Rotation rot = toBreak.get().getB();
@@ -565,7 +565,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
}
List<BlockState> desirableOnHotbar = new ArrayList<>();
Optional<Placement> toPlace = searchForPlacables(bcc, desirableOnHotbar);
if (toPlace.isPresent() && isSafeToCancel && ctx.player().isOnGround() && ticks <= 0) {
if (toPlace.isPresent() && isSafeToCancel && ctx.player().onGround() && ticks <= 0) {
Rotation rot = toPlace.get().rot;
baritone.getLookBehavior().updateTarget(rot, true);
ctx.player().getInventory().selected = toPlace.get().hotbarSelection;

View File

@@ -204,7 +204,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
}
if (this.state == State.FLYING || this.state == State.START_FLYING) {
this.state = ctx.player().isOnGround() && Baritone.settings().elytraAutoJump.value
this.state = ctx.player().onGround() && Baritone.settings().elytraAutoJump.value
? State.LOCATE_JUMP
: State.START_FLYING;
}
@@ -322,7 +322,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
}
private void pathTo0(BlockPos destination, boolean appendDestination) {
if (ctx.player() == null || ctx.player().level.dimension() != Level.NETHER) {
if (ctx.player() == null || ctx.player().level().dimension() != Level.NETHER) {
return;
}
this.onLostControl();

View File

@@ -260,7 +260,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().random, pos, state)) {
if (ig.isValidBonemealTarget(ctx.world(), pos, state) && ig.isBonemealSuccess(ctx.world(), ctx.world().random, pos, state)) {
bonemealable.add(pos);
}
}
@@ -376,7 +376,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
}
}
for (Entity entity : ctx.entities()) {
if (entity instanceof ItemEntity && entity.isOnGround()) {
if (entity instanceof ItemEntity && entity.onGround()) {
ItemEntity ei = (ItemEntity) entity;
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
// +0.1 because of farmland's 0.9375 dummy height lol

View File

@@ -120,7 +120,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
.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().above()::distSqr));
baritone.getInputOverrideHandler().clearAllKeys();
if (shaft.isPresent() && ctx.player().isOnGround()) {
if (shaft.isPresent() && ctx.player().onGround()) {
BlockPos pos = shaft.get();
BlockState state = baritone.bsi.get0(pos);
if (!MovementHelper.avoidBreaking(baritone.bsi, pos.getX(), pos.getY(), pos.getZ(), state)) {

View File

@@ -25,6 +25,7 @@ import baritone.api.event.events.*;
import baritone.api.pathing.goals.GoalBlock;
import baritone.api.utils.*;
import baritone.api.utils.input.Input;
import baritone.pathing.movement.MovementHelper;
import baritone.process.ElytraProcess;
import baritone.utils.BlockStateInterface;
import baritone.utils.IRenderer;
@@ -45,9 +46,10 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.block.AirBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkSource;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
@@ -1264,8 +1266,8 @@ public final class ElytraBehavior implements Helper {
private boolean passable(int x, int y, int z, boolean ignoreLava) {
if (ignoreLava) {
final Material mat = this.bsi.get0(x, y, z).getMaterial();
return mat == Material.AIR || mat == Material.LAVA;
final BlockState state = this.bsi.get0(x, y, z);
return state.getBlock() instanceof AirBlock || MovementHelper.isLava(state);
} else {
return !this.boi.get0(x, y, z);
}

View File

@@ -24,6 +24,7 @@ import baritone.api.utils.BetterBlockPos;
import baritone.api.utils.Helper;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.GameRenderer;
@@ -62,7 +63,7 @@ public class GuiClick extends Screen implements Helper {
}
@Override
public void render(PoseStack stack, int mouseX, int mouseY, float partialTicks) {
public void render(GuiGraphics stack, int mouseX, int mouseY, float partialTicks) {
double mx = mc.mouseHandler.xpos();
double my = mc.mouseHandler.ypos();
@@ -75,7 +76,7 @@ public class GuiClick extends Screen implements Helper {
if (near != null && far != null) {
Vec3 viewerPos = new Vec3(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ());
LocalPlayer player = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().player();
HitResult result = player.level.clip(new ClipContext(near.add(viewerPos), far.add(viewerPos), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
HitResult result = player.level().clip(new ClipContext(near.add(viewerPos), far.add(viewerPos), ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player));
if (result != null && result.getType() == HitResult.Type.BLOCK) {
currentMouseOver = ((BlockHitResult) result).getBlockPos();
}

View File

@@ -209,7 +209,7 @@ public final class PathRenderer implements IRenderer {
positions.forEach(pos -> {
BlockState state = bsi.get0(pos);
VoxelShape shape = state.getShape(player.level, pos);
VoxelShape shape = state.getShape(player.level(), pos);
AABB toDraw = shape.isEmpty() ? Shapes.block().bounds() : shape.bounds();
toDraw = toDraw.move(pos);
IRenderer.emitAABB(stack, toDraw, .002D);

View File

@@ -1,105 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch;
import com.google.common.base.Strings;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.Agent;
import com.mojang.authlib.exceptions.AuthenticationException;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
import net.minecraft.launchwrapper.Launch;
import java.io.File;
import java.lang.reflect.Field;
import java.net.Proxy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Based on GradleStart from ForgeGradle 2.3
*
* @author Brady
* @since 3/11/2019
*/
public class LaunchTesting {
public static void main(String[] args) {
Map<String, String> arguments = new HashMap<>();
hackNatives();
arguments.put("version", "BaritownedDeveloperEnvironment");
arguments.put("assetIndex", System.getenv("assetIndex"));
arguments.put("assetsDir", System.getenv().getOrDefault("assetDirectory", "assets"));
arguments.put("accessToken", "FML");
arguments.put("userProperties", "{}");
arguments.put("tweakClass", System.getenv("tweakClass"));
String password = System.getenv("password");
if (password != null && !password.isEmpty()) {
attemptLogin(arguments, System.getenv("username"), System.getenv("password"));
}
List<String> argsArray = new ArrayList<>();
arguments.forEach((k, v) -> {
argsArray.add("--" + k);
argsArray.add(v);
});
Launch.main(argsArray.toArray(new String[0]));
}
private static void hackNatives() {
String paths = System.getProperty("java.library.path");
String nativesDir = System.getenv().get("nativesDirectory");
if (Strings.isNullOrEmpty(paths))
paths = nativesDir;
else
paths += File.pathSeparator + nativesDir;
System.setProperty("java.library.path", paths);
// hack the classloader now.
try {
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
sysPathsField.setAccessible(true);
sysPathsField.set(null, null);
} catch (Throwable ignored) {}
}
private static void attemptLogin(Map<String, String> argMap, String username, String password) {
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) (new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1")).createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(username);
auth.setPassword(password);
try {
auth.logIn();
} catch (AuthenticationException var4) {
throw new RuntimeException(var4);
}
argMap.put("accessToken", auth.getAuthenticatedToken());
argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
argMap.put("username", auth.getSelectedProfile().getName());
argMap.put("userType", auth.getUserType().getName());
argMap.put("userProperties", (new GsonBuilder()).registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
}
}