Compare commits

...

16 Commits

Author SHA1 Message Date
ZacSharp
a99e25eb8d v1.13.1 2025-08-27 00:33:00 +02:00
ZacSharp
3fdb743836 Merge branch '1.21.3' into 1.21.4 2025-05-13 18:23:21 +02:00
ZacSharp
6b9fb07cd9 Merge branch '1.21.1' into 1.21.3 2025-05-13 18:11:38 +02:00
leijurv
561a4d2634 Merge pull request #4728 from ZacSharp/pr/1.21.4/elytra/fixTakeoff
Fix elytra takeoff on 1.21.4
2025-05-04 18:44:55 -07:00
ZacSharp
d927cc7b44 Fix elytra takeoff 2025-04-27 18:18:45 +02:00
ZacSharp
c630969aa5 Merge branch '1.21.3' into 1.21.4 2025-04-23 00:34:38 +02:00
ZacSharp
ce6079c203 Merge branch '1.21.1' into 1.21.3 2025-04-23 00:29:01 +02:00
leijurv
a0f100f473 Merge pull request #4599 from ZacSharp/1.21.4-update
Merge 1.21.1 into 1.21.4
2025-01-02 18:09:25 -10:00
ZacSharp
94a677f239 Merge branch '1.21.1' into 1.21.4 2024-12-31 18:16:59 +01:00
leijurv
485bec0572 Merge pull request #4576 from rfresh2/1.21.4
1.21.4
2024-12-08 00:34:54 -07:00
rfresh2
9324fb7d24 1.21.4 2024-12-06 23:29:00 -08:00
Leijurv
9d5db72806 v1.11.1 2024-11-20 01:10:40 -08:00
leijurv
b14c75804d Merge pull request #4536 from rfresh2/1.21.3
1.21.3
2024-11-05 21:37:50 -08:00
rfresh2
fd4fbf5df5 update forge and resolve rebase conflicts 2024-10-30 20:44:51 -07:00
rfresh2
7e8c8501a7 restore tool getMaterialCost intended functionality 2024-10-30 20:34:16 -07:00
rfresh2
55cb180755 1.21.3 2024-10-30 20:34:12 -07:00
30 changed files with 151 additions and 175 deletions

View File

