Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b9fb07cd9 | ||
|
|
26e0af1188 | ||
|
|
ce6079c203 | ||
|
|
aff430ac51 | ||
|
|
7e5dedd8f3 | ||
|
|
ba1ccce962 | ||
|
|
1dc5be3985 | ||
|
|
1d6f5df155 | ||
|
|
9d5db72806 | ||
|
|
b14c75804d | ||
|
|
fd4fbf5df5 | ||
|
|
7e8c8501a7 | ||
|
|
55cb180755 | ||
|
|
9eefcbc9b6 | ||
|
|
52cfe5cf7e | ||
|
|
50291089db | ||
|
|
5102d9164e | ||
|
|
a231748b4e | ||
|
|
ec57888ce1 | ||
|
|
960ff6ed98 | ||
|
|
8867fb7010 | ||
|
|
8786148fef | ||
|
|
e66fdea500 | ||
|
|
74f46cd6eb |
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt update -y
|
||||
|
||||
RUN apt install \
|
||||
openjdk-17-jdk \
|
||||
openjdk-21-jdk \
|
||||
git \
|
||||
--assume-yes
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.22",
|
||||
"minecraft": ["1.20.5", "1.20.6"]
|
||||
"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.20.5, 1.20.6]"
|
||||
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.10.2
|
||||
mod_version=1.12.0
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
java_version=21
|
||||
|
||||
minecraft_version=1.20.6
|
||||
minecraft_version=1.21.3
|
||||
|
||||
forge_version=50.0.8
|
||||
forge_version=53.0.7
|
||||
|
||||
neoforge_version=43-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"]
|
||||
}
|
||||
@@ -127,4 +127,4 @@ publishing {
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package baritone.launch;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
||||
@Mod("baritoe")
|
||||
@Mod(value = "baritoe", dist = Dist.CLIENT)
|
||||
public class BaritoneForgeModXD {
|
||||
}
|
||||
|
||||
@@ -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.20.5, 1.20.6]"
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
|
||||
@Override
|
||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
|
||||
Block block;
|
||||
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
|
||||
@Override
|
||||
public EntityType get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
|
||||
EntityType entity;
|
||||
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
|
||||
@@ -77,7 +77,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
||||
properties = parts[1];
|
||||
}
|
||||
|
||||
Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(blockId)).orElse(null);
|
||||
Block block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(blockId)).orElse(null);
|
||||
if (block == null) {
|
||||
// This block doesn't exist so there's no properties to complete.
|
||||
return Stream.empty();
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum ItemById implements IDatatypeFor<Item> {
|
||||
|
||||
@Override
|
||||
public Item get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
|
||||
Item item;
|
||||
if ((item = BuiltInRegistries.ITEM.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("No item found by that id");
|
||||
|
||||
@@ -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,45 +21,37 @@ 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;
|
||||
import net.minecraft.world.level.CustomSpawner;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.WorldDataConfiguration;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
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;
|
||||
@@ -232,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<>();
|
||||
@@ -254,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));
|
||||
}
|
||||
}
|
||||
@@ -308,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(new ResourceLocation(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(new ResourceLocation("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());
|
||||
|
||||
@@ -37,11 +37,6 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
@Mixin(Screen.class)
|
||||
public abstract class MixinScreen implements IGuiScreen {
|
||||
|
||||
@Override
|
||||
@Invoker("openLink")
|
||||
public abstract void openLinkInvoker(URI url);
|
||||
|
||||
|
||||
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
|
||||
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {
|
||||
|
||||
@@ -20,8 +20,10 @@ 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;
|
||||
@@ -41,14 +43,13 @@ public class MixinWorldRenderer {
|
||||
|
||||
@Inject(
|
||||
method = "renderLevel",
|
||||
at = @At("RETURN"),
|
||||
locals = LocalCapture.CAPTURE_FAILSOFT
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void onStartHand(float f, long l, boolean bl, Camera arg, GameRenderer arg2, LightTexture arg3, Matrix4f matrix4f, Matrix4f matrix4f2, 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);
|
||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(f, poseStack, matrix4f2));
|
||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, matrix4f2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -35,6 +35,7 @@ import baritone.command.argument.CommandArguments;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import baritone.utils.accessor.IGuiScreen;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Tuple;
|
||||
@@ -97,8 +98,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
||||
return false;
|
||||
} else if (msg.trim().equalsIgnoreCase("orderpizza")) {
|
||||
try {
|
||||
((IGuiScreen) ctx.minecraft().screen).openLinkInvoker(new URI("https://www.dominos.com/en/pages/order/"));
|
||||
} catch (NullPointerException | URISyntaxException ignored) {}
|
||||
Util.getPlatform().openUri("https://www.dominos.com/en/pages/order/");
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
}
|
||||
if (msg.isEmpty()) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -42,6 +42,7 @@ import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -75,9 +76,9 @@ public class SelCommand extends Command {
|
||||
float opacity = Baritone.settings().selectionOpacity.value;
|
||||
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
||||
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
||||
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
IRenderer.emitAABB(event.getModelViewStack(), new AABB(pos1));
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
IRenderer.emitAABB(bufferBuilder, event.getModelViewStack(), new AABB(pos1));
|
||||
IRenderer.endLines(bufferBuilder, ignoreDepth);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,14 @@ import baritone.utils.ToolSet;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.*;
|
||||
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -108,19 +111,44 @@ public class CalculationContext {
|
||||
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
|
||||
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
|
||||
this.allowFallIntoLava = false; // Super secret internal setting for ElytraBehavior
|
||||
this.frostWalker = EnchantmentHelper.getEnchantmentLevel(Enchantments.FROST_WALKER, baritone.getPlayerContext().player());
|
||||
// todo: technically there can now be datapack enchants that replace blocks with any other at any range
|
||||
int frostWalkerLevel = 0;
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemEnchantments itemEnchantments = baritone.getPlayerContext()
|
||||
.player()
|
||||
.getItemBySlot(slot)
|
||||
.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
if (enchant.is(Enchantments.FROST_WALKER)) {
|
||||
frostWalkerLevel = itemEnchantments.getLevel(enchant);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.frostWalker = frostWalkerLevel;
|
||||
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
|
||||
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
|
||||
this.allowDownward = Baritone.settings().allowDownward.value;
|
||||
this.minFallHeight = 3; // Minimum fall height used by MovementFall
|
||||
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.value;
|
||||
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.value;
|
||||
int depth = EnchantmentHelper.getDepthStrider(player);
|
||||
if (depth > 3) {
|
||||
depth = 3;
|
||||
float waterSpeedMultiplier = 1.0f;
|
||||
OUTER: for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemEnchantments itemEnchantments = baritone.getPlayerContext()
|
||||
.player()
|
||||
.getItemBySlot(slot)
|
||||
.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
List<EnchantmentAttributeEffect> effects = enchant.value()
|
||||
.getEffects(EnchantmentEffectComponents.ATTRIBUTES);
|
||||
for (EnchantmentAttributeEffect effect : effects) {
|
||||
if (effect.attribute().is(Attributes.WATER_MOVEMENT_EFFICIENCY.unwrapKey().get())) {
|
||||
waterSpeedMultiplier = effect.amount().calculate(itemEnchantments.getLevel(enchant));
|
||||
break OUTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float mult = depth / 3.0F;
|
||||
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult;
|
||||
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - waterSpeedMultiplier) + ActionCosts.WALK_ONE_BLOCK_COST * waterSpeedMultiplier;
|
||||
this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.value;
|
||||
this.backtrackCostFavoringCoefficient = Baritone.settings().backtrackCostFavoringCoefficient.value;
|
||||
this.jumpPenalty = Baritone.settings().jumpPenalty.value;
|
||||
|
||||
@@ -31,7 +31,11 @@ import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.ItemEnchantments;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.piston.MovingPistonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -500,14 +504,27 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
static boolean canUseFrostWalker(CalculationContext context, BlockState state) {
|
||||
return context.frostWalker != 0
|
||||
&& state == FrostedIceBlock.meltsInto()
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
&& state.getValue(LiquidBlock.LEVEL) == 0;
|
||||
}
|
||||
|
||||
static boolean canUseFrostWalker(IPlayerContext ctx, BlockPos pos) {
|
||||
boolean hasFrostWalker = false;
|
||||
OUTER: for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemEnchantments itemEnchantments = ctx
|
||||
.player()
|
||||
.getItemBySlot(slot)
|
||||
.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
if (enchant.is(Enchantments.FROST_WALKER)) {
|
||||
hasFrostWalker = true;
|
||||
break OUTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockState state = BlockStateInterface.get(ctx, pos);
|
||||
return EnchantmentHelper.hasFrostWalker(ctx.player())
|
||||
return hasFrostWalker
|
||||
&& state == FrostedIceBlock.meltsInto()
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
&& state.getValue(LiquidBlock.LEVEL) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -31,6 +31,7 @@ import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.PathRenderer;
|
||||
import baritone.utils.accessor.IFireworkRocketEntity;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
||||
import it.unimi.dsi.fastutil.floats.FloatIterator;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -424,28 +425,28 @@ public final class ElytraBehavior implements Helper {
|
||||
PathRenderer.drawGoal(event.getModelViewStack(), ctx, new GoalBlock(this.aimPos), event.getPartialTicks(), Color.GREEN);
|
||||
}
|
||||
if (!this.clearLines.isEmpty() && settings.elytraRenderRaytraces.value) {
|
||||
IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
for (Pair<Vec3, Vec3> line : this.clearLines) {
|
||||
IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) {
|
||||
IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
for (Pair<Vec3, Vec3> line : this.blockedLines) {
|
||||
IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (this.simulationLine != null && Baritone.settings().elytraRenderSimulation.value) {
|
||||
IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
final Vec3 offset = ctx.player().getPosition(event.getPartialTicks());
|
||||
for (int i = 0; i < this.simulationLine.size() - 1; i++) {
|
||||
final Vec3 src = this.simulationLine.get(i).add(offset);
|
||||
final Vec3 dst = this.simulationLine.get(i + 1).add(offset);
|
||||
IRenderer.emitLine(event.getModelViewStack(), src, dst);
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), src, dst);
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import baritone.api.event.events.RenderEvent;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.selection.ISelection;
|
||||
import baritone.utils.IRenderer;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
@@ -28,27 +29,27 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(stack, selection.aabb(), SELECTION_BOX_EXPANSION);
|
||||
IRenderer.emitAABB(bufferBuilder, stack, selection.aabb(), SELECTION_BOX_EXPANSION);
|
||||
}
|
||||
|
||||
if (settings.renderSelectionCorners.value) {
|
||||
IRenderer.glColor(settings.colorSelectionPos1.value, opacity);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(stack, new AABB(selection.pos1()));
|
||||
IRenderer.emitAABB(bufferBuilder, stack, new AABB(selection.pos1()));
|
||||
}
|
||||
|
||||
IRenderer.glColor(settings.colorSelectionPos2.value, opacity);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(stack, new AABB(selection.pos2()));
|
||||
IRenderer.emitAABB(bufferBuilder, stack, new AABB(selection.pos2()));
|
||||
}
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
IRenderer.endLines(bufferBuilder, ignoreDepth);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
@@ -126,11 +127,11 @@ public class GuiClick extends Screen implements Helper {
|
||||
// drawSingleSelectionBox WHEN?
|
||||
PathRenderer.drawManySelectionBoxes(modelViewStack, e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||
IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
|
||||
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
||||
BetterBlockPos b = new BetterBlockPos(clickStart);
|
||||
IRenderer.emitAABB(modelViewStack, new AABB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||
IRenderer.endLines(true);
|
||||
IRenderer.emitAABB(bufferBuilder, modelViewStack, new AABB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||
IRenderer.endLines(bufferBuilder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,19 +24,19 @@ 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;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public interface IRenderer {
|
||||
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuilder();
|
||||
IEntityRenderManager renderManager = (IEntityRenderManager) Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
|
||||
Settings settings = BaritoneAPI.getSettings();
|
||||
@@ -51,9 +51,9 @@ public interface IRenderer {
|
||||
IRenderer.color[3] = alpha;
|
||||
}
|
||||
|
||||
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
|
||||
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,
|
||||
@@ -68,16 +68,20 @@ public interface IRenderer {
|
||||
if (ignoreDepth) {
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
|
||||
buffer.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
|
||||
RenderSystem.setShader(CoreShaders.RENDERTYPE_LINES);
|
||||
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
|
||||
}
|
||||
|
||||
static void startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
startLines(color, .4f, lineWidth, ignoreDepth);
|
||||
static BufferBuilder startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
return startLines(color, .4f, lineWidth, ignoreDepth);
|
||||
}
|
||||
|
||||
static void endLines(boolean ignoredDepth) {
|
||||
tessellator.end();
|
||||
static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) {
|
||||
MeshData meshData = bufferBuilder.build();
|
||||
if (meshData != null) {
|
||||
BufferUploader.drawWithShader(meshData);
|
||||
}
|
||||
|
||||
if (ignoredDepth) {
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
@@ -87,7 +91,7 @@ public interface IRenderer {
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
final double dx = x2 - x1;
|
||||
final double dy = y2 - y1;
|
||||
final double dz = z2 - z1;
|
||||
@@ -97,59 +101,59 @@ public interface IRenderer {
|
||||
final float ny = (float) (dy * invMag);
|
||||
final float nz = (float) (dz * invMag);
|
||||
|
||||
emitLine(stack, x1, y1, z1, x2, y2, z2, nx, ny, nz);
|
||||
emitLine(bufferBuilder, stack, x1, y1, z1, x2, y2, z2, nx, ny, nz);
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack,
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack,
|
||||
double x1, double y1, double z1,
|
||||
double x2, double y2, double z2,
|
||||
double nx, double ny, double nz) {
|
||||
emitLine(stack,
|
||||
emitLine(bufferBuilder, stack,
|
||||
(float) x1, (float) y1, (float) z1,
|
||||
(float) x2, (float) y2, (float) z2,
|
||||
(float) nx, (float) ny, (float) nz
|
||||
);
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack,
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float nx, float ny, float nz) {
|
||||
PoseStack.Pose pose = stack.last();
|
||||
|
||||
buffer.vertex(pose, x1, y1, z1).color(color[0], color[1], color[2], color[3]).normal(pose, nx, ny, nz).endVertex();
|
||||
buffer.vertex(pose, x2, y2, z2).color(color[0], color[1], color[2], color[3]).normal(pose, nx, ny, nz).endVertex();
|
||||
bufferBuilder.addVertex(pose, x1, y1, z1).setColor(color[0], color[1], color[2], color[3]).setNormal(pose, nx, ny, nz);
|
||||
bufferBuilder.addVertex(pose, x2, y2, z2).setColor(color[0], color[1], color[2], color[3]).setNormal(pose, nx, ny, nz);
|
||||
}
|
||||
|
||||
static void emitAABB(PoseStack stack, AABB aabb) {
|
||||
static void emitAABB(BufferBuilder bufferBuilder, PoseStack stack, AABB aabb) {
|
||||
AABB toDraw = aabb.move(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ());
|
||||
|
||||
// bottom
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
// top
|
||||
emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
// corners
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
static void emitAABB(PoseStack stack, AABB aabb, double expand) {
|
||||
emitAABB(stack, aabb.inflate(expand, expand, expand));
|
||||
static void emitAABB(BufferBuilder bufferBuilder, PoseStack stack, AABB aabb, double expand) {
|
||||
emitAABB(bufferBuilder, stack, aabb.inflate(expand, expand, expand));
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack, Vec3 start, Vec3 end) {
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, Vec3 start, Vec3 end) {
|
||||
double vpX = renderManager.renderPosX();
|
||||
double vpY = renderManager.renderPosY();
|
||||
double vpZ = renderManager.renderPosZ();
|
||||
emitLine(stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ);
|
||||
emitLine(bufferBuilder, stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.pathing.path.PathExecutor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -37,6 +38,7 @@ import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
@@ -50,7 +52,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class PathRenderer implements IRenderer {
|
||||
|
||||
private static final ResourceLocation TEXTURE_BEACON_BEAM = new ResourceLocation("textures/entity/beacon_beam.png");
|
||||
private static final ResourceLocation TEXTURE_BEACON_BEAM = ResourceLocation.parse("textures/entity/beacon_beam.png");
|
||||
|
||||
|
||||
private PathRenderer() {}
|
||||
@@ -133,7 +135,7 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
public static void drawPath(PoseStack stack, List<BetterBlockPos> positions, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0, double offset) {
|
||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
|
||||
int fadeStart = fadeStart0 + startIndex;
|
||||
int fadeEnd = fadeEnd0 + startIndex;
|
||||
@@ -167,13 +169,13 @@ public final class PathRenderer implements IRenderer {
|
||||
IRenderer.glColor(color, alpha);
|
||||
}
|
||||
|
||||
emitPathLine(stack, start.x, start.y, start.z, end.x, end.y, end.z, offset);
|
||||
emitPathLine(bufferBuilder, stack, start.x, start.y, start.z, end.x, end.y, end.z, offset);
|
||||
}
|
||||
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
|
||||
private static void emitPathLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, double offset) {
|
||||
private static void emitPathLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, double offset) {
|
||||
final double extraOffset = offset + 0.03D;
|
||||
|
||||
double vpX = posX();
|
||||
@@ -181,20 +183,20 @@ public final class PathRenderer implements IRenderer {
|
||||
double vpZ = posZ();
|
||||
boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value;
|
||||
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x1 + offset - vpX, y1 + offset - vpY, z1 + offset - vpZ,
|
||||
x2 + offset - vpX, y2 + offset - vpY, z2 + offset - vpZ
|
||||
);
|
||||
if (renderPathAsFrickinThingy) {
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x2 + offset - vpX, y2 + offset - vpY, z2 + offset - vpZ,
|
||||
x2 + offset - vpX, y2 + extraOffset - vpY, z2 + offset - vpZ
|
||||
);
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x2 + offset - vpX, y2 + extraOffset - vpY, z2 + offset - vpZ,
|
||||
x1 + offset - vpX, y1 + extraOffset - vpY, z1 + offset - vpZ
|
||||
);
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x1 + offset - vpX, y1 + extraOffset - vpY, z1 + offset - vpZ,
|
||||
x1 + offset - vpX, y1 + offset - vpY, z1 + offset - vpZ
|
||||
);
|
||||
@@ -202,7 +204,7 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
public static void drawManySelectionBoxes(PoseStack stack, Entity player, Collection<BlockPos> positions, Color color) {
|
||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
|
||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
||||
@@ -212,17 +214,20 @@ public final class PathRenderer implements IRenderer {
|
||||
VoxelShape shape = state.getShape(player.level(), pos);
|
||||
AABB toDraw = shape.isEmpty() ? Shapes.block().bounds() : shape.bounds();
|
||||
toDraw = toDraw.move(pos);
|
||||
IRenderer.emitAABB(stack, toDraw, .002D);
|
||||
IRenderer.emitAABB(bufferBuilder, stack, toDraw, .002D);
|
||||
});
|
||||
|
||||
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
}
|
||||
|
||||
public static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color) {
|
||||
drawGoal(stack, ctx, goal, partialTicks, color, true);
|
||||
drawGoal(null, stack, ctx, goal, partialTicks, color, true);
|
||||
}
|
||||
|
||||
private static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color, boolean setupRender) {
|
||||
private static void drawGoal(@Nullable BufferBuilder bufferBuilder, PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color, boolean setupRender) {
|
||||
if (!setupRender && bufferBuilder == null) {
|
||||
throw new RuntimeException("BufferBuilder must not be null if setupRender is false");
|
||||
}
|
||||
double renderPosX = posX();
|
||||
double renderPosY = posY();
|
||||
double renderPosZ = posZ();
|
||||
@@ -254,15 +259,15 @@ public final class PathRenderer implements IRenderer {
|
||||
y2 -= 0.5;
|
||||
maxY--;
|
||||
}
|
||||
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
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();
|
||||
}
|
||||
@@ -280,7 +285,7 @@ public final class PathRenderer implements IRenderer {
|
||||
settings.renderGoalAnimated.value ? ctx.world().getGameTime() : 0,
|
||||
(int) minY,
|
||||
(int) maxY,
|
||||
color.getColorComponents(null),
|
||||
color.getRGB(),
|
||||
|
||||
// Arguments filled by the private method lol
|
||||
0.2F,
|
||||
@@ -304,19 +309,19 @@ public final class PathRenderer implements IRenderer {
|
||||
y2 = 0;
|
||||
minY -= renderPosY;
|
||||
maxY -= renderPosY;
|
||||
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
} else if (goal instanceof GoalComposite) {
|
||||
// Simple way to determine if goals can be batched, without having some sort of GoalRenderer
|
||||
boolean batch = Arrays.stream(((GoalComposite) goal).goals()).allMatch(IGoalRenderPos.class::isInstance);
|
||||
|
||||
BufferBuilder buf = bufferBuilder;
|
||||
if (batch) {
|
||||
IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
buf = IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
for (Goal g : ((GoalComposite) goal).goals()) {
|
||||
drawGoal(stack, ctx, g, partialTicks, color, !batch);
|
||||
drawGoal(buf, stack, ctx, g, partialTicks, color, !batch);
|
||||
}
|
||||
if (batch) {
|
||||
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
||||
IRenderer.endLines(buf, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
} else if (goal instanceof GoalInverted) {
|
||||
drawGoal(stack, ctx, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
|
||||
@@ -330,37 +335,37 @@ public final class PathRenderer implements IRenderer {
|
||||
maxY = minY + 2;
|
||||
y1 = 1 + y + goalpos.level - renderPosY;
|
||||
y2 = 1 - y + goalpos.level - renderPosY;
|
||||
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double minX, double maxX, double minZ, double maxZ, double minY, double maxY, double y1, double y2, boolean setupRender) {
|
||||
private static void drawDankLitGoalBox(BufferBuilder bufferBuilder, PoseStack stack, Color colorIn, double minX, double maxX, double minZ, double maxZ, double minY, double maxY, double y1, double y2, boolean setupRender) {
|
||||
if (setupRender) {
|
||||
IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
bufferBuilder = IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
|
||||
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1);
|
||||
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2);
|
||||
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y1);
|
||||
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y2);
|
||||
|
||||
for (double y = minY; y < maxY; y += 16) {
|
||||
double max = Math.min(maxY, y + 16);
|
||||
IRenderer.emitLine(stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
if (setupRender) {
|
||||
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderHorizontalQuad(PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
|
||||
private static void renderHorizontalQuad(BufferBuilder bufferBuilder, PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
|
||||
if (y != 0) {
|
||||
IRenderer.emitLine(stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0);
|
||||
IRenderer.emitLine(stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,24 @@ 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.EnchantmentHelper;
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -52,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;
|
||||
@@ -76,24 +98,30 @@ 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) {
|
||||
return EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0;
|
||||
ItemEnchantments enchantments = stack.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : enchantments.keySet()) {
|
||||
// silk touch enchantment is still special cased as affecting block drops
|
||||
// not possible to add custom attribute via datapack
|
||||
if (enchant.is(Enchantments.SILK_TOUCH) && enchantments.getLevel(enchant) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,9 +218,15 @@ public class ToolSet {
|
||||
|
||||
float speed = item.getDestroySpeed(state);
|
||||
if (speed > 1) {
|
||||
int effLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.EFFICIENCY, item);
|
||||
if (effLevel > 0 && !item.isEmpty()) {
|
||||
speed += effLevel * effLevel + 1;
|
||||
final ItemEnchantments itemEnchantments = item.getEnchantments();
|
||||
OUTER: for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
List<EnchantmentAttributeEffect> effects = enchant.value().getEffects(EnchantmentEffectComponents.ATTRIBUTES);
|
||||
for (EnchantmentAttributeEffect e : effects) {
|
||||
if (e.attribute().is(Attributes.MINING_EFFICIENCY.unwrapKey().get())) {
|
||||
speed += e.amount().calculate(itemEnchantments.getLevel(enchant));
|
||||
break OUTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,9 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
|
||||
case 4: //1.12
|
||||
case 5: //1.13-1.17
|
||||
throw new UnsupportedOperationException("This litematic Version is too old.");
|
||||
case 6: //1.18+
|
||||
case 6: //1.18-1.20
|
||||
throw new UnsupportedOperationException("This litematic Version is too old.");
|
||||
case 7: //1.21+
|
||||
return new LitematicaSchematic(nbt);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsuported Version of a Litematica Schematic");
|
||||
|
||||
@@ -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(new ResourceLocation((((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);
|
||||
}
|
||||
@@ -273,4 +281,4 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
return this.arraySize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 -> {
|
||||
@@ -130,7 +135,7 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
String location = m.group("location");
|
||||
String properties = m.group("properties");
|
||||
|
||||
ResourceLocation resourceLocation = new ResourceLocation(location);
|
||||
ResourceLocation resourceLocation = ResourceLocation.parse(location);
|
||||
Map<String, String> propertiesMap = new HashMap<>();
|
||||
if (properties != null) {
|
||||
for (String property : properties.split(",")) {
|
||||
|
||||
@@ -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