Skip to content
Merged

1.21.8 #4820

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": ["1.21.5"]
"minecraft": ["1.21.6", "1.21.7", "1.21.8"]
},
"custom": {
"modmenu": {
Expand Down
2 changes: 1 addition & 1 deletion forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.5]"
versionRange="[1.21.6, 1.21.8]"
ordering="NONE"
side="BOTH"
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ org.gradle.jvmargs=-Xmx4G

available_loaders=fabric,neoforge,forge,tweaker

mod_version=1.14.0
mod_version=1.15.0
maven_group=baritone
archives_base_name=baritone

java_version=21

minecraft_version=1.21.5
minecraft_version=1.21.8

forge_version=55.0.9
forge_version=58.0.0

neoforge_version=63-beta
neoforge_version=2-beta

fabric_version=0.16.10
fabric_version=0.16.14

nether_pathfinder_version=1.4.1

Expand Down
2 changes: 1 addition & 1 deletion neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.5]"
versionRange="[1.21.6, 1.21.8]"
ordering="NONE"
side="BOTH"
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import baritone.api.event.events.PacketEvent;
import baritone.api.event.events.type.EventState;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.Connection;
import net.minecraft.network.PacketSendListener;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
import org.spongepowered.asm.mixin.Final;
Expand Down Expand Up @@ -52,7 +52,7 @@ public class MixinNetworkManager {
method = "sendPacket",
at = @At("HEAD")
)
private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, boolean flush, CallbackInfo ci) {
private void preDispatchPacket(final Packet<?> packet, final ChannelFutureListener channelFutureListener, final boolean flush, final CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
return;
}
Expand All @@ -68,7 +68,7 @@ private void preDispatchPacket(Packet<?> packet, PacketSendListener packetSendLi
method = "sendPacket",
at = @At("RETURN")
)
private void postDispatchPacket(Packet<?> packet, PacketSendListener packetSendListener, boolean flush, CallbackInfo ci) {
private void postDispatchPacket(Packet<?> packet, ChannelFutureListener packetSendListener, boolean flush, CallbackInfo ci) {
if (this.receiving != PacketFlow.CLIENTBOUND) {
return;
}
Expand Down
15 changes: 5 additions & 10 deletions src/launch/java/baritone/launch/mixins/MixinScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,22 @@
import baritone.api.IBaritone;
import baritone.api.event.events.ChatEvent;
import baritone.utils.accessor.IGuiScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Style;
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.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;

@Mixin(Screen.class)
public abstract class MixinScreen implements IGuiScreen {

//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
@Inject(method = "handleComponentClicked", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/multiplayer/ClientPacketListener;sendUnsignedCommand(Ljava/lang/String;)Z"
), cancellable = true)
public void handleCustomClickEvent(final Style style, final CallbackInfoReturnable<Boolean> cir) {
ClickEvent clickEvent = style.getClickEvent();
@Inject(method = "handleClickEvent", at = @At(value = "HEAD"), cancellable = true)
public void handleCustomClickEvent(final Minecraft minecraft, final ClickEvent clickEvent, final CallbackInfo ci) {
if (clickEvent == null) {
return;
}
Expand All @@ -52,7 +48,6 @@ public void handleCustomClickEvent(final Style style, final CallbackInfoReturnab
if (baritone != null) {
baritone.getGameEventHandler().onSendChatMessage(new ChatEvent(command));
}
cir.setReturnValue(true);
cir.cancel();
ci.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import baritone.api.BaritoneAPI;
import baritone.api.IBaritone;
import baritone.api.event.events.RenderEvent;
import com.mojang.blaze3d.buffers.GpuBufferSlice;
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 org.joml.Matrix4f;
import org.joml.Vector4f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -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 GraphicsResourceAllocator graphicsResourceAllocator, final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final Matrix4f matrix4f, final Matrix4f matrix4f2, final GpuBufferSlice gpuBufferSlice, final Vector4f vector4f, final boolean bl2, final CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
PoseStack poseStack = new PoseStack();
poseStack.mulPose(matrix4f);
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/baritone/behavior/PathingBehavior.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@
import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.MovementHelper;
import baritone.pathing.path.PathExecutor;
import baritone.process.ElytraProcess;
import baritone.utils.PathRenderer;
import baritone.utils.PathingCommandContext;
import baritone.utils.pathing.Favoring;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue;
import net.minecraft.core.BlockPos;

public final class PathingBehavior extends Behavior implements IPathingBehavior, Helper {

Expand Down Expand Up @@ -158,7 +160,9 @@ private void tickPath() {
queuePathEvent(PathEvent.AT_GOAL);
next = null;
if (Baritone.settings().disconnectOnArrival.value) {
ctx.world().disconnect();
if (ctx.world() instanceof ClientLevel clientLevel) {
clientLevel.disconnect(Component.literal("[Baritone] Arrived at goal!"));
}
}
return;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/baritone/process/CustomGoalProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType;
import baritone.utils.BaritoneProcessHelper;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.network.chat.Component;

/**
* As set by ExampleBaritoneControl or something idk
Expand Down Expand Up @@ -105,7 +107,9 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
if (this.goal == null || (this.goal.isInGoal(ctx.playerFeet()) && this.goal.isInGoal(baritone.getPathingBehavior().pathStart()))) {
onLostControl(); // we're there xd
if (Baritone.settings().disconnectOnArrival.value) {
ctx.world().disconnect();
if (ctx.world() instanceof ClientLevel clientLevel) {
clientLevel.disconnect(Component.literal("[Baritone] Arrived at goal!"));
}
}
if (Baritone.settings().notificationOnPathComplete.value) {
logNotification("Pathing complete", false);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/baritone/process/ElytraProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
import baritone.utils.BaritoneProcessHelper;
import baritone.utils.PathingCommandContext;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -157,7 +159,9 @@ public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
if (Baritone.settings().disconnectOnArrival.value && !reachedGoal) {
// don't be active when the user logs back in
this.onLostControl();
ctx.world().disconnect();
if (ctx.world() instanceof ClientLevel clientLevel) {
clientLevel.disconnect(Component.literal("[Baritone] Arrived at goal!"));
}
return new PathingCommand(null, PathingCommandType.CANCEL_AND_SET_GOAL);
}
reachedGoal = true;
Expand Down
77 changes: 42 additions & 35 deletions src/main/java/baritone/utils/BaritoneRenderType.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@
package baritone.utils;

import com.mojang.blaze3d.buffers.GpuBuffer;
import com.mojang.blaze3d.buffers.GpuBufferSlice;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.systems.RenderPass;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.textures.GpuTexture;
import com.mojang.blaze3d.systems.ScissorState;
import com.mojang.blaze3d.textures.GpuTextureView;
import com.mojang.blaze3d.vertex.MeshData;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.renderer.RenderStateShard;
import net.minecraft.client.renderer.RenderType;
import org.joml.Vector4f;

import java.util.OptionalDouble;
import java.util.OptionalInt;
Expand All @@ -43,11 +46,6 @@ public static BaritoneRenderType create(String name, int bufferSize, RenderPipel
return new BaritoneRenderType(name, bufferSize, false, false, renderPipeline);
}

@Override
public RenderPipeline getRenderPipeline() {
return this.renderPipeline;
}

@Override
public VertexFormat format() {
return this.renderPipeline.getVertexFormat();
Expand All @@ -60,45 +58,59 @@ public VertexFormat.Mode mode() {

@Override
public void draw(final MeshData meshData) {
RenderPipeline renderPipeline = this.getRenderPipeline();
this.setupRenderState();

try {
GpuBuffer gpuBuffer = renderPipeline.getVertexFormat().uploadImmediateVertexBuffer(meshData.vertexBuffer());
GpuBuffer gpuBuffer2;
GpuBuffer vertexBuffer = this.renderPipeline.getVertexFormat().uploadImmediateVertexBuffer(meshData.vertexBuffer());
GpuBuffer indexBuffer;
VertexFormat.IndexType indexType;
if (meshData.indexBuffer() == null) {
RenderSystem.AutoStorageIndexBuffer autoStorageIndexBuffer = RenderSystem.getSequentialBuffer(meshData.drawState().mode());
gpuBuffer2 = autoStorageIndexBuffer.getBuffer(meshData.drawState().indexCount());
indexBuffer = autoStorageIndexBuffer.getBuffer(meshData.drawState().indexCount());
indexType = autoStorageIndexBuffer.type();
} else {
gpuBuffer2 = renderPipeline.getVertexFormat().uploadImmediateIndexBuffer(meshData.indexBuffer());
indexBuffer = this.renderPipeline.getVertexFormat().uploadImmediateIndexBuffer(meshData.indexBuffer());
indexType = meshData.drawState().indexType();
}

RenderTarget renderTarget = getRenderTarget();

try (RenderPass renderPass = RenderSystem.getDevice().createCommandEncoder().createRenderPass(
renderTarget.getColorTexture(),
OptionalInt.empty(),
renderTarget.useDepth ? renderTarget.getDepthTexture() : null,
OptionalDouble.empty())
) {
renderPass.setPipeline(renderPipeline);
renderPass.setVertexBuffer(0, gpuBuffer);
if (RenderSystem.SCISSOR_STATE.isEnabled()) {
renderPass.enableScissor(RenderSystem.SCISSOR_STATE);
RenderTarget renderTarget = RenderStateShard.MAIN_TARGET.getRenderTarget();
GpuTextureView colorTextureTarget = RenderSystem.outputColorTextureOverride != null
? RenderSystem.outputColorTextureOverride
: renderTarget.getColorTextureView();
GpuTextureView depthTextureTarget = renderTarget.useDepth
? (RenderSystem.outputDepthTextureOverride != null ? RenderSystem.outputDepthTextureOverride : renderTarget.getDepthTextureView())
: null;

GpuBufferSlice dynamicTransformsUbo = RenderSystem.getDynamicUniforms()
.writeTransform(
RenderSystem.getModelViewMatrix(),
new Vector4f(1.0F, 1.0F, 1.0F, 1.0F),
RenderSystem.getModelOffset(),
RenderSystem.getTextureMatrix(),
RenderSystem.getShaderLineWidth()
);

try (RenderPass renderPass = RenderSystem.getDevice()
.createCommandEncoder()
.createRenderPass(() -> "Immediate draw for " + this.getName(), colorTextureTarget, OptionalInt.empty(), depthTextureTarget, OptionalDouble.empty())) {
renderPass.setPipeline(this.renderPipeline);
ScissorState scissorState = RenderSystem.getScissorStateForRenderTypeDraws();
if (scissorState.enabled()) {
renderPass.enableScissor(scissorState.x(), scissorState.y(), scissorState.width(), scissorState.height());
}

for(int i = 0; i < 12; ++i) {
GpuTexture gpuTexture = RenderSystem.getShaderTexture(i);
if (gpuTexture != null) {
renderPass.bindSampler("Sampler" + i, gpuTexture);
RenderSystem.bindDefaultUniforms(renderPass);
renderPass.setUniform("DynamicTransforms", dynamicTransformsUbo);
renderPass.setVertexBuffer(0, vertexBuffer);

for (int i = 0; i < 12; i++) {
GpuTextureView texture = RenderSystem.getShaderTexture(i);
if (texture != null) {
renderPass.bindSampler("Sampler" + i, texture);
}
}

renderPass.setIndexBuffer(gpuBuffer2, indexType);
renderPass.drawIndexed(0, meshData.drawState().indexCount());
renderPass.setIndexBuffer(indexBuffer, indexType);
renderPass.drawIndexed(0, 0, meshData.drawState().indexCount(), 1);
}
} catch (Throwable e) {
try {
Expand All @@ -113,9 +125,4 @@ public void draw(final MeshData meshData) {

this.clearRenderState();
}

@Override
public RenderTarget getRenderTarget() {
return RenderStateShard.MAIN_TARGET.getRenderTarget();
}
}