@@ -26,7 +26,7 @@
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": ["1.21","1.21.1"]
"minecraft": ["1.21.4"]
},
"custom": {
"modmenu": {

View File

@@ -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.21, 1.21.1]"
versionRange="[1.21.4]"
ordering="NONE"
side="BOTH"

View File

@@ -2,19 +2,19 @@ org.gradle.jvmargs=-Xmx4G
available_loaders=fabric,forge,neoforge,tweaker
mod_version=1.11.0
mod_version=1.13.1
maven_group=baritone
archives_base_name=baritone
java_version=21
minecraft_version=1.21
minecraft_version=1.21.4
forge_version=51.0.16
forge_version=54.0.5
neoforge_version=20-beta
neoforge_version=9-beta
fabric_version=0.15.11
fabric_version=0.16.9
nether_pathfinder_version=1.4.1

View File

@@ -26,7 +26,7 @@ archivesBaseName = archivesBaseName + "-neoforge"
unimined.minecraft {
neoForged {
neoForge {
loader project.neoforge_version
mixinConfig ["mixins.baritone.json"]
}

View File

@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
modId="minecraft"
type="required"
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.21,1.21.1]"
versionRange="[1.21.4]"
ordering="NONE"
side="BOTH"

View File

@@ -673,13 +673,6 @@ public final class Settings {
*/
public final Setting<Boolean> logAsToast = new Setting<>(false);
/**
* The time of how long the message in the pop-up will display
* <p>
* If below 1000L (1sec), it's better to disable this
*/
public final Setting<Long> toastTimer = new Setting<>(5000L);
/**
* Print all the debug messages to chat
*/

View File

@@ -157,7 +157,7 @@ public final class BetterBlockPos extends BlockPos {
@Override
public BetterBlockPos relative(Direction dir) {
Vec3i vec = dir.getNormal();
Vec3i vec = dir.getUnitVec3i();
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
}
@@ -166,7 +166,7 @@ public final class BetterBlockPos extends BlockPos {
if (dist == 0) {
return this;
}
Vec3i vec = dir.getNormal();
Vec3i vec = dir.getUnitVec3i();
return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist);
}

View File

@@ -21,32 +21,26 @@ import baritone.api.utils.accessor.IItemStack;
import baritone.api.utils.accessor.ILootTable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.commands.Commands;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.LayeredRegistryAccess;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.RegistryDataLoader;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.RegistryLayer;
import net.minecraft.server.ReloadableServerRegistries;
import net.minecraft.server.ReloadableServerResources;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.progress.ChunkProgressListener;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.VanillaPackResources;
import net.minecraft.server.packs.repository.BuiltInPackSource;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackRepository;
import net.minecraft.server.packs.repository.ServerPacksSource;
import net.minecraft.server.packs.resources.CloseableResourceManager;
import net.minecraft.server.packs.resources.MultiPackResourceManager;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.tags.TagLoader;
import net.minecraft.world.RandomSequences;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@@ -58,7 +52,6 @@ import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.dimension.LevelStem;
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.LootParams;
import net.minecraft.world.level.storage.loot.LootTable;
@@ -231,8 +224,8 @@ public final class BlockOptionalMeta {
private static synchronized List<Item> drops(Block b) {
return drops.computeIfAbsent(b, block -> {
ResourceLocation lootTableLocation = block.getLootTable().location();
if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) {
Optional<ResourceKey<LootTable>> optionalLootTableKey = block.getLootTable();
if (optionalLootTableKey.isEmpty()) {
return Collections.emptyList();
} else {
List<Item> items = new ArrayList<>();
@@ -253,13 +246,13 @@ public final class BlockOptionalMeta {
}
private static List<ItemStack> getDrops(Block state, LootParams.Builder params) {
ResourceKey<LootTable> lv = state.getLootTable();
if (lv == BuiltInLootTables.EMPTY) {
Optional<ResourceKey<LootTable>> lv = state.getLootTable();
if (lv.isEmpty()) {
return Collections.emptyList();
} else {
LootParams lv2 = params.withParameter(LootContextParams.BLOCK_STATE, state.defaultBlockState()).create(LootContextParamSets.BLOCK);
ServerLevelStub lv3 = (ServerLevelStub) lv2.getLevel();
LootTable lv4 = lv3.holder().getLootTable(lv);
LootTable lv4 = lv3.holder().getLootTable(lv.get());
return((ILootTable) lv4).invokeGetRandomItems(new LootContext.Builder(lv2).withOptionalRandomSeed(1).create(null));
}
}
@@ -307,44 +300,33 @@ public final class BlockOptionalMeta {
}
public static CompletableFuture<RegistryAccess> load() {
PackRepository packRepository = Minecraft.getInstance().getResourcePackRepository();
// Simplified from {@link net.minecraft.server.WorldLoader#load()}
CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(
PackType.SERVER_DATA,
List.of(packRepository.getPack(BuiltInPackSource.VANILLA_ID).open())
List.of(ServerPacksSource.createVanillaPackSource())
);
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = loadAndReplaceLayer(
closeableResourceManager, RegistryLayer.createRegistryAccess(), RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES
LayeredRegistryAccess<RegistryLayer> baseLayeredRegistry = RegistryLayer.createRegistryAccess();
List<Registry.PendingTags<?>> pendingTags = TagLoader.loadTagsForExistingRegistries(
closeableResourceManager, baseLayeredRegistry.getLayer(RegistryLayer.STATIC)
);
return ReloadableServerResources.loadResources(
closeableResourceManager,
List<HolderLookup.RegistryLookup<?>> worldGenRegistryLookupList = TagLoader.buildUpdatedLookups(
baseLayeredRegistry.getAccessForLoading(RegistryLayer.WORLDGEN),
pendingTags
);
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = baseLayeredRegistry.replaceFrom(
RegistryLayer.WORLDGEN,
RegistryDataLoader.load(
closeableResourceManager,
worldGenRegistryLookupList,
RegistryDataLoader.WORLDGEN_REGISTRIES
)
);
return ReloadableServerRegistries.reload(
layeredRegistryAccess,
FeatureFlags.VANILLA_SET,
Commands.CommandSelection.INTEGRATED,
2,
Runnable::run,
pendingTags,
closeableResourceManager,
Minecraft.getInstance()
).thenApply(reloadableServerResources -> reloadableServerResources.fullRegistries().get());
).thenApply(r -> r.layers().compositeAccess());
}
private static LayeredRegistryAccess<RegistryLayer> loadAndReplaceLayer(
ResourceManager resourceManager,
LayeredRegistryAccess<RegistryLayer> registryAccess,
RegistryLayer registryLayer,
List<RegistryDataLoader.RegistryData<?>> registryData
) {
RegistryAccess.Frozen frozen = loadLayer(resourceManager, registryAccess, registryLayer, registryData);
return registryAccess.replaceFrom(registryLayer, frozen);
}
private static RegistryAccess.Frozen loadLayer(
ResourceManager resourceManager,
LayeredRegistryAccess<RegistryLayer> registryAccess,
RegistryLayer registryLayer,
List<RegistryDataLoader.RegistryData<?>> registryData
) {
RegistryAccess.Frozen frozen = registryAccess.getAccessForLoading(registryLayer);
return RegistryDataLoader.load(resourceManager, frozen, registryData);
}
}
}

View File

@@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI;
import baritone.api.Settings;
import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
@@ -245,8 +246,8 @@ public class SettingsUtil {
BlockUtils::blockToString
),
ITEM(
Item.class,
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
Item.class,
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())).map(Holder.Reference::value).orElse(null),
item -> BuiltInRegistries.ITEM.getKey(item).toString()
),
LIST() {

View File

@@ -17,65 +17,13 @@
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.client.gui.components.toasts.SystemToast;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
public class BaritoneToast implements Toast {
private String title;
private String subtitle;
private long firstDrawTime;
private boolean newDisplay;
private long totalShowTime;
public BaritoneToast(Component titleComponent, Component subtitleComponent, long totalShowTime) {
this.title = titleComponent.getString();
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
this.totalShowTime = totalShowTime;
}
public Visibility render(GuiGraphics gui, ToastComponent toastGui, long delta) {
if (this.newDisplay) {
this.firstDrawTime = delta;
this.newDisplay = false;
}
//TODO: check
gui.blit(ResourceLocation.parse("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
if (this.subtitle == null) {
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256);
} else {
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;
}
public void setDisplayedText(Component titleComponent, Component subtitleComponent) {
this.title = titleComponent.getString();
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
this.newDisplay = true;
}
public static void addOrUpdate(ToastComponent toast, Component title, Component subtitle, long totalShowTime) {
BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object());
if (baritonetoast == null) {
toast.addToast(new BaritoneToast(title, subtitle, totalShowTime));
} else {
baritonetoast.setDisplayedText(title, subtitle);
}
}
public class BaritoneToast {
private static final SystemToast.SystemToastId BARITONE_TOAST_ID = new SystemToast.SystemToastId(5000L);
public static void addOrUpdate(Component title, Component subtitle) {
addOrUpdate(Minecraft.getInstance().getToasts(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value);
SystemToast.addOrUpdate(Minecraft.getInstance().getToastManager(), BARITONE_TOAST_ID, title, subtitle);
}
}

View File

@@ -32,6 +32,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Optional;
@@ -81,13 +82,13 @@ public abstract class MixinLivingEntity extends Entity {
}
@Inject(
method = "travel",
method = "updateFallFlyingMovement",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/LivingEntity.getLookAngle()Lnet/minecraft/world/phys/Vec3;"
)
)
private void onPreElytraMove(Vec3 direction, CallbackInfo ci) {
private void onPreElytraMove(Vec3 direction, final CallbackInfoReturnable<Vec3> cir) {
this.getBaritone().ifPresent(baritone -> {
this.elytraRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.getYRot(), this.getXRot());
baritone.getGameEventHandler().onPlayerRotationMove(this.elytraRotationEvent);
@@ -97,14 +98,14 @@ public abstract class MixinLivingEntity extends Entity {
}
@Inject(
method = "travel",
method = "travelFallFlying",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/LivingEntity.move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V",
shift = At.Shift.AFTER
)
)
private void onPostElytraMove(Vec3 direction, CallbackInfo ci) {
private void onPostElytraMove(final CallbackInfo ci) {
if (this.elytraRotationEvent != null) {
this.setYRot(this.elytraRotationEvent.getOriginal().getYaw());
this.setXRot(this.elytraRotationEvent.getOriginal().getPitch());

View File

@@ -20,18 +20,17 @@ package baritone.launch.mixins;
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.resource.GraphicsResourceAllocator;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.LightTexture;
import org.joml.Matrix4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
/**
* @author Brady
@@ -44,7 +43,7 @@ public class MixinWorldRenderer {
method = "renderLevel",
at = @At("RETURN")
)
private void onStartHand(final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
private void onStartHand(final GraphicsResourceAllocator graphicsResourceAllocator, final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
PoseStack poseStack = new PoseStack();
poseStack.mulPose(matrix4f);

View File

@@ -84,7 +84,7 @@ public final class ChunkPacker {
Block block = state.getBlock();
if (CachedChunk.BLOCKS_TO_KEEP_TRACK_OF.contains(block)) {
String name = BlockUtils.blockToString(block);
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), z));
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinY(), z));
}
}
}

View File

@@ -156,7 +156,7 @@ public enum FasterWorldScanner implements IWorldScanner {
long chunkX = (long) pos.x << 4;
long chunkZ = (long) pos.z << 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinY()) >> 4;
return collectChunkSections(lookup, chunkProvider.getChunk(pos.x, pos.z, false), chunkX, chunkZ, playerSectionY).stream();
}
@@ -165,7 +165,7 @@ 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();
int chunkY = chunk.getMinY();
LevelChunkSection[] sections = chunk.getSections();
int l = sections.length;
int i = playerSection - 1;

View File

@@ -40,10 +40,10 @@ public class RenderCommand extends Command {
int renderDistance = (ctx.minecraft().options.renderDistance().get() + 1) * 16;
ctx.minecraft().levelRenderer.setBlocksDirty(
origin.x - renderDistance,
ctx.world().getMinBuildHeight(),
ctx.world().getMinY(),
origin.z - renderDistance,
origin.x + renderDistance,
ctx.world().getMaxBuildHeight(),
ctx.world().getMaxY(),
origin.z + renderDistance
);
logDirect("Done");

View File

@@ -44,7 +44,7 @@ public class TunnelCommand extends Command {
int width = Integer.parseInt(args.getArgs().get(1).getValue());
int depth = Integer.parseInt(args.getArgs().get(2).getValue());
if (width < 1 || height < 2 || depth < 1 || height > ctx.world().getMaxBuildHeight()){
if (width < 1 || height < 2 || depth < 1 || height > ctx.world().getMaxY()){
logDirect("Width and depth must at least be 1 block; Height must at least be 2 blocks, and cannot be greater than the build limit.");
cont = false;
}

View File

@@ -147,7 +147,7 @@ public class MovementDescend extends Movement {
int effectiveStartHeight = y;
for (int fallHeight = 3; true; fallHeight++) {
int newY = y - fallHeight;
if (newY < context.world.getMinBuildHeight()) {
if (newY < context.world.getMinY()) {
// when pathing in the end, where you could plausibly fall into the void
// this check prevents it from getting the block at y=(below whatever the minimum height is) and crashing
return false;

View File

@@ -140,7 +140,7 @@ public class MovementFall extends Movement {
}
state.setInput(Input.MOVE_FORWARD, true);
}
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getNormal).orElse(null);
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getUnitVec3i).orElse(null);
if (avoid == null) {
avoid = src.subtract(dest);
} else {

View File

@@ -64,7 +64,7 @@ public class MovementParkour extends Movement {
if (!context.allowParkour) {
return;
}
if (!context.allowJumpAtBuildLimit && y >= context.world.getMaxBuildHeight()) {
if (!context.allowJumpAtBuildLimit && y >= context.world.getMaxY()) {
return;
}
int xDiff = dir.getStepX();

View File

@@ -254,7 +254,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
if (this.state == State.GET_TO_JUMP) {
final IPathExecutor executor = baritone.getPathingBehavior().getCurrent();
final boolean canStartFlying = ctx.player().fallDistance > 1.0f
// TODO 1.21.5: replace `ctx.player().getDeltaMovement().y < -0.377` with `ctx.player().fallDistance > 1.0f`
final boolean canStartFlying = ctx.player().getDeltaMovement().y < -0.377
&& !isSafeToCancel
&& executor != null
&& executor.getPath().movements().get(executor.getPosition()) instanceof MovementFall;
@@ -272,7 +273,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
baritone.getPathingBehavior().secretInternalSegmentCancel();
}
baritone.getInputOverrideHandler().clearAllKeys();
if (ctx.player().fallDistance > 1.0f) {
// TODO 1.21.5: replace `ctx.player().getDeltaMovement().y < -0.377` with `ctx.player().fallDistance > 1.0f`
if (ctx.player().getDeltaMovement().y < -0.377) {
baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, true);
}
}

View File

@@ -310,7 +310,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
if (!(ctx.world().getBlockState(pos.relative(dir)).getBlock() instanceof AirBlock)) {
continue;
}
Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getNormal()).scale(0.5));
Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getUnitVec3i()).scale(0.5));
Optional<Rotation> rot = RotationUtils.reachableOffset(ctx, pos, faceCenter, blockReachDistance, false);
if (rot.isPresent() && isSafeToCancel && baritone.getInventoryBehavior().throwaway(true, this::isCocoa)) {
HitResult result = RayTraceUtils.rayTraceTowards(ctx.player(), rot.get(), blockReachDistance);

View File

@@ -60,8 +60,8 @@ public final class BlockStateInterfaceAccessWrapper implements BlockGetter {
}
@Override
public int getMinBuildHeight() {
return bsi.world.getMinBuildHeight();
public int getMinY() {
return bsi.world.getMinY();
}
}

View File

@@ -24,7 +24,10 @@ import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.ShaderProgram;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
@@ -50,7 +53,7 @@ public interface IRenderer {
static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
RenderSystem.enableBlend();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShader(CoreShaders.POSITION_COLOR);
RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
@@ -65,7 +68,7 @@ public interface IRenderer {
if (ignoreDepth) {
RenderSystem.disableDepthTest();
}
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
RenderSystem.setShader(CoreShaders.RENDERTYPE_LINES);
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
}
@@ -78,7 +81,7 @@ public interface IRenderer {
if (meshData != null) {
BufferUploader.drawWithShader(meshData);
}
if (ignoredDepth) {
RenderSystem.enableDepthTest();
}

View File

@@ -262,12 +262,12 @@ public final class PathRenderer implements IRenderer {
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
} else if (goal instanceof GoalXZ) {
GoalXZ goalPos = (GoalXZ) goal;
minY = ctx.world().getMinBuildHeight();
maxY = ctx.world().getMaxBuildHeight();
minY = ctx.world().getMinY();
maxY = ctx.world().getMaxY();
if (settings.renderGoalXZBeacon.value) {
//TODO: check
textureManager.bindForSetup(TEXTURE_BEACON_BEAM);
textureManager.getTexture(TEXTURE_BEACON_BEAM).bind();
if (settings.renderGoalIgnoreDepth.value) {
RenderSystem.disableDepthTest();
}

View File

@@ -18,8 +18,9 @@
package baritone.utils;
import baritone.api.utils.input.Input;
import net.minecraft.client.player.ClientInput;
public class PlayerMovementInput extends net.minecraft.client.player.Input {
public class PlayerMovementInput extends ClientInput {
private final InputOverrideHandler handler;
@@ -28,31 +29,39 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input {
}
@Override
public void tick(boolean p_225607_1_, float f) {
public void tick() {
this.leftImpulse = 0.0F;
this.forwardImpulse = 0.0F;
boolean jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
this.jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
if (this.up = handler.isInputForcedDown(Input.MOVE_FORWARD)) {
boolean up = handler.isInputForcedDown(Input.MOVE_FORWARD);
if (up) {
this.forwardImpulse++;
}
if (this.down = handler.isInputForcedDown(Input.MOVE_BACK)) {
boolean down = handler.isInputForcedDown(Input.MOVE_BACK);
if (down) {
this.forwardImpulse--;
}
if (this.left = handler.isInputForcedDown(Input.MOVE_LEFT)) {
boolean left = handler.isInputForcedDown(Input.MOVE_LEFT);
if (left) {
this.leftImpulse++;
}
if (this.right = handler.isInputForcedDown(Input.MOVE_RIGHT)) {
boolean right = handler.isInputForcedDown(Input.MOVE_RIGHT);
if (right) {
this.leftImpulse--;
}
if (this.shiftKeyDown = handler.isInputForcedDown(Input.SNEAK)) {
boolean sneaking = handler.isInputForcedDown(Input.SNEAK);
if (sneaking) {
this.leftImpulse *= 0.3D;
this.forwardImpulse *= 0.3D;
}
boolean sprinting = handler.isInputForcedDown(Input.SPRINT);
this.keyPresses = new net.minecraft.world.entity.player.Input(up, down, left, right, jumping, sneaking, sprinting);
}
}

View File

@@ -20,12 +20,17 @@ package baritone.utils;
import baritone.Baritone;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.Holder;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TieredItem;
import net.minecraft.world.item.enchantment.*;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.item.enchantment.ItemEnchantments;
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
@@ -55,6 +60,20 @@ public class ToolSet {
private final LocalPlayer player;
/**
* Used for evaluating the material cost of a tool.
* see {@link #getMaterialCost(ItemStack)}
* Prefer tools with lower material cost (lower index in this list).
*/
private static final List<TagKey<Item>> materialTagsPriorityList = List.of(
ItemTags.WOODEN_TOOL_MATERIALS,
ItemTags.STONE_TOOL_MATERIALS,
ItemTags.IRON_TOOL_MATERIALS,
ItemTags.GOLD_TOOL_MATERIALS,
ItemTags.DIAMOND_TOOL_MATERIALS,
ItemTags.NETHERITE_TOOL_MATERIALS
);
public ToolSet(LocalPlayer player) {
breakStrengthCache = new HashMap<>();
this.player = player;
@@ -79,20 +98,18 @@ public class ToolSet {
}
/**
* Evaluate the material cost of a possible tool. The priority matches the
* harvest level order; there is a chance for multiple at the same with modded tools
* but in that case we don't really care.
*
* Evaluate the material cost of a possible tool.
* If all else is equal, we want to prefer the tool with the lowest material cost.
* i.e. we want to prefer a wooden pickaxe over a stone pickaxe, if all else is equal.
* @param itemStack a possibly empty ItemStack
* @return values from 0 up
*/
private int getMaterialCost(ItemStack itemStack) {
if (itemStack.getItem() instanceof TieredItem) {
TieredItem tool = (TieredItem) itemStack.getItem();
return (int) tool.getTier().getAttackDamageBonus();
} else {
return -1;
for (int i = 0; i < materialTagsPriorityList.size(); i++) {
final TagKey<Item> tag = materialTagsPriorityList.get(i);
if (itemStack.is(tag)) return i;
}
return -1;
}
public boolean hasSilkTouch(ItemStack stack) {

View File

@@ -20,12 +20,14 @@ package baritone.utils.schematic.format.defaults;
import baritone.api.schematic.CompositeSchematic;
import baritone.api.schematic.IStaticSchematic;
import baritone.utils.schematic.StaticSchematic;
import net.minecraft.core.Holder;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import org.apache.commons.lang3.Validate;
@@ -81,8 +83,14 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
BlockState[] blockList = new BlockState[blockStatePalette.size()];
for (int i = 0; i < blockStatePalette.size(); i++) {
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
CompoundTag tag = (CompoundTag) blockStatePalette.get(i);
ResourceLocation blockKey = ResourceLocation.tryParse(tag.getString("Name"));
Block block = blockKey == null
? Blocks.AIR
: BuiltInRegistries.BLOCK.get(blockKey)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
CompoundTag properties = tag.getCompound("Properties");
blockList[i] = getBlockState(block, properties);
}

View File

@@ -18,12 +18,14 @@
package baritone.utils.schematic.format.defaults;
import baritone.utils.schematic.StaticSchematic;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.datafix.fixes.ItemIdFix;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
/**
@@ -63,7 +65,13 @@ public final class MCEditSchematic extends StaticSchematic {
// additional is 0 through 15 inclusive since it's & 0xF above
blockID |= additional[blockInd] << 8;
}
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.tryParse(ItemIdFix.getItem(blockID)));
ResourceLocation blockKey = ResourceLocation.tryParse(ItemIdFix.getItem(blockID));
Block block = blockKey == null
? Blocks.AIR
: BuiltInRegistries.BLOCK.get(blockKey)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
// int meta = metadata[blockInd] & 0xFF;
// this.states[x][z][y] = block.getStateFromMeta(meta);
this.states[x][z][y] = block.defaultBlockState();

View File

@@ -25,11 +25,14 @@ import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
@@ -107,7 +110,9 @@ public final class SpongeSchematic extends StaticSchematic {
private BlockState deserialize() {
if (this.blockState == null) {
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation);
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
this.blockState = block.defaultBlockState();
this.properties.keySet().stream().sorted(String::compareTo).forEachOrdered(key -> {

View File

@@ -21,7 +21,7 @@ import net.minecraft.world.level.Level;
public abstract class WorldSchematic extends Level {
private WorldSchematic() {
super(null, null, null, null, null, false, false, 0, 0);
super(null, null, null, null, false, false, 0, 0);
throw new LinkageError();
}
}