Compare commits

..

1 Commits

Author SHA1 Message Date
ZacSharp
12ddeee278 v1.11.2 2025-05-13 20:42:51 +02:00
30 changed files with 175 additions and 151 deletions

View File

@@ -26,7 +26,7 @@
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": ["1.21.4"]
"minecraft": ["1.21","1.21.1"]
},
"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.4]"
versionRange="[1.21, 1.21.1]"
ordering="NONE"
side="BOTH"

View File

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

View File

@@ -26,7 +26,7 @@ archivesBaseName = archivesBaseName + "-neoforge"
unimined.minecraft {
neoForge {
neoForged {
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.4]"
versionRange="[1.21,1.21.1]"
ordering="NONE"
side="BOTH"

View File

@@ -673,6 +673,13 @@ 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.getUnitVec3i();
Vec3i vec = dir.getNormal();
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.getUnitVec3i();
Vec3i vec = dir.getNormal();
return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist);
}

View File

@@ -21,26 +21,32 @@ 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.core.HolderLookup;
import net.minecraft.commands.Commands;
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.tags.TagLoader;
import net.minecraft.server.packs.resources.ResourceManager;
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;
@@ -52,6 +58,7 @@ 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;
@@ -224,8 +231,8 @@ public final class BlockOptionalMeta {
private static synchronized List<Item> drops(Block b) {
return drops.computeIfAbsent(b, block -> {
Optional<ResourceKey<LootTable>> optionalLootTableKey = block.getLootTable();
if (optionalLootTableKey.isEmpty()) {
ResourceLocation lootTableLocation = block.getLootTable().location();
if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) {
return Collections.emptyList();
} else {
List<Item> items = new ArrayList<>();
@@ -246,13 +253,13 @@ public final class BlockOptionalMeta {
}
private static List<ItemStack> getDrops(Block state, LootParams.Builder params) {
Optional<ResourceKey<LootTable>> lv = state.getLootTable();
if (lv.isEmpty()) {
ResourceKey<LootTable> lv = state.getLootTable();
if (lv == BuiltInLootTables.EMPTY) {
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.get());
LootTable lv4 = lv3.holder().getLootTable(lv);
return((ILootTable) lv4).invokeGetRandomItems(new LootContext.Builder(lv2).withOptionalRandomSeed(1).create(null));
}
}
@@ -300,33 +307,44 @@ public final class BlockOptionalMeta {
}
public static CompletableFuture<RegistryAccess> load() {
// Simplified from {@link net.minecraft.server.WorldLoader#load()}
PackRepository packRepository = Minecraft.getInstance().getResourcePackRepository();
CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(
PackType.SERVER_DATA,
List.of(ServerPacksSource.createVanillaPackSource())
List.of(packRepository.getPack(BuiltInPackSource.VANILLA_ID).open())
);
LayeredRegistryAccess<RegistryLayer> baseLayeredRegistry = RegistryLayer.createRegistryAccess();
List<Registry.PendingTags<?>> pendingTags = TagLoader.loadTagsForExistingRegistries(
closeableResourceManager, baseLayeredRegistry.getLayer(RegistryLayer.STATIC)
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = loadAndReplaceLayer(
closeableResourceManager, RegistryLayer.createRegistryAccess(), RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES
);
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,
pendingTags,
return ReloadableServerResources.loadResources(
closeableResourceManager,
layeredRegistryAccess,
FeatureFlags.VANILLA_SET,
Commands.CommandSelection.INTEGRATED,
2,
Runnable::run,
Minecraft.getInstance()
).thenApply(r -> r.layers().compositeAccess());
).thenApply(reloadableServerResources -> reloadableServerResources.fullRegistries().get());
}
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,7 +21,6 @@ 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;
@@ -246,8 +245,8 @@ public class SettingsUtil {
BlockUtils::blockToString
),
ITEM(
Item.class,
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())).map(Holder.Reference::value).orElse(null),
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 -> BuiltInRegistries.ITEM.getKey(item).toString()
),
LIST() {

View File

@@ -17,13 +17,65 @@
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.components.toasts.SystemToast;
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;
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) {
SystemToast.addOrUpdate(Minecraft.getInstance().getToastManager(), BARITONE_TOAST_ID, title, subtitle);
addOrUpdate(Minecraft.getInstance().getToasts(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value);
}
}

View File

@@ -32,7 +32,6 @@ 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;
@@ -82,13 +81,13 @@ public abstract class MixinLivingEntity extends Entity {
}
@Inject(
method = "updateFallFlyingMovement",
method = "travel",
at = @At(
value = "INVOKE",
target = "net/minecraft/world/entity/LivingEntity.getLookAngle()Lnet/minecraft/world/phys/Vec3;"
)
)
private void onPreElytraMove(Vec3 direction, final CallbackInfoReturnable<Vec3> cir) {
private void onPreElytraMove(Vec3 direction, CallbackInfo ci) {
this.getBaritone().ifPresent(baritone -> {
this.elytraRotationEvent = new RotationMoveEvent(RotationMoveEvent.Type.MOTION_UPDATE, this.getYRot(), this.getXRot());
baritone.getGameEventHandler().onPlayerRotationMove(this.elytraRotationEvent);
@@ -98,14 +97,14 @@ public abstract class MixinLivingEntity extends Entity {
}
@Inject(
method = "travelFallFlying",
method = "travel",
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(final CallbackInfo ci) {
private void onPostElytraMove(Vec3 direction, CallbackInfo ci) {
if (this.elytraRotationEvent != null) {
this.setYRot(this.elytraRotationEvent.getOriginal().getYaw());
this.setXRot(this.elytraRotationEvent.getOriginal().getPitch());

View File

@@ -20,17 +20,18 @@ 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
@@ -43,7 +44,7 @@ public class MixinWorldRenderer {
method = "renderLevel",
at = @At("RETURN")
)
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) {
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) {
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.getMinY(), z));
specialBlocks.computeIfAbsent(name, b -> new ArrayList<>()).add(new BlockPos(x, y+chunk.getMinBuildHeight(), 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().getMinY()) >> 4;
int playerSectionY = (ctx.playerFeet().y - ctx.world().getMinBuildHeight()) >> 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.getMinY();
int chunkY = chunk.getMinBuildHeight();
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().getMinY(),
ctx.world().getMinBuildHeight(),
origin.z - renderDistance,
origin.x + renderDistance,
ctx.world().getMaxY(),
ctx.world().getMaxBuildHeight(),
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().getMaxY()){
if (width < 1 || height < 2 || depth < 1 || height > ctx.world().getMaxBuildHeight()){
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.getMinY()) {
if (newY < context.world.getMinBuildHeight()) {
// 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::getUnitVec3i).orElse(null);
Vec3i avoid = Optional.ofNullable(avoid()).map(Direction::getNormal).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.getMaxY()) {
if (!context.allowJumpAtBuildLimit && y >= context.world.getMaxBuildHeight()) {
return;
}
int xDiff = dir.getStepX();

View File

@@ -254,8 +254,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
if (this.state == State.GET_TO_JUMP) {
final IPathExecutor executor = baritone.getPathingBehavior().getCurrent();
// 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
final boolean canStartFlying = ctx.player().fallDistance > 1.0f
&& !isSafeToCancel
&& executor != null
&& executor.getPath().movements().get(executor.getPosition()) instanceof MovementFall;
@@ -273,8 +272,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
baritone.getPathingBehavior().secretInternalSegmentCancel();
}
baritone.getInputOverrideHandler().clearAllKeys();
// TODO 1.21.5: replace `ctx.player().getDeltaMovement().y < -0.377` with `ctx.player().fallDistance > 1.0f`
if (ctx.player().getDeltaMovement().y < -0.377) {
if (ctx.player().fallDistance > 1.0f) {
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.getUnitVec3i()).scale(0.5));
Vec3 faceCenter = Vec3.atCenterOf(pos).add(Vec3.atLowerCornerOf(dir.getNormal()).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 getMinY() {
return bsi.world.getMinY();
public int getMinBuildHeight() {
return bsi.world.getMinBuildHeight();
}
}

View File

@@ -24,10 +24,7 @@ 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;
@@ -53,7 +50,7 @@ public interface IRenderer {
static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
RenderSystem.enableBlend();
RenderSystem.setShader(CoreShaders.POSITION_COLOR);
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.blendFuncSeparate(
GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
@@ -68,7 +65,7 @@ public interface IRenderer {
if (ignoreDepth) {
RenderSystem.disableDepthTest();
}
RenderSystem.setShader(CoreShaders.RENDERTYPE_LINES);
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
}
@@ -81,7 +78,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().getMinY();
maxY = ctx.world().getMaxY();
minY = ctx.world().getMinBuildHeight();
maxY = ctx.world().getMaxBuildHeight();
if (settings.renderGoalXZBeacon.value) {
//TODO: check
textureManager.getTexture(TEXTURE_BEACON_BEAM).bind();
textureManager.bindForSetup(TEXTURE_BEACON_BEAM);
if (settings.renderGoalIgnoreDepth.value) {
RenderSystem.disableDepthTest();
}

View File

@@ -18,9 +18,8 @@
package baritone.utils;
import baritone.api.utils.input.Input;
import net.minecraft.client.player.ClientInput;
public class PlayerMovementInput extends ClientInput {
public class PlayerMovementInput extends net.minecraft.client.player.Input {
private final InputOverrideHandler handler;
@@ -29,39 +28,31 @@ public class PlayerMovementInput extends ClientInput {
}
@Override
public void tick() {
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
boolean up = handler.isInputForcedDown(Input.MOVE_FORWARD);
if (up) {
this.jumping = handler.isInputForcedDown(Input.JUMP); // oppa gangnam style
if (this.up = handler.isInputForcedDown(Input.MOVE_FORWARD)) {
this.forwardImpulse++;
}
boolean down = handler.isInputForcedDown(Input.MOVE_BACK);
if (down) {
if (this.down = handler.isInputForcedDown(Input.MOVE_BACK)) {
this.forwardImpulse--;
}
boolean left = handler.isInputForcedDown(Input.MOVE_LEFT);
if (left) {
if (this.left = handler.isInputForcedDown(Input.MOVE_LEFT)) {
this.leftImpulse++;
}
boolean right = handler.isInputForcedDown(Input.MOVE_RIGHT);
if (right) {
if (this.right = handler.isInputForcedDown(Input.MOVE_RIGHT)) {
this.leftImpulse--;
}
boolean sneaking = handler.isInputForcedDown(Input.SNEAK);
if (sneaking) {
if (this.shiftKeyDown = handler.isInputForcedDown(Input.SNEAK)) {
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,17 +20,12 @@ 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.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.TieredItem;
import net.minecraft.world.item.enchantment.*;
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
@@ -60,20 +55,6 @@ 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;
@@ -98,18 +79,20 @@ public class ToolSet {
}
/**
* 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.
* 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.
*
* @param itemStack a possibly empty ItemStack
* @return values from 0 up
*/
private int getMaterialCost(ItemStack itemStack) {
for (int i = 0; i < materialTagsPriorityList.size(); i++) {
final TagKey<Item> tag = materialTagsPriorityList.get(i);
if (itemStack.is(tag)) return i;
if (itemStack.getItem() instanceof TieredItem) {
TieredItem tool = (TieredItem) itemStack.getItem();
return (int) tool.getTier().getAttackDamageBonus();
} else {
return -1;
}
return -1;
}
public boolean hasSilkTouch(ItemStack stack) {

View File

@@ -20,14 +20,12 @@ 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;
@@ -83,14 +81,8 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
BlockState[] blockList = new BlockState[blockStatePalette.size()];
for (int i = 0; i < blockStatePalette.size(); i++) {
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");
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
blockList[i] = getBlockState(block, properties);
}

View File

@@ -18,14 +18,12 @@
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;
/**
@@ -65,13 +63,7 @@ public final class MCEditSchematic extends StaticSchematic {
// additional is 0 through 15 inclusive since it's & 0xF above
blockID |= additional[blockInd] << 8;
}
ResourceLocation blockKey = ResourceLocation.tryParse(ItemIdFix.getItem(blockID));
Block block = blockKey == null
? Blocks.AIR
: BuiltInRegistries.BLOCK.get(blockKey)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.tryParse(ItemIdFix.getItem(blockID)));
// int meta = metadata[blockInd] & 0xFF;
// this.states[x][z][y] = block.getStateFromMeta(meta);
this.states[x][z][y] = block.defaultBlockState();

View File

@@ -25,14 +25,11 @@ 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;
@@ -110,9 +107,7 @@ public final class SpongeSchematic extends StaticSchematic {
private BlockState deserialize() {
if (this.blockState == null) {
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation)
.map(Holder.Reference::value)
.orElse(Blocks.AIR);
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation);
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, false, false, 0, 0);
super(null, null, null, null, null, false, false, 0, 0);
throw new LinkageError();
}
}