Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b9fb07cd9 | ||
|
|
ce6079c203 | ||
|
|
9d5db72806 | ||
|
|
b14c75804d | ||
|
|
fd4fbf5df5 | ||
|
|
7e8c8501a7 | ||
|
|
55cb180755 |
@@ -26,7 +26,7 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.22",
|
||||
"minecraft": ["1.21","1.21.1"]
|
||||
"minecraft": ["1.21.2","1.21.3"]
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
|
||||
@@ -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.2, 1.21.3]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
@@ -2,19 +2,19 @@ org.gradle.jvmargs=-Xmx4G
|
||||
|
||||
available_loaders=fabric,forge,neoforge,tweaker
|
||||
|
||||
mod_version=1.11.0
|
||||
mod_version=1.12.0
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
java_version=21
|
||||
|
||||
minecraft_version=1.21
|
||||
minecraft_version=1.21.3
|
||||
|
||||
forge_version=51.0.16
|
||||
forge_version=53.0.7
|
||||
|
||||
neoforge_version=20-beta
|
||||
neoforge_version=6-beta
|
||||
|
||||
fabric_version=0.15.11
|
||||
fabric_version=0.16.7
|
||||
|
||||
nether_pathfinder_version=1.4.1
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ archivesBaseName = archivesBaseName + "-neoforge"
|
||||
|
||||
unimined.minecraft {
|
||||
|
||||
neoForged {
|
||||
neoForge {
|
||||
loader project.neoforge_version
|
||||
mixinConfig ["mixins.baritone.json"]
|
||||
}
|
||||
|
||||
@@ -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.2,1.21.3]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -20,6 +20,7 @@ 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;
|
||||
@@ -44,7 +45,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 LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
PoseStack poseStack = new PoseStack();
|
||||
poseStack.mulPose(matrix4f);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -31,28 +32,36 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input {
|
||||
public void tick(boolean p_225607_1_, float f) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 -> {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user