Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d5617ff62 | ||
|
|
6e07cb78d8 | ||
|
|
72dcabd84c | ||
|
|
78352721ca | ||
|
|
69c745226a | ||
|
|
612a8a6dc3 | ||
|
|
9ca631e1b1 | ||
|
|
e360cdae53 | ||
|
|
48a45ecb4c | ||
|
|
c079a92c09 | ||
|
|
224bc79834 | ||
|
|
e6fd85cd42 | ||
|
|
0ecbfdc585 | ||
|
|
3fdb743836 | ||
|
|
6b9fb07cd9 | ||
|
|
561a4d2634 | ||
|
|
d59ae28d5f | ||
|
|
fb10bf51c9 | ||
|
|
b1d3675354 | ||
|
|
801ade9d93 | ||
|
|
70b010dc63 | ||
|
|
3b5e229d14 | ||
|
|
408028e338 | ||
|
|
897ccda927 | ||
|
|
429ef5874b | ||
|
|
42015d4a7f | ||
|
|
0120256fb1 | ||
|
|
9663031ad8 | ||
|
|
cfb7970e71 | ||
|
|
d927cc7b44 | ||
|
|
c630969aa5 | ||
|
|
ce6079c203 | ||
|
|
a0f100f473 | ||
|
|
94a677f239 | ||
|
|
485bec0572 | ||
|
|
9324fb7d24 | ||
|
|
9d5db72806 | ||
|
|
b14c75804d | ||
|
|
fd4fbf5df5 | ||
|
|
7e8c8501a7 | ||
|
|
55cb180755 |
2
SETUP.md
2
SETUP.md
@@ -56,7 +56,7 @@ The recommended Java versions by Minecraft version are
|
||||
| 1.12.2 - 1.16.5 | 8 |
|
||||
| 1.17.1 | 16 |
|
||||
| 1.18.2 - 1.20.4 | 17 |
|
||||
| 1.20.5 - 1.21.4 | 21 |
|
||||
| 1.20.5 - 1.21.5 | 21 |
|
||||
|
||||
Download java: https://adoptium.net/
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ allprojects {
|
||||
mappings {
|
||||
intermediary()
|
||||
mojmap()
|
||||
parchment("1.20.6", "2024.05.01")
|
||||
parchment("1.21.4", "2025.03.23")
|
||||
|
||||
devFallbackNamespace "official"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"contact": {
|
||||
"homepage": "https://github.com/cabaletta/baritone",
|
||||
"sources": "https://github.com/cabaletta/baritone",
|
||||
"issues": "https://github.com/cabaletta/baritone/issues"
|
||||
"issues": "https://github.com/cabaletta/baritone/issues"
|
||||
},
|
||||
|
||||
"license": "LGPL-3.0",
|
||||
@@ -23,10 +23,9 @@
|
||||
"mixins": [
|
||||
"mixins.baritone.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.22",
|
||||
"minecraft": ["1.21","1.21.1"]
|
||||
"minecraft": ["1.21.9", "1.21.10"]
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
|
||||
@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.21, 1.21.1]"
|
||||
versionRange="[1.21.9, 1.21.10]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
org.gradle.jvmargs=-Xmx4G
|
||||
|
||||
available_loaders=fabric,forge,neoforge,tweaker
|
||||
available_loaders=fabric,neoforge,forge,tweaker
|
||||
|
||||
mod_version=1.11.2
|
||||
mod_version=1.16.0
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
java_version=21
|
||||
|
||||
minecraft_version=1.21
|
||||
minecraft_version=1.21.10
|
||||
|
||||
forge_version=51.0.16
|
||||
forge_version=60.0.0
|
||||
|
||||
neoforge_version=20-beta
|
||||
neoforge_version=1-beta
|
||||
|
||||
fabric_version=0.15.11
|
||||
fabric_version=0.17.2
|
||||
|
||||
nether_pathfinder_version=1.4.1
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ archivesBaseName = archivesBaseName + "-neoforge"
|
||||
|
||||
unimined.minecraft {
|
||||
|
||||
neoForged {
|
||||
neoForge {
|
||||
loader project.neoforge_version
|
||||
mixinConfig ["mixins.baritone.json"]
|
||||
}
|
||||
|
||||
@@ -35,6 +35,9 @@ A Minecraft pathfinder bot.
|
||||
modId="minecraft"
|
||||
type="required"
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.21,1.21.1]"
|
||||
versionRange="[1.21.9, 1.21.10]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
[[mixins]]
|
||||
config = "mixins.baritone.json"
|
||||
|
||||
4
scripts/proguard.pro
vendored
4
scripts/proguard.pro
vendored
@@ -41,7 +41,7 @@
|
||||
|
||||
# setting names are reflected from field names, so keep field names
|
||||
-keepclassmembers class baritone.api.Settings {
|
||||
public <fields>;
|
||||
public <fields>;
|
||||
}
|
||||
|
||||
# need to keep mixin names
|
||||
@@ -346,4 +346,4 @@
|
||||
public int length();
|
||||
public java.lang.String substring(int);
|
||||
public java.lang.String substring(int,int);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -21,17 +21,16 @@ import baritone.api.command.argument.IArgConsumer;
|
||||
import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||
import baritone.api.utils.Helper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Paginator<E> implements Helper {
|
||||
|
||||
public final List<E> entries;
|
||||
@@ -78,12 +77,10 @@ public class Paginator<E> implements Helper {
|
||||
MutableComponent prevPageComponent = Component.literal("<<");
|
||||
if (hasPrevPage) {
|
||||
prevPageComponent.setStyle(prevPageComponent.getStyle()
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
.withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format("%s %d", commandPrefix, page - 1)
|
||||
))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
.withHoverEvent(new HoverEvent.ShowText(
|
||||
Component.literal("Click to view previous page")
|
||||
)));
|
||||
} else {
|
||||
@@ -92,9 +89,8 @@ public class Paginator<E> implements Helper {
|
||||
MutableComponent nextPageComponent = Component.literal(">>");
|
||||
if (hasNextPage) {
|
||||
nextPageComponent.setStyle(nextPageComponent.getStyle()
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("%s %d", commandPrefix, page + 1)))
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
.withClickEvent(new ClickEvent.RunCommand(String.format("%s %d", commandPrefix, page + 1)))
|
||||
.withHoverEvent(new HoverEvent.ShowText(
|
||||
Component.literal("Click to view next page")
|
||||
)));
|
||||
} else {
|
||||
|
||||
@@ -157,7 +157,7 @@ public final class BetterBlockPos extends BlockPos {
|
||||
|
||||
@Override
|
||||
public BetterBlockPos relative(Direction dir) {
|
||||
Vec3i vec = dir.getNormal();
|
||||
Vec3i vec = dir.getUnitVec3i();
|
||||
return new BetterBlockPos(x + vec.getX(), y + vec.getY(), z + vec.getZ());
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public final class BetterBlockPos extends BlockPos {
|
||||
if (dist == 0) {
|
||||
return this;
|
||||
}
|
||||
Vec3i vec = dir.getNormal();
|
||||
Vec3i vec = dir.getUnitVec3i();
|
||||
return new BetterBlockPos(x + vec.getX() * dist, y + vec.getY() * dist, z + vec.getZ() * dist);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,32 +21,25 @@ import baritone.api.utils.accessor.IItemStack;
|
||||
import baritone.api.utils.accessor.ILootTable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.RegistryAccess;
|
||||
import net.minecraft.resources.RegistryDataLoader;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.RegistryLayer;
|
||||
import net.minecraft.server.ReloadableServerRegistries;
|
||||
import net.minecraft.server.ReloadableServerResources;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
import net.minecraft.server.packs.VanillaPackResources;
|
||||
import net.minecraft.server.packs.repository.BuiltInPackSource;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.ServerPacksSource;
|
||||
import net.minecraft.server.packs.resources.CloseableResourceManager;
|
||||
import net.minecraft.server.packs.resources.MultiPackResourceManager;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.tags.TagLoader;
|
||||
import net.minecraft.world.RandomSequences;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
@@ -58,7 +51,6 @@ import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import net.minecraft.world.level.storage.ServerLevelData;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
@@ -231,8 +223,8 @@ public final class BlockOptionalMeta {
|
||||
|
||||
private static synchronized List<Item> drops(Block b) {
|
||||
return drops.computeIfAbsent(b, block -> {
|
||||
ResourceLocation lootTableLocation = block.getLootTable().location();
|
||||
if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) {
|
||||
Optional<ResourceKey<LootTable>> optionalLootTableKey = block.getLootTable();
|
||||
if (optionalLootTableKey.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Item> items = new ArrayList<>();
|
||||
@@ -253,13 +245,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));
|
||||
}
|
||||
}
|
||||
@@ -269,8 +261,8 @@ public final class BlockOptionalMeta {
|
||||
private static Unsafe unsafe = getUnsafe();
|
||||
private static CompletableFuture<RegistryAccess> registryAccess = load();
|
||||
|
||||
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, ChunkProgressListener $$6, boolean $$7, long $$8, List<CustomSpawner> $$9, boolean $$10, @Nullable RandomSequences $$11) {
|
||||
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10, $$11);
|
||||
public ServerLevelStub(MinecraftServer $$0, Executor $$1, LevelStorageSource.LevelStorageAccess $$2, ServerLevelData $$3, ResourceKey<Level> $$4, LevelStem $$5, boolean $$6, long $$7, List<CustomSpawner> $$8, boolean $$9, @Nullable RandomSequences $$10) {
|
||||
super($$0, $$1, $$2, $$3, $$4, $$5, $$6, $$7, $$8, $$9, $$10);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -307,44 +299,33 @@ public final class BlockOptionalMeta {
|
||||
}
|
||||
|
||||
public static CompletableFuture<RegistryAccess> load() {
|
||||
PackRepository packRepository = Minecraft.getInstance().getResourcePackRepository();
|
||||
// Simplified from {@link net.minecraft.server.WorldLoader#load()}
|
||||
CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(
|
||||
PackType.SERVER_DATA,
|
||||
List.of(packRepository.getPack(BuiltInPackSource.VANILLA_ID).open())
|
||||
List.of(ServerPacksSource.createVanillaPackSource())
|
||||
);
|
||||
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = loadAndReplaceLayer(
|
||||
closeableResourceManager, RegistryLayer.createRegistryAccess(), RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES
|
||||
LayeredRegistryAccess<RegistryLayer> baseLayeredRegistry = RegistryLayer.createRegistryAccess();
|
||||
List<Registry.PendingTags<?>> pendingTags = TagLoader.loadTagsForExistingRegistries(
|
||||
closeableResourceManager, baseLayeredRegistry.getLayer(RegistryLayer.STATIC)
|
||||
);
|
||||
return ReloadableServerResources.loadResources(
|
||||
closeableResourceManager,
|
||||
List<HolderLookup.RegistryLookup<?>> worldGenRegistryLookupList = TagLoader.buildUpdatedLookups(
|
||||
baseLayeredRegistry.getAccessForLoading(RegistryLayer.WORLDGEN),
|
||||
pendingTags
|
||||
);
|
||||
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = baseLayeredRegistry.replaceFrom(
|
||||
RegistryLayer.WORLDGEN,
|
||||
RegistryDataLoader.load(
|
||||
closeableResourceManager,
|
||||
worldGenRegistryLookupList,
|
||||
RegistryDataLoader.WORLDGEN_REGISTRIES
|
||||
)
|
||||
);
|
||||
return ReloadableServerRegistries.reload(
|
||||
layeredRegistryAccess,
|
||||
FeatureFlags.VANILLA_SET,
|
||||
Commands.CommandSelection.INTEGRATED,
|
||||
2,
|
||||
Runnable::run,
|
||||
pendingTags,
|
||||
closeableResourceManager,
|
||||
Minecraft.getInstance()
|
||||
).thenApply(reloadableServerResources -> reloadableServerResources.fullRegistries().get());
|
||||
).thenApply(r -> r.layers().compositeAccess());
|
||||
}
|
||||
|
||||
private static LayeredRegistryAccess<RegistryLayer> loadAndReplaceLayer(
|
||||
ResourceManager resourceManager,
|
||||
LayeredRegistryAccess<RegistryLayer> registryAccess,
|
||||
RegistryLayer registryLayer,
|
||||
List<RegistryDataLoader.RegistryData<?>> registryData
|
||||
) {
|
||||
RegistryAccess.Frozen frozen = loadLayer(resourceManager, registryAccess, registryLayer, registryData);
|
||||
return registryAccess.replaceFrom(registryLayer, frozen);
|
||||
}
|
||||
|
||||
private static RegistryAccess.Frozen loadLayer(
|
||||
ResourceManager resourceManager,
|
||||
LayeredRegistryAccess<RegistryLayer> registryAccess,
|
||||
RegistryLayer registryLayer,
|
||||
List<RegistryDataLoader.RegistryData<?>> registryData
|
||||
) {
|
||||
RegistryAccess.Frozen frozen = registryAccess.getAccessForLoading(registryLayer);
|
||||
return RegistryDataLoader.load(resourceManager, frozen, registryData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -245,8 +246,8 @@ public class SettingsUtil {
|
||||
BlockUtils::blockToString
|
||||
),
|
||||
ITEM(
|
||||
Item.class,
|
||||
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
Item.class,
|
||||
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())).map(Holder.Reference::value).orElse(null),
|
||||
item -> BuiltInRegistries.ITEM.getKey(item).toString()
|
||||
),
|
||||
LIST() {
|
||||
|
||||
@@ -17,65 +17,13 @@
|
||||
|
||||
package baritone.api.utils.gui;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.toasts.Toast;
|
||||
import net.minecraft.client.gui.components.toasts.ToastComponent;
|
||||
import net.minecraft.client.gui.components.toasts.SystemToast;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class BaritoneToast implements Toast {
|
||||
private String title;
|
||||
private String subtitle;
|
||||
private long firstDrawTime;
|
||||
private boolean newDisplay;
|
||||
private long totalShowTime;
|
||||
|
||||
public BaritoneToast(Component titleComponent, Component subtitleComponent, long totalShowTime) {
|
||||
this.title = titleComponent.getString();
|
||||
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
|
||||
this.totalShowTime = totalShowTime;
|
||||
}
|
||||
|
||||
public Visibility render(GuiGraphics gui, ToastComponent toastGui, long delta) {
|
||||
if (this.newDisplay) {
|
||||
this.firstDrawTime = delta;
|
||||
this.newDisplay = false;
|
||||
}
|
||||
|
||||
|
||||
//TODO: check
|
||||
gui.blit(ResourceLocation.parse("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
|
||||
|
||||
if (this.subtitle == null) {
|
||||
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 12, -11534256);
|
||||
} else {
|
||||
gui.drawString(toastGui.getMinecraft().font, this.title, 18, 7, -11534256);
|
||||
gui.drawString(toastGui.getMinecraft().font, this.subtitle, 18, 18, -16777216);
|
||||
}
|
||||
|
||||
return delta - this.firstDrawTime < totalShowTime ? Visibility.SHOW : Visibility.HIDE;
|
||||
}
|
||||
|
||||
public void setDisplayedText(Component titleComponent, Component subtitleComponent) {
|
||||
this.title = titleComponent.getString();
|
||||
this.subtitle = subtitleComponent == null ? null : subtitleComponent.getString();
|
||||
this.newDisplay = true;
|
||||
}
|
||||
|
||||
public static void addOrUpdate(ToastComponent toast, Component title, Component subtitle, long totalShowTime) {
|
||||
BaritoneToast baritonetoast = toast.getToast(BaritoneToast.class, new Object());
|
||||
|
||||
if (baritonetoast == null) {
|
||||
toast.addToast(new BaritoneToast(title, subtitle, totalShowTime));
|
||||
} else {
|
||||
baritonetoast.setDisplayedText(title, subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
public class BaritoneToast {
|
||||
private static final SystemToast.SystemToastId BARITONE_TOAST_ID = new SystemToast.SystemToastId(5000L);
|
||||
public static void addOrUpdate(Component title, Component subtitle) {
|
||||
addOrUpdate(Minecraft.getInstance().getToasts(), title, subtitle, baritone.api.BaritoneAPI.getSettings().toastTimer.value);
|
||||
SystemToast.addOrUpdate(Minecraft.getInstance().getToastManager(), BARITONE_TOAST_ID, title, subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,9 @@ import baritone.api.event.events.PlayerUpdateEvent;
|
||||
import baritone.api.event.events.SprintStateEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.behavior.LookBehavior;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.entity.player.Abilities;
|
||||
import net.minecraft.world.entity.player.Input;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -110,13 +110,13 @@ public class MixinClientPlayerEntity {
|
||||
method = "aiStep",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/client/KeyMapping.isDown()Z"
|
||||
target = "Lnet/minecraft/world/entity/player/Input;sprint()Z"
|
||||
)
|
||||
)
|
||||
private boolean isKeyDown(KeyMapping keyBinding) {
|
||||
private boolean redirectSprintInput(final Input instance) {
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getBaritoneForPlayer((LocalPlayer) (Object) this);
|
||||
if (baritone == null) {
|
||||
return keyBinding.isDown();
|
||||
return instance.sprint();
|
||||
}
|
||||
SprintStateEvent event = new SprintStateEvent();
|
||||
baritone.getGameEventHandler().onPlayerSprintState(event);
|
||||
@@ -127,7 +127,7 @@ public class MixinClientPlayerEntity {
|
||||
// hitting control shouldn't make all bots sprint
|
||||
return false;
|
||||
}
|
||||
return keyBinding.isDown();
|
||||
return instance.sprint();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
|
||||
@@ -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",
|
||||
target = "Lnet/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());
|
||||
|
||||
@@ -24,7 +24,6 @@ import baritone.api.event.events.TickEvent;
|
||||
import baritone.api.event.events.WorldEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.ReceivingLevelScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
@@ -131,7 +130,7 @@ public class MixinMinecraft {
|
||||
method = "setLevel",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) {
|
||||
private void preLoadWorld(final ClientLevel world, final CallbackInfo ci) {
|
||||
// If we're unloading the world but one doesn't exist, ignore it
|
||||
if (this.level == null && world == null) {
|
||||
return;
|
||||
@@ -151,7 +150,7 @@ public class MixinMinecraft {
|
||||
method = "setLevel",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) {
|
||||
private void postLoadWorld(final ClientLevel world, final CallbackInfo ci) {
|
||||
// still fire event for both null, as that means we've just finished exiting a world
|
||||
|
||||
// mc.world changing is only the primary baritone
|
||||
|
||||
@@ -22,9 +22,9 @@ import baritone.api.IBaritone;
|
||||
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;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class MixinNetworkManager {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.launch.mixins;
|
||||
|
||||
import baritone.utils.accessor.IRenderPipelines;
|
||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(RenderPipelines.class)
|
||||
public class MixinRenderPipelines implements IRenderPipelines {
|
||||
@Final @Shadow
|
||||
private static RenderPipeline.Snippet LINES_SNIPPET;
|
||||
|
||||
public RenderPipeline.Snippet getLinesSnippet() {
|
||||
return LINES_SNIPPET;
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,13 @@ import baritone.api.BaritoneAPI;
|
||||
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.gen.Invoker;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.net.URI;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
@@ -38,21 +35,19 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
public abstract class MixinScreen implements IGuiScreen {
|
||||
|
||||
//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) {
|
||||
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;
|
||||
}
|
||||
String command = clickEvent.getValue();
|
||||
if (command == null || !command.startsWith(FORCE_COMMAND_PREFIX)) {
|
||||
if (!(clickEvent instanceof ClickEvent.RunCommand(String command))) return;
|
||||
if (!command.startsWith(FORCE_COMMAND_PREFIX)) {
|
||||
return;
|
||||
}
|
||||
IBaritone baritone = BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
if (baritone != null) {
|
||||
baritone.getGameEventHandler().onSendChatMessage(new ChatEvent(command));
|
||||
}
|
||||
cir.setReturnValue(true);
|
||||
cir.cancel();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@ package baritone.launch.mixins;
|
||||
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 net.minecraft.client.renderer.LightTexture;
|
||||
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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -44,7 +44,7 @@ public class MixinWorldRenderer {
|
||||
method = "renderLevel",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void onStartHand(final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
|
||||
private void onStartHand(final GraphicsResourceAllocator graphicsResourceAllocator, final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final Matrix4f matrix4f, final Matrix4f matrix4f2, final Matrix4f matrix4f3, 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);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"MixinPalettedContainer",
|
||||
"MixinPalettedContainer$Data",
|
||||
"MixinPlayerController",
|
||||
"MixinRenderPipelines",
|
||||
"MixinScreen",
|
||||
"MixinWorldRenderer"
|
||||
],
|
||||
|
||||
@@ -24,13 +24,13 @@ import baritone.utils.ToolSet;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.DiggerItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -38,6 +38,7 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.Random;
|
||||
@@ -68,7 +69,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
if (firstValidThrowaway() >= 9) { // aka there are none on the hotbar, but there are some in main inventory
|
||||
requestSwapWithHotBar(firstValidThrowaway(), 8);
|
||||
}
|
||||
int pick = bestToolAgainst(Blocks.STONE, PickaxeItem.class);
|
||||
int pick = bestToolAgainst(Blocks.STONE);
|
||||
if (pick >= 9) {
|
||||
requestSwapWithHotBar(pick, 0);
|
||||
}
|
||||
@@ -92,7 +93,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
// we're using 0 and 8 for pickaxe and throwaway
|
||||
ArrayList<Integer> candidates = new ArrayList<>();
|
||||
for (int i = 1; i < 8; i++) {
|
||||
if (ctx.player().getInventory().items.get(i).isEmpty() && !disallowedHotbar.test(i)) {
|
||||
if (ctx.player().getInventory().getNonEquipmentItems().get(i).isEmpty() && !disallowedHotbar.test(i)) {
|
||||
candidates.add(i);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +127,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
}
|
||||
|
||||
private int firstValidThrowaway() { // TODO offhand idk
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().items;
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().getNonEquipmentItems();
|
||||
for (int i = 0; i < invy.size(); i++) {
|
||||
if (Baritone.settings().acceptableThrowawayItems.value.contains(invy.get(i).getItem())) {
|
||||
return i;
|
||||
@@ -135,8 +136,8 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int bestToolAgainst(Block against, Class<? extends DiggerItem> cla$$) {
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().items;
|
||||
private int bestToolAgainst(Block against) {
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().getNonEquipmentItems();
|
||||
int bestInd = -1;
|
||||
double bestSpeed = -1;
|
||||
for (int i = 0; i < invy.size(); i++) {
|
||||
@@ -147,7 +148,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
if (Baritone.settings().itemSaver.value && (stack.getDamageValue() + Baritone.settings().itemSaverThreshold.value) >= stack.getMaxDamage() && stack.getMaxDamage() > 1) {
|
||||
continue;
|
||||
}
|
||||
if (cla$$.isInstance(stack.getItem())) {
|
||||
if (stack.getItem().components().has(DataComponents.TOOL)) {
|
||||
double speed = ToolSet.calculateSpeedVsBlock(stack, against.defaultBlockState()); // takes into account enchants
|
||||
if (speed > bestSpeed) {
|
||||
bestSpeed = speed;
|
||||
@@ -189,7 +190,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
|
||||
public boolean throwaway(boolean select, Predicate<? super ItemStack> desired, boolean allowInventory) {
|
||||
LocalPlayer p = ctx.player();
|
||||
NonNullList<ItemStack> inv = p.getInventory().items;
|
||||
NonNullList<ItemStack> inv = p.getInventory().getNonEquipmentItems();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack item = inv.get(i);
|
||||
// this usage of settings() is okay because it's only called once during pathing
|
||||
@@ -199,12 +200,12 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
// acceptableThrowawayItems to the CalculationContext
|
||||
if (desired.test(item)) {
|
||||
if (select) {
|
||||
p.getInventory().selected = i;
|
||||
p.getInventory().setSelectedSlot(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (desired.test(p.getInventory().offhand.get(0))) {
|
||||
if (desired.test(p.getItemBySlot(EquipmentSlot.OFFHAND))) {
|
||||
// main hand takes precedence over off hand
|
||||
// that means that if we have block A selected in main hand and block B in off hand, right clicking places block B
|
||||
// we've already checked above ^ and the main hand can't possible have an acceptablethrowawayitem
|
||||
@@ -212,9 +213,9 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
// so not a shovel, not a hoe, not a block, etc
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack item = inv.get(i);
|
||||
if (item.isEmpty() || item.getItem() instanceof PickaxeItem) {
|
||||
if (item.isEmpty() || item.getItem().components().has(DataComponents.TOOL)) {
|
||||
if (select) {
|
||||
p.getInventory().selected = i;
|
||||
p.getInventory().setSelectedSlot(i);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -226,7 +227,7 @@ public final class InventoryBehavior extends Behavior implements Helper {
|
||||
if (desired.test(inv.get(i))) {
|
||||
if (select) {
|
||||
requestSwapWithHotBar(i, 7);
|
||||
p.getInventory().selected = 7;
|
||||
p.getInventory().setSelectedSlot(7);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,16 +33,18 @@ import baritone.pathing.calc.AbstractNodeCostSearch;
|
||||
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 {
|
||||
|
||||
@@ -158,7 +160,9 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -73,12 +73,10 @@ public class WaypointBehavior extends Behavior {
|
||||
MutableComponent component = Component.literal("Death position saved.");
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
.withHoverEvent(new HoverEvent.ShowText(
|
||||
Component.literal("Click to goto death")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
.withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s goto %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,19 +26,12 @@ import baritone.api.utils.IPlayerContext;
|
||||
import baritone.utils.accessor.IPalettedContainer;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.IdMapper;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.util.BitStorage;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.GlobalPalette;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.Palette;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.chunk.SingleValuePalette;
|
||||
import net.minecraft.world.level.chunk.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -156,7 +149,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 +158,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;
|
||||
@@ -289,7 +282,7 @@ public enum FasterWorldScanner implements IWorldScanner {
|
||||
return PALETTE_REGISTRY_SENTINEL;
|
||||
} else {
|
||||
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
palette.write(buf);
|
||||
palette.write(buf, Block.BLOCK_STATE_REGISTRY);
|
||||
int size = buf.readVarInt();
|
||||
BlockState[] states = new BlockState[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
||||
@@ -33,14 +33,14 @@ import baritone.behavior.Behavior;
|
||||
import baritone.command.argument.ArgConsumer;
|
||||
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.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Tuple;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
@@ -80,12 +80,10 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
||||
MutableComponent component = Component.literal(String.format("> %s", toDisplay));
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
.withHoverEvent(new HoverEvent.ShowText(
|
||||
Component.literal("Click to rerun command")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
.withClickEvent(new ClickEvent.RunCommand(
|
||||
FORCE_COMMAND_PREFIX + msg
|
||||
)));
|
||||
logDirect(component);
|
||||
|
||||
@@ -115,11 +115,11 @@ public class ElytraCommand extends Command {
|
||||
clippy.append("Within a few hundred blocks of spawn/axis/highways/etc, the terrain is too fragmented to be predictable. Baritone Elytra will still work, just with backtracking. ");
|
||||
clippy.append("However, once you get more than a few thousand blocks out, you should try ");
|
||||
MutableComponent olderSeed = Component.literal("the older seed (click here)");
|
||||
olderSeed.setStyle(olderSeed.getStyle().withUnderlined(true).withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraNetherSeed " + OLD_2B2T_SEED))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + "set elytraNetherSeed " + OLD_2B2T_SEED)));
|
||||
olderSeed.setStyle(olderSeed.getStyle().withUnderlined(true).withBold(true).withHoverEvent(new HoverEvent.ShowText(Component.literal(Baritone.settings().prefix.value + "set elytraNetherSeed " + OLD_2B2T_SEED))).withClickEvent(new ClickEvent.RunCommand(FORCE_COMMAND_PREFIX + "set elytraNetherSeed " + OLD_2B2T_SEED)));
|
||||
clippy.append(olderSeed);
|
||||
clippy.append(". Once you're further out into newer terrain generation (this includes everything up through 1.12), you should try ");
|
||||
MutableComponent newerSeed = Component.literal("the newer seed (click here)");
|
||||
newerSeed.setStyle(newerSeed.getStyle().withUnderlined(true).withBold(true).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraNetherSeed " + NEW_2B2T_SEED))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, FORCE_COMMAND_PREFIX + "set elytraNetherSeed " + NEW_2B2T_SEED)));
|
||||
newerSeed.setStyle(newerSeed.getStyle().withUnderlined(true).withBold(true).withHoverEvent(new HoverEvent.ShowText(Component.literal(Baritone.settings().prefix.value + "set elytraNetherSeed " + NEW_2B2T_SEED))).withClickEvent(new ClickEvent.RunCommand(FORCE_COMMAND_PREFIX + "set elytraNetherSeed " + NEW_2B2T_SEED)));
|
||||
clippy.append(newerSeed);
|
||||
clippy.append(". Once you get into 1.19 terrain, the terrain becomes unpredictable again, due to custom non-vanilla generation, and you should set #elytraPredictTerrain to false. ");
|
||||
return clippy;
|
||||
@@ -130,10 +130,10 @@ public class ElytraCommand extends Command {
|
||||
gatekeep.append("To disable this message, enable the setting elytraTermsAccepted\n");
|
||||
gatekeep.append("Baritone Elytra is an experimental feature. It is only intended for long distance travel in the Nether using fireworks for vanilla boost. It will not work with any other mods (\"hacks\") for non-vanilla boost. ");
|
||||
MutableComponent gatekeep2 = Component.literal("If you want Baritone to attempt to take off from the ground for you, you can enable the elytraAutoJump setting (not advisable on laggy servers!). ");
|
||||
gatekeep2.setStyle(gatekeep2.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraAutoJump true"))));
|
||||
gatekeep2.setStyle(gatekeep2.getStyle().withHoverEvent(new HoverEvent.ShowText(Component.literal(Baritone.settings().prefix.value + "set elytraAutoJump true"))));
|
||||
gatekeep.append(gatekeep2);
|
||||
MutableComponent gatekeep3 = Component.literal("If you want Baritone to go slower, enable the elytraConserveFireworks setting and/or decrease the elytraFireworkSpeed setting. ");
|
||||
gatekeep3.setStyle(gatekeep3.getStyle().withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(Baritone.settings().prefix.value + "set elytraConserveFireworks true\n" + Baritone.settings().prefix.value + "set elytraFireworkSpeed 0.6\n(the 0.6 number is just an example, tweak to your liking)"))));
|
||||
gatekeep3.setStyle(gatekeep3.getStyle().withHoverEvent(new HoverEvent.ShowText(Component.literal(Baritone.settings().prefix.value + "set elytraConserveFireworks true\n" + Baritone.settings().prefix.value + "set elytraFireworkSpeed 0.6\n(the 0.6 number is just an example, tweak to your liking)"))));
|
||||
gatekeep.append(gatekeep3);
|
||||
MutableComponent gatekeep4 = Component.literal("Baritone Elytra ");
|
||||
MutableComponent red = Component.literal("wants to know the seed");
|
||||
|
||||
@@ -25,7 +25,6 @@ import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.cache.CachedChunk;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
@@ -83,8 +82,8 @@ public class FindCommand extends Command {
|
||||
baseComponent.setStyle(baseComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withInsertion(positionText)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command))
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent)));
|
||||
.withClickEvent(new ClickEvent.RunCommand(command))
|
||||
.withHoverEvent(new HoverEvent.ShowText(hoverComponent)));
|
||||
return baseComponent;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,19 +25,17 @@ import baritone.api.command.exception.CommandException;
|
||||
import baritone.api.command.exception.CommandNotFoundException;
|
||||
import baritone.api.command.helpers.Paginator;
|
||||
import baritone.api.command.helpers.TabCompleteHelper;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
public class HelpCommand extends Command {
|
||||
@@ -74,8 +72,8 @@ public class HelpCommand extends Command {
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(shortDescComponent);
|
||||
component.setStyle(component.getStyle()
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, clickCommand)));
|
||||
.withHoverEvent(new HoverEvent.ShowText(hoverComponent))
|
||||
.withClickEvent(new ClickEvent.RunCommand(clickCommand)));
|
||||
return component;
|
||||
},
|
||||
FORCE_COMMAND_PREFIX + label
|
||||
@@ -91,8 +89,7 @@ public class HelpCommand extends Command {
|
||||
command.getLongDesc().forEach(this::logDirect);
|
||||
logDirect("");
|
||||
MutableComponent returnComponent = Component.literal("Click to return to the help menu");
|
||||
returnComponent.setStyle(returnComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
returnComponent.setStyle(returnComponent.getStyle().withClickEvent(new ClickEvent.RunCommand(
|
||||
FORCE_COMMAND_PREFIX + label
|
||||
)));
|
||||
logDirect(returnComponent);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -43,7 +43,6 @@ 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;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -76,7 +75,7 @@ public class SelCommand extends Command {
|
||||
float opacity = Baritone.settings().selectionOpacity.value;
|
||||
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
||||
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, opacity, lineWidth);
|
||||
IRenderer.emitAABB(bufferBuilder, event.getModelViewStack(), new AABB(pos1));
|
||||
IRenderer.endLines(bufferBuilder, ignoreDepth);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.utils.SettingsUtil;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
@@ -108,8 +108,8 @@ public class SetCommand extends Command {
|
||||
component.setStyle(component.getStyle().withColor(ChatFormatting.GRAY));
|
||||
component.append(typeComponent);
|
||||
component.setStyle(component.getStyle()
|
||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent))
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion)));
|
||||
.withHoverEvent(new HoverEvent.ShowText(hoverComponent))
|
||||
.withClickEvent(new ClickEvent.SuggestCommand(commandSuggestion)));
|
||||
return component;
|
||||
},
|
||||
FORCE_COMMAND_PREFIX + "set " + arg + " " + search
|
||||
@@ -188,12 +188,10 @@ public class SetCommand extends Command {
|
||||
MutableComponent oldValueComponent = Component.literal(String.format("Old value: %s", oldValue));
|
||||
oldValueComponent.setStyle(oldValueComponent.getStyle()
|
||||
.withColor(ChatFormatting.GRAY)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
.withHoverEvent(new HoverEvent.ShowText(
|
||||
Component.literal("Click to set the setting back to this value")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
.withClickEvent(new ClickEvent.RunCommand(
|
||||
FORCE_COMMAND_PREFIX + String.format("set %s %s", setting.getName(), oldValue)
|
||||
)));
|
||||
logDirect(oldValueComponent);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -34,17 +34,17 @@ import baritone.api.command.helpers.TabCompleteHelper;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
|
||||
@@ -75,12 +75,10 @@ public class WaypointsCommand extends Command {
|
||||
component.append(nameComponent);
|
||||
component.append(timestamp);
|
||||
component.setStyle(component.getStyle()
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
.withHoverEvent(new HoverEvent.ShowText(
|
||||
Component.literal("Click to select")
|
||||
))
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
.withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s %s %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
@@ -160,8 +158,7 @@ public class WaypointsCommand extends Command {
|
||||
}
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).addAll(Arrays.<IWaypoint>asList(waypoints));
|
||||
MutableComponent textComponent = Component.literal(String.format("Cleared %d waypoints, click to restore them", waypoints.length));
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s restore @ %s",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
@@ -241,8 +238,7 @@ public class WaypointsCommand extends Command {
|
||||
logDirect(transform.apply(waypoint));
|
||||
logDirect(String.format("Position: %s", waypoint.getLocation()));
|
||||
MutableComponent deleteComponent = Component.literal("Click to delete this waypoint");
|
||||
deleteComponent.setStyle(deleteComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
deleteComponent.setStyle(deleteComponent.getStyle().withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s delete %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
@@ -252,8 +248,7 @@ public class WaypointsCommand extends Command {
|
||||
)
|
||||
)));
|
||||
MutableComponent goalComponent = Component.literal("Click to set goal to this waypoint");
|
||||
goalComponent.setStyle(goalComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
goalComponent.setStyle(goalComponent.getStyle().withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s goal %s @ %d",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
@@ -263,8 +258,7 @@ public class WaypointsCommand extends Command {
|
||||
)
|
||||
)));
|
||||
MutableComponent recreateComponent = Component.literal("Click to show a command to recreate this waypoint");
|
||||
recreateComponent.setStyle(recreateComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.SUGGEST_COMMAND,
|
||||
recreateComponent.setStyle(recreateComponent.getStyle().withClickEvent(new ClickEvent.SuggestCommand(
|
||||
String.format(
|
||||
"%s%s save %s %s %s %s %s",
|
||||
Baritone.settings().prefix.value, // This uses the normal prefix because it is run by the user.
|
||||
@@ -277,8 +271,7 @@ public class WaypointsCommand extends Command {
|
||||
)
|
||||
)));
|
||||
MutableComponent backComponent = Component.literal("Click to return to the waypoints list");
|
||||
backComponent.setStyle(backComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
backComponent.setStyle(backComponent.getStyle().withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s list",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
@@ -293,8 +286,7 @@ public class WaypointsCommand extends Command {
|
||||
ForWaypoints.waypoints(this.baritone).removeWaypoint(waypoint);
|
||||
deletedWaypoints.computeIfAbsent(baritone.getWorldProvider().getCurrentWorld(), k -> new ArrayList<>()).add(waypoint);
|
||||
MutableComponent textComponent = Component.literal("That waypoint has successfully been deleted, click to restore it");
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
textComponent.setStyle(textComponent.getStyle().withClickEvent(new ClickEvent.RunCommand(
|
||||
String.format(
|
||||
"%s%s restore @ %s",
|
||||
FORCE_COMMAND_PREFIX,
|
||||
|
||||
@@ -43,17 +43,12 @@ import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.Half;
|
||||
import net.minecraft.world.level.block.state.properties.SlabType;
|
||||
import net.minecraft.world.level.block.state.properties.StairsShape;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
import net.minecraft.world.level.material.*;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static baritone.pathing.movement.Movement.HORIZONTALS_BUT_ALSO_DOWN_____SO_EVERY_DIRECTION_EXCEPT_UP;
|
||||
@@ -650,7 +645,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
*/
|
||||
static void switchToBestToolFor(IPlayerContext ctx, BlockState b, ToolSet ts, boolean preferSilkTouch) {
|
||||
if (Baritone.settings().autoTool.value && !Baritone.settings().assumeExternalAutoTool.value) {
|
||||
ctx.player().getInventory().selected = ts.getBestSlot(b.getBlock(), preferSilkTouch);
|
||||
ctx.player().getInventory().setSelectedSlot(ts.getBestSlot(b.getBlock(), preferSilkTouch));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -30,9 +30,6 @@ import baritone.pathing.movement.MovementHelper;
|
||||
import baritone.pathing.movement.MovementState;
|
||||
import baritone.pathing.movement.MovementState.MovementTarget;
|
||||
import baritone.utils.pathing.MutableMoveResult;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -47,6 +44,10 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.WaterFluid;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class MovementFall extends Movement {
|
||||
|
||||
private static final ItemStack STACK_BUCKET_WATER = new ItemStack(Items.WATER_BUCKET);
|
||||
@@ -101,7 +102,7 @@ public class MovementFall extends Movement {
|
||||
}
|
||||
|
||||
if (ctx.player().position().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().onGround()) {
|
||||
ctx.player().getInventory().selected = ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_WATER);
|
||||
ctx.player().getInventory().setSelectedSlot(ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_WATER));
|
||||
|
||||
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
||||
|
||||
@@ -118,7 +119,7 @@ public class MovementFall extends Movement {
|
||||
if (playerFeet.equals(dest) && (ctx.player().position().y - playerFeet.getY() < 0.094 || isWater)) { // 0.094 because lilypads
|
||||
if (isWater) { // only match water, not flowing water (which we cannot pick up with a bucket)
|
||||
if (Inventory.isHotbarSlot(ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_EMPTY))) {
|
||||
ctx.player().getInventory().selected = ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_EMPTY);
|
||||
ctx.player().getInventory().setSelectedSlot(ctx.player().getInventory().findSlotMatchingItem(STACK_BUCKET_EMPTY));
|
||||
if (ctx.player().getDeltaMovement().y >= 0) {
|
||||
return state.setInput(Input.CLICK_RIGHT, true);
|
||||
} else {
|
||||
@@ -140,7 +141,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();
|
||||
|
||||
@@ -25,15 +25,10 @@ import baritone.api.pathing.goals.GoalGetToBlock;
|
||||
import baritone.api.process.IBuilderProcess;
|
||||
import baritone.api.process.PathingCommand;
|
||||
import baritone.api.process.PathingCommandType;
|
||||
import baritone.api.schematic.FillSchematic;
|
||||
import baritone.api.schematic.ISchematic;
|
||||
import baritone.api.schematic.IStaticSchematic;
|
||||
import baritone.api.schematic.MaskSchematic;
|
||||
import baritone.api.schematic.SubstituteSchematic;
|
||||
import baritone.api.schematic.RotatedSchematic;
|
||||
import baritone.api.schematic.MirroredSchematic;
|
||||
import baritone.api.schematic.*;
|
||||
import baritone.api.schematic.format.ISchematicFormat;
|
||||
import baritone.api.utils.*;
|
||||
import baritone.api.utils.Rotation;
|
||||
import baritone.api.utils.input.Input;
|
||||
import baritone.pathing.movement.CalculationContext;
|
||||
import baritone.pathing.movement.Movement;
|
||||
@@ -42,8 +37,8 @@ import baritone.utils.BaritoneProcessHelper;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.PathingCommandContext;
|
||||
import baritone.utils.schematic.MapArtSchematic;
|
||||
import baritone.utils.schematic.SelectionSchematic;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import baritone.utils.schematic.SelectionSchematic;
|
||||
import baritone.utils.schematic.litematica.LitematicaHelper;
|
||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -57,14 +52,7 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.PipeBlock;
|
||||
import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.StairBlock;
|
||||
import net.minecraft.world.level.block.TrapDoorBlock;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -395,7 +383,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
|
||||
private OptionalInt hasAnyItemThatWouldPlace(BlockState desired, HitResult result, Rotation rot) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack stack = ctx.player().getInventory().items.get(i);
|
||||
ItemStack stack = ctx.player().getInventory().getNonEquipmentItems().get(i);
|
||||
if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) {
|
||||
continue;
|
||||
}
|
||||
@@ -567,7 +555,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (toPlace.isPresent() && isSafeToCancel && ctx.player().onGround() && ticks <= 0) {
|
||||
Rotation rot = toPlace.get().rot;
|
||||
baritone.getLookBehavior().updateTarget(rot, true);
|
||||
ctx.player().getInventory().selected = toPlace.get().hotbarSelection;
|
||||
ctx.player().getInventory().setSelectedSlot(toPlace.get().hotbarSelection);
|
||||
baritone.getInputOverrideHandler().setInputForceState(Input.SNEAK, true);
|
||||
if ((ctx.isLookingAt(toPlace.get().placeAgainst) && ((BlockHitResult) ctx.objectMouseOver()).getDirection().equals(toPlace.get().side)) || ctx.playerRotations().isReallyCloseTo(rot)) {
|
||||
baritone.getInputOverrideHandler().setInputForceState(Input.CLICK_RIGHT, true);
|
||||
@@ -1017,7 +1005,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
private List<BlockState> approxPlaceable(int size) {
|
||||
List<BlockState> result = new ArrayList<>();
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemStack stack = ctx.player().getInventory().items.get(i);
|
||||
ItemStack stack = ctx.player().getInventory().getNonEquipmentItems().get(i);
|
||||
if (stack.isEmpty() || !(stack.getItem() instanceof BlockItem)) {
|
||||
result.add(Blocks.AIR.defaultBlockState());
|
||||
continue;
|
||||
|
||||
@@ -23,6 +23,8 @@ import baritone.api.process.ICustomGoalProcess;
|
||||
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
|
||||
@@ -105,7 +107,9 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
|
||||
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);
|
||||
|
||||
@@ -44,8 +44,10 @@ import baritone.process.elytra.NullElytraProcess;
|
||||
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;
|
||||
@@ -157,7 +159,9 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||
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;
|
||||
@@ -254,7 +258,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||
|
||||
if (this.state == State.GET_TO_JUMP) {
|
||||
final IPathExecutor executor = baritone.getPathingBehavior().getCurrent();
|
||||
final boolean canStartFlying = ctx.player().fallDistance > 1.0f
|
||||
// TODO 1.21.5: replace `ctx.player().getDeltaMovement().y < -0.377` with `ctx.player().fallDistance > 1.0f`
|
||||
final boolean canStartFlying = ctx.player().getDeltaMovement().y < -0.377
|
||||
&& !isSafeToCancel
|
||||
&& executor != null
|
||||
&& executor.getPath().movements().get(executor.getPosition()) instanceof MovementFall;
|
||||
@@ -272,7 +277,8 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||
baritone.getPathingBehavior().secretInternalSegmentCancel();
|
||||
}
|
||||
baritone.getInputOverrideHandler().clearAllKeys();
|
||||
if (ctx.player().fallDistance > 1.0f) {
|
||||
// TODO 1.21.5: replace `ctx.player().getDeltaMovement().y < -0.377` with `ctx.player().fallDistance > 1.0f`
|
||||
if (ctx.player().getDeltaMovement().y < -0.377) {
|
||||
baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, true);
|
||||
}
|
||||
}
|
||||
@@ -365,7 +371,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||
return true;
|
||||
}
|
||||
|
||||
NonNullList<ItemStack> inv = ctx.player().getInventory().items;
|
||||
NonNullList<ItemStack> inv = ctx.player().getInventory().getNonEquipmentItems();
|
||||
int qty = 0;
|
||||
for (int i = 0; i < 36; i++) {
|
||||
if (ElytraBehavior.isFireworks(inv.get(i))) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -74,7 +74,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
||||
@Override
|
||||
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
|
||||
if (desiredQuantity > 0) {
|
||||
int curr = ctx.player().getInventory().items.stream()
|
||||
int curr = ctx.player().getInventory().getNonEquipmentItems().stream()
|
||||
.filter(stack -> filter.has(stack))
|
||||
.mapToInt(ItemStack::getCount).sum();
|
||||
if (curr >= desiredQuantity) {
|
||||
|
||||
@@ -37,7 +37,6 @@ import it.unimi.dsi.fastutil.floats.FloatIterator;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -58,9 +57,9 @@ import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@@ -425,21 +424,21 @@ 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) {
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value);
|
||||
for (Pair<Vec3, Vec3> line : this.clearLines) {
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
|
||||
}
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) {
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value);
|
||||
for (Pair<Vec3, Vec3> line : this.blockedLines) {
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
|
||||
}
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (this.simulationLine != null && Baritone.settings().elytraRenderSimulation.value) {
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.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);
|
||||
@@ -1289,7 +1288,7 @@ public final class ElytraBehavior implements Helper {
|
||||
}
|
||||
|
||||
private int findGoodElytra() {
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().items;
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().getNonEquipmentItems();
|
||||
for (int i = 0; i < invy.size(); i++) {
|
||||
ItemStack slot = invy.get(i);
|
||||
if (slot.getItem() == Items.ELYTRA && (slot.getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.PaletteResize;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@@ -195,7 +196,7 @@ public final class NetherPathfinderContext {
|
||||
continue;
|
||||
}
|
||||
final PalettedContainer<BlockState> bsc = extendedblockstorage.getStates();
|
||||
final int airId = ((IPalettedContainer<BlockState>) bsc).getPalette().idFor(AIR_BLOCK_STATE);
|
||||
final int airId = ((IPalettedContainer<BlockState>) bsc).getPalette().idFor(AIR_BLOCK_STATE, PaletteResize.noResizeExpected());
|
||||
// pasted from FasterWorldScanner
|
||||
final BitStorage array = ((IPalettedContainer<BlockState>) bsc).getStorage();
|
||||
if (array == null) continue;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(bufferBuilder, stack, selection.aabb(), SELECTION_BOX_EXPANSION);
|
||||
|
||||
134
src/main/java/baritone/utils/BaritoneRenderType.java
Normal file
134
src/main/java/baritone/utils/BaritoneRenderType.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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.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.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class BaritoneRenderType extends RenderType {
|
||||
private final RenderPipeline renderPipeline;
|
||||
|
||||
public BaritoneRenderType(String name, int bufferSize, boolean affectsCrumbling, boolean sortOnUpload, RenderPipeline renderPipeline) {
|
||||
super(name, bufferSize, affectsCrumbling, sortOnUpload, () -> {}, () -> {});
|
||||
this.renderPipeline = renderPipeline;
|
||||
}
|
||||
|
||||
public static BaritoneRenderType create(String name, int bufferSize, RenderPipeline renderPipeline) {
|
||||
return new BaritoneRenderType(name, bufferSize, false, false, renderPipeline);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat format() {
|
||||
return this.renderPipeline.getVertexFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat.Mode mode() {
|
||||
return this.renderPipeline.getVertexFormatMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderPipeline pipeline() {
|
||||
return this.renderPipeline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(final MeshData meshData) {
|
||||
this.setupRenderState();
|
||||
try {
|
||||
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());
|
||||
indexBuffer = autoStorageIndexBuffer.getBuffer(meshData.drawState().indexCount());
|
||||
indexType = autoStorageIndexBuffer.type();
|
||||
} else {
|
||||
indexBuffer = this.renderPipeline.getVertexFormat().uploadImmediateIndexBuffer(meshData.indexBuffer());
|
||||
indexType = meshData.drawState().indexType();
|
||||
}
|
||||
|
||||
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),
|
||||
new Vector3f(),
|
||||
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());
|
||||
}
|
||||
|
||||
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(indexBuffer, indexType);
|
||||
renderPass.drawIndexed(0, 0, meshData.drawState().indexCount(), 1);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
try {
|
||||
meshData.close();
|
||||
} catch (Throwable e2) {
|
||||
e.addSuppressed(e2);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
meshData.close();
|
||||
|
||||
this.clearRenderState();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.input.MouseButtonEvent;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
@@ -85,17 +85,16 @@ public class GuiClick extends Screen implements Helper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) {
|
||||
public boolean mouseReleased(MouseButtonEvent event) {
|
||||
if (currentMouseOver != null) { //Catch this, or else a click into void will result in a crash
|
||||
if (mouseButton == 0) {
|
||||
if (event.button() == 0) {
|
||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().removeAllSelections();
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getSelectionManager().addSelection(BetterBlockPos.from(clickStart), BetterBlockPos.from(currentMouseOver));
|
||||
MutableComponent component = Component.literal("Selection made! For usage: " + Baritone.settings().prefix.value + "help sel");
|
||||
component.setStyle(component.getStyle()
|
||||
.withColor(ChatFormatting.WHITE)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
.withClickEvent(new ClickEvent.RunCommand(
|
||||
FORCE_COMMAND_PREFIX + "help sel"
|
||||
)));
|
||||
Helper.HELPER.logDirect(component);
|
||||
@@ -103,18 +102,18 @@ public class GuiClick extends Screen implements Helper {
|
||||
} else {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver));
|
||||
}
|
||||
} else if (mouseButton == 1) {
|
||||
} else if (event.button() == 1) {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(new GoalBlock(currentMouseOver.above()));
|
||||
}
|
||||
}
|
||||
clickStart = null;
|
||||
return super.mouseReleased(mouseX, mouseY, mouseButton);
|
||||
return super.mouseReleased(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
|
||||
public boolean mouseClicked(MouseButtonEvent event, boolean doubleClick) {
|
||||
clickStart = currentMouseOver;
|
||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
return super.mouseClicked(event, doubleClick);
|
||||
}
|
||||
|
||||
public void onRender(PoseStack modelViewStack, Matrix4f projectionMatrix) {
|
||||
@@ -127,7 +126,7 @@ public class GuiClick extends Screen implements Helper {
|
||||
// drawSingleSelectionBox WHEN?
|
||||
PathRenderer.drawManySelectionBoxes(modelViewStack, e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value);
|
||||
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
||||
BetterBlockPos b = new BetterBlockPos(clickStart);
|
||||
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));
|
||||
|
||||
@@ -20,12 +20,17 @@ package baritone.utils;
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.Settings;
|
||||
import baritone.utils.accessor.IEntityRenderManager;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import baritone.utils.accessor.IRenderPipelines;
|
||||
import com.mojang.blaze3d.pipeline.BlendFunction;
|
||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||
import com.mojang.blaze3d.platform.DepthTestFunction;
|
||||
import com.mojang.blaze3d.platform.DestFactor;
|
||||
import com.mojang.blaze3d.platform.SourceFactor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.RenderPipelines;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@@ -35,8 +40,33 @@ public interface IRenderer {
|
||||
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
IEntityRenderManager renderManager = (IEntityRenderManager) Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
|
||||
Settings settings = BaritoneAPI.getSettings();
|
||||
RenderPipeline.Snippet BARITONE_LINES_SNIPPET = RenderPipeline.builder(((IRenderPipelines) new RenderPipelines()).getLinesSnippet())
|
||||
.withBlend(new BlendFunction(
|
||||
SourceFactor.SRC_ALPHA,
|
||||
DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
SourceFactor.ONE,
|
||||
DestFactor.ZERO
|
||||
))
|
||||
.withDepthWrite(false)
|
||||
.withCull(false)
|
||||
.buildSnippet();
|
||||
RenderType linesWithDepthRenderType = BaritoneRenderType.create(
|
||||
"renderType/baritone_lines_with_depth",
|
||||
256,
|
||||
RenderPipeline.builder(BARITONE_LINES_SNIPPET)
|
||||
.withLocation("pipelines/baritone_lines_with_depth")
|
||||
.withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
|
||||
.build()
|
||||
);
|
||||
RenderType linesNoDepthRenderType = BaritoneRenderType.create(
|
||||
"renderType/baritone_lines_no_depth",
|
||||
256,
|
||||
RenderPipeline.builder(BARITONE_LINES_SNIPPET)
|
||||
.withLocation("pipelines/baritone_lines_no_depth")
|
||||
.withDepthTestFunction(DepthTestFunction.NO_DEPTH_TEST)
|
||||
.build()
|
||||
);
|
||||
|
||||
float[] color = new float[]{1.0F, 1.0F, 1.0F, 255.0F};
|
||||
|
||||
@@ -48,44 +78,25 @@ public interface IRenderer {
|
||||
IRenderer.color[3] = alpha;
|
||||
}
|
||||
|
||||
static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
RenderSystem.blendFuncSeparate(
|
||||
GlStateManager.SourceFactor.SRC_ALPHA,
|
||||
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
|
||||
GlStateManager.SourceFactor.ONE,
|
||||
GlStateManager.DestFactor.ZERO
|
||||
);
|
||||
static BufferBuilder startLines(Color color, float alpha, float lineWidth) {
|
||||
glColor(color, alpha);
|
||||
RenderSystem.lineWidth(lineWidth);
|
||||
RenderSystem.depthMask(false);
|
||||
RenderSystem.disableCull();
|
||||
|
||||
if (ignoreDepth) {
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
|
||||
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
|
||||
}
|
||||
|
||||
static BufferBuilder startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
return startLines(color, .4f, lineWidth, ignoreDepth);
|
||||
static BufferBuilder startLines(Color color, float lineWidth) {
|
||||
return startLines(color, .4f, lineWidth);
|
||||
}
|
||||
|
||||
static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) {
|
||||
MeshData meshData = bufferBuilder.build();
|
||||
if (meshData != null) {
|
||||
BufferUploader.drawWithShader(meshData);
|
||||
if (ignoredDepth) {
|
||||
linesNoDepthRenderType.draw(meshData);
|
||||
} else {
|
||||
linesWithDepthRenderType.draw(meshData);
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoredDepth) {
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
|
||||
RenderSystem.enableCull();
|
||||
RenderSystem.depthMask(true);
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
|
||||
@@ -25,12 +25,9 @@ import baritone.api.utils.IPlayerContext;
|
||||
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;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -52,9 +49,6 @@ import java.util.List;
|
||||
*/
|
||||
public final class PathRenderer implements IRenderer {
|
||||
|
||||
private static final ResourceLocation TEXTURE_BEACON_BEAM = ResourceLocation.parse("textures/entity/beacon_beam.png");
|
||||
|
||||
|
||||
private PathRenderer() {}
|
||||
|
||||
public static double posX() {
|
||||
@@ -135,7 +129,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) {
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value);
|
||||
|
||||
int fadeStart = fadeStart0 + startIndex;
|
||||
int fadeEnd = fadeEnd0 + startIndex;
|
||||
@@ -204,7 +198,7 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
public static void drawManySelectionBoxes(PoseStack stack, Entity player, Collection<BlockPos> positions, Color color) {
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.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?
|
||||
@@ -262,42 +256,17 @@ public final class PathRenderer implements IRenderer {
|
||||
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
} else if (goal instanceof GoalXZ) {
|
||||
GoalXZ goalPos = (GoalXZ) goal;
|
||||
minY = ctx.world().getMinBuildHeight();
|
||||
maxY = ctx.world().getMaxBuildHeight();
|
||||
minY = ctx.world().getMinY();
|
||||
maxY = ctx.world().getMaxY();
|
||||
|
||||
if (settings.renderGoalXZBeacon.value) {
|
||||
//TODO: check
|
||||
textureManager.bindForSetup(TEXTURE_BEACON_BEAM);
|
||||
if (settings.renderGoalIgnoreDepth.value) {
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
|
||||
stack.pushPose(); // push
|
||||
stack.translate(goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ); // translate
|
||||
|
||||
//TODO: check
|
||||
BeaconRenderer.renderBeaconBeam(
|
||||
stack,
|
||||
ctx.minecraft().renderBuffers().bufferSource(),
|
||||
TEXTURE_BEACON_BEAM,
|
||||
settings.renderGoalAnimated.value ? partialTicks : 0,
|
||||
1.0F,
|
||||
settings.renderGoalAnimated.value ? ctx.world().getGameTime() : 0,
|
||||
(int) minY,
|
||||
(int) maxY,
|
||||
color.getRGB(),
|
||||
|
||||
// Arguments filled by the private method lol
|
||||
0.2F,
|
||||
0.25F
|
||||
);
|
||||
|
||||
stack.popPose(); // pop
|
||||
|
||||
if (settings.renderGoalIgnoreDepth.value) {
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
return;
|
||||
// todo: fix beacon renderer (has been broken since at least 1.20.4)
|
||||
// issue with outer beam rendering, probably related to matrix transforms state not matching vanilla
|
||||
// possible solutions:
|
||||
// inject hook into LevelRenderer#renderBlockEntities where the matrices have already been set up correctly
|
||||
// copy out and modify the vanilla beacon render code
|
||||
// also another issue on 1.21.5 is we don't have a simple method call for editing the beacon's depth test
|
||||
// return;
|
||||
}
|
||||
|
||||
minX = goalPos.getX() + 0.002 - renderPosX;
|
||||
@@ -315,7 +284,7 @@ public final class PathRenderer implements IRenderer {
|
||||
boolean batch = Arrays.stream(((GoalComposite) goal).goals()).allMatch(IGoalRenderPos.class::isInstance);
|
||||
BufferBuilder buf = bufferBuilder;
|
||||
if (batch) {
|
||||
buf = IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
buf = IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value);
|
||||
}
|
||||
for (Goal g : ((GoalComposite) goal).goals()) {
|
||||
drawGoal(buf, stack, ctx, g, partialTicks, color, !batch);
|
||||
@@ -341,7 +310,7 @@ public final class PathRenderer implements IRenderer {
|
||||
|
||||
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) {
|
||||
bufferBuilder = IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
bufferBuilder = IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value);
|
||||
}
|
||||
|
||||
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y1);
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
package baritone.utils;
|
||||
|
||||
import baritone.api.utils.input.Input;
|
||||
import net.minecraft.client.player.ClientInput;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
|
||||
public class PlayerMovementInput extends net.minecraft.client.player.Input {
|
||||
public class PlayerMovementInput extends ClientInput {
|
||||
|
||||
private final InputOverrideHandler handler;
|
||||
|
||||
@@ -28,31 +30,40 @@ public class PlayerMovementInput extends net.minecraft.client.player.Input {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(boolean p_225607_1_, float f) {
|
||||
this.leftImpulse = 0.0F;
|
||||
this.forwardImpulse = 0.0F;
|
||||
public void tick() {
|
||||
float leftImpulse = 0.0F;
|
||||
float 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)) {
|
||||
this.forwardImpulse++;
|
||||
boolean up = handler.isInputForcedDown(Input.MOVE_FORWARD);
|
||||
if (up) {
|
||||
forwardImpulse++;
|
||||
}
|
||||
|
||||
if (this.down = handler.isInputForcedDown(Input.MOVE_BACK)) {
|
||||
this.forwardImpulse--;
|
||||
boolean down = handler.isInputForcedDown(Input.MOVE_BACK);
|
||||
if (down) {
|
||||
forwardImpulse--;
|
||||
}
|
||||
|
||||
if (this.left = handler.isInputForcedDown(Input.MOVE_LEFT)) {
|
||||
this.leftImpulse++;
|
||||
boolean left = handler.isInputForcedDown(Input.MOVE_LEFT);
|
||||
if (left) {
|
||||
leftImpulse++;
|
||||
}
|
||||
|
||||
if (this.right = handler.isInputForcedDown(Input.MOVE_RIGHT)) {
|
||||
this.leftImpulse--;
|
||||
boolean right = handler.isInputForcedDown(Input.MOVE_RIGHT);
|
||||
if (right) {
|
||||
leftImpulse--;
|
||||
}
|
||||
|
||||
if (this.shiftKeyDown = handler.isInputForcedDown(Input.SNEAK)) {
|
||||
this.leftImpulse *= 0.3D;
|
||||
this.forwardImpulse *= 0.3D;
|
||||
boolean sneaking = handler.isInputForcedDown(Input.SNEAK);
|
||||
if (sneaking) {
|
||||
leftImpulse *= 0.3D;
|
||||
forwardImpulse *= 0.3D;
|
||||
}
|
||||
this.moveVector = new Vec2(leftImpulse, forwardImpulse);
|
||||
|
||||
boolean sprinting = handler.isInputForcedDown(Input.SPRINT);
|
||||
|
||||
this.keyPresses = new net.minecraft.world.entity.player.Input(up, down, left, right, jumping, sneaking, sprinting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,17 @@ package baritone.utils;
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.TieredItem;
|
||||
import net.minecraft.world.item.enchantment.*;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentEffectComponents;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.ItemEnchantments;
|
||||
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -55,6 +60,20 @@ public class ToolSet {
|
||||
|
||||
private final LocalPlayer player;
|
||||
|
||||
/**
|
||||
* Used for evaluating the material cost of a tool.
|
||||
* see {@link #getMaterialCost(ItemStack)}
|
||||
* Prefer tools with lower material cost (lower index in this list).
|
||||
*/
|
||||
private static final List<TagKey<Item>> materialTagsPriorityList = List.of(
|
||||
ItemTags.WOODEN_TOOL_MATERIALS,
|
||||
ItemTags.STONE_TOOL_MATERIALS,
|
||||
ItemTags.IRON_TOOL_MATERIALS,
|
||||
ItemTags.GOLD_TOOL_MATERIALS,
|
||||
ItemTags.DIAMOND_TOOL_MATERIALS,
|
||||
ItemTags.NETHERITE_TOOL_MATERIALS
|
||||
);
|
||||
|
||||
public ToolSet(LocalPlayer player) {
|
||||
breakStrengthCache = new HashMap<>();
|
||||
this.player = player;
|
||||
@@ -79,20 +98,18 @@ public class ToolSet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate the material cost of a possible tool. The priority matches the
|
||||
* harvest level order; there is a chance for multiple at the same with modded tools
|
||||
* but in that case we don't really care.
|
||||
*
|
||||
* Evaluate the material cost of a possible tool.
|
||||
* If all else is equal, we want to prefer the tool with the lowest material cost.
|
||||
* i.e. we want to prefer a wooden pickaxe over a stone pickaxe, if all else is equal.
|
||||
* @param itemStack a possibly empty ItemStack
|
||||
* @return values from 0 up
|
||||
*/
|
||||
private int getMaterialCost(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof TieredItem) {
|
||||
TieredItem tool = (TieredItem) itemStack.getItem();
|
||||
return (int) tool.getTier().getAttackDamageBonus();
|
||||
} else {
|
||||
return -1;
|
||||
for (int i = 0; i < materialTagsPriorityList.size(); i++) {
|
||||
final TagKey<Item> tag = materialTagsPriorityList.get(i);
|
||||
if (itemStack.is(tag)) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasSilkTouch(ItemStack stack) {
|
||||
@@ -126,7 +143,7 @@ public class ToolSet {
|
||||
possible, this lets us make pathing depend on the actual tool to be used (if auto tool is disabled)
|
||||
*/
|
||||
if (!Baritone.settings().autoTool.value && pathingCalculation) {
|
||||
return player.getInventory().selected;
|
||||
return player.getInventory().getSelectedSlot();
|
||||
}
|
||||
|
||||
int best = 0;
|
||||
@@ -136,7 +153,7 @@ public class ToolSet {
|
||||
BlockState blockState = b.defaultBlockState();
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack itemStack = player.getInventory().getItem(i);
|
||||
if (!Baritone.settings().useSwordToMine.value && itemStack.getItem() instanceof SwordItem) {
|
||||
if (!Baritone.settings().useSwordToMine.value && itemStack.getItem().components().has(DataComponents.WEAPON)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -228,11 +245,11 @@ public class ToolSet {
|
||||
*/
|
||||
private double potionAmplifier() {
|
||||
double speed = 1;
|
||||
if (player.hasEffect(MobEffects.DIG_SPEED)) {
|
||||
speed *= 1 + (player.getEffect(MobEffects.DIG_SPEED).getAmplifier() + 1) * 0.2;
|
||||
if (player.hasEffect(MobEffects.HASTE)) {
|
||||
speed *= 1 + (player.getEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2;
|
||||
}
|
||||
if (player.hasEffect(MobEffects.DIG_SLOWDOWN)) {
|
||||
switch (player.getEffect(MobEffects.DIG_SLOWDOWN).getAmplifier()) {
|
||||
if (player.hasEffect(MobEffects.MINING_FATIGUE)) {
|
||||
switch (player.getEffect(MobEffects.MINING_FATIGUE).getAmplifier()) {
|
||||
case 0:
|
||||
speed *= 0.3;
|
||||
break;
|
||||
|
||||
24
src/main/java/baritone/utils/accessor/IRenderPipelines.java
Normal file
24
src/main/java/baritone/utils/accessor/IRenderPipelines.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.utils.accessor;
|
||||
|
||||
import com.mojang.blaze3d.pipeline.RenderPipeline;
|
||||
|
||||
public interface IRenderPipelines {
|
||||
RenderPipeline.Snippet getLinesSnippet();
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
|
||||
@Override
|
||||
public IStaticSchematic parse(InputStream input) throws IOException {
|
||||
CompoundTag nbt = NbtIo.readCompressed(input, NbtAccounter.unlimitedHeap());
|
||||
int version = nbt.getInt("Version");
|
||||
int version = nbt.getInt("Version").orElse(-1);
|
||||
switch (version) {
|
||||
case 1:
|
||||
case 2:
|
||||
@@ -78,7 +78,7 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
|
||||
@Override
|
||||
public IStaticSchematic parse(InputStream input) throws IOException {
|
||||
CompoundTag nbt = NbtIo.readCompressed(input, NbtAccounter.unlimitedHeap());
|
||||
int version = nbt.getInt("Version");
|
||||
int version = nbt.getInt("Version").orElse(-1);
|
||||
switch (version) {
|
||||
case 4: //1.12
|
||||
case 5: //1.13-1.17
|
||||
|
||||
@@ -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;
|
||||
@@ -56,9 +58,13 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
* @return Array of subregion tags.
|
||||
*/
|
||||
private static CompoundTag[] getRegions(CompoundTag nbt) {
|
||||
return nbt.getCompound("Regions").getAllKeys().stream()
|
||||
.map(nbt.getCompound("Regions")::getCompound)
|
||||
.toArray(CompoundTag[]::new);
|
||||
return nbt.getCompound("Regions")
|
||||
.map(CompoundTag::values)
|
||||
.map(r -> r.stream()
|
||||
.filter(v -> v instanceof CompoundTag)
|
||||
.map(CompoundTag.class::cast)
|
||||
.toArray(CompoundTag[]::new)
|
||||
).orElse(new CompoundTag[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,8 +74,8 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
* @return the lower coord of the requested axis.
|
||||
*/
|
||||
private static int getMinOfSubregion(CompoundTag subReg, String s) {
|
||||
int a = subReg.getCompound("Position").getInt(s);
|
||||
int b = subReg.getCompound("Size").getInt(s);
|
||||
int a = subReg.getCompound("Position").flatMap(position -> position.getInt(s)).orElse(0);
|
||||
int b = subReg.getCompound("Size").flatMap(size -> size.getInt(s)).orElse(0);
|
||||
return Math.min(a, a + b + 1);
|
||||
}
|
||||
|
||||
@@ -81,8 +87,14 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
BlockState[] blockList = new BlockState[blockStatePalette.size()];
|
||||
|
||||
for (int i = 0; i < blockStatePalette.size(); i++) {
|
||||
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
|
||||
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
|
||||
CompoundTag tag = (CompoundTag) blockStatePalette.get(i);
|
||||
ResourceLocation blockKey = ResourceLocation.tryParse(tag.getString("Name").orElse(""));
|
||||
Block block = blockKey == null
|
||||
? Blocks.AIR
|
||||
: BuiltInRegistries.BLOCK.get(blockKey)
|
||||
.map(Holder.Reference::value)
|
||||
.orElse(Blocks.AIR);
|
||||
CompoundTag properties = tag.getCompound("Properties").orElse(new CompoundTag());
|
||||
|
||||
blockList[i] = getBlockState(block, properties);
|
||||
}
|
||||
@@ -97,9 +109,9 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
private static BlockState getBlockState(Block block, CompoundTag properties) {
|
||||
BlockState blockState = block.defaultBlockState();
|
||||
|
||||
for (Object key : properties.getAllKeys()) {
|
||||
Property<?> property = block.getStateDefinition().getProperty((String) key);
|
||||
String propertyValue = properties.getString((String) key);
|
||||
for (String key : properties.keySet()) {
|
||||
Property<?> property = block.getStateDefinition().getProperty(key);
|
||||
String propertyValue = properties.getString(key).orElse(null);
|
||||
if (property != null) {
|
||||
blockState = setPropertyValue(blockState, property, propertyValue);
|
||||
}
|
||||
@@ -134,8 +146,8 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
* @return the volume of the subregion.
|
||||
*/
|
||||
private static long getVolume(CompoundTag subReg) {
|
||||
CompoundTag size = subReg.getCompound("Size");
|
||||
return Math.abs(size.getInt("x") * size.getInt("y") * size.getInt("z"));
|
||||
CompoundTag size = subReg.getCompound("Size").orElse(new CompoundTag());
|
||||
return Math.abs(size.getInt("x").orElse(0) * size.getInt("y").orElse(0) * size.getInt("z").orElse(0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,12 +168,12 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
private void fillInSchematic(CompoundTag nbt) {
|
||||
Vec3i offsetMinCorner = new Vec3i(getMinOfSchematic(nbt, "x"), getMinOfSchematic(nbt, "y"), getMinOfSchematic(nbt, "z"));
|
||||
for (CompoundTag subReg : getRegions(nbt)) {
|
||||
ListTag usedBlockTypes = subReg.getList("BlockStatePalette", 10);
|
||||
ListTag usedBlockTypes = subReg.getListOrEmpty("BlockStatePalette");
|
||||
BlockState[] blockList = getBlockList(usedBlockTypes);
|
||||
|
||||
int bitsPerBlock = getBitsPerBlock(usedBlockTypes.size());
|
||||
long regionVolume = getVolume(subReg);
|
||||
long[] blockStateArray = subReg.getLongArray("BlockStates");
|
||||
long[] blockStateArray = subReg.getLongArray("BlockStates").orElse(new long[0]);
|
||||
|
||||
LitematicaBitArray bitArray = new LitematicaBitArray(bitsPerBlock, regionVolume, blockStateArray);
|
||||
writeSubregionIntoSchematic(subReg, offsetMinCorner, blockList, bitArray);
|
||||
@@ -178,10 +190,10 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
int offsetX = getMinOfSubregion(subReg, "x") - offsetMinCorner.getX();
|
||||
int offsetY = getMinOfSubregion(subReg, "y") - offsetMinCorner.getY();
|
||||
int offsetZ = getMinOfSubregion(subReg, "z") - offsetMinCorner.getZ();
|
||||
CompoundTag size = subReg.getCompound("Size");
|
||||
int sizeX = Math.abs(size.getInt("x"));
|
||||
int sizeY = Math.abs(size.getInt("y"));
|
||||
int sizeZ = Math.abs(size.getInt("z"));
|
||||
CompoundTag size = subReg.getCompound("Size").orElse(new CompoundTag());
|
||||
int sizeX = Math.abs(size.getInt("x").orElse(0));
|
||||
int sizeY = Math.abs(size.getInt("y").orElse(0));
|
||||
int sizeZ = Math.abs(size.getInt("z").orElse(0));
|
||||
BlockState[][][] states = new BlockState[sizeX][sizeZ][sizeY];
|
||||
int index = 0;
|
||||
for (int y = 0; y < sizeY; y++) {
|
||||
|
||||
@@ -18,12 +18,13 @@
|
||||
package baritone.utils.schematic.format.defaults;
|
||||
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Holder;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -33,19 +34,19 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
public final class MCEditSchematic extends StaticSchematic {
|
||||
|
||||
public MCEditSchematic(CompoundTag schematic) {
|
||||
String type = schematic.getString("Materials");
|
||||
String type = schematic.getString("Materials").orElseThrow();
|
||||
if (!type.equals("Alpha")) {
|
||||
throw new IllegalStateException("bad schematic " + type);
|
||||
}
|
||||
this.x = schematic.getInt("Width");
|
||||
this.y = schematic.getInt("Height");
|
||||
this.z = schematic.getInt("Length");
|
||||
byte[] blocks = schematic.getByteArray("Blocks");
|
||||
this.x = schematic.getInt("Width").orElse(0);
|
||||
this.y = schematic.getInt("Height").orElse(0);
|
||||
this.z = schematic.getInt("Length").orElse(0);
|
||||
byte[] blocks = schematic.getByteArray("Blocks").orElseThrow();
|
||||
// byte[] metadata = schematic.getByteArray("Data");
|
||||
|
||||
byte[] additional = null;
|
||||
if (schematic.contains("AddBlocks")) {
|
||||
byte[] addBlocks = schematic.getByteArray("AddBlocks");
|
||||
byte[] addBlocks = schematic.getByteArray("AddBlocks").orElseThrow();
|
||||
additional = new byte[addBlocks.length * 2];
|
||||
for (int i = 0; i < addBlocks.length; i++) {
|
||||
additional[i * 2 + 0] = (byte) ((addBlocks[i] >> 4) & 0xF); // lower nibble
|
||||
@@ -63,7 +64,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();
|
||||
|
||||
@@ -20,18 +20,20 @@ package baritone.utils.schematic.format.defaults;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import baritone.utils.type.VarInt;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||
import net.minecraft.core.Holder;
|
||||
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;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
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.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.Property;
|
||||
|
||||
/**
|
||||
* @author Brady
|
||||
@@ -40,15 +42,15 @@ import net.minecraft.world.level.block.state.properties.Property;
|
||||
public final class SpongeSchematic extends StaticSchematic {
|
||||
|
||||
public SpongeSchematic(CompoundTag nbt) {
|
||||
this.x = nbt.getInt("Width");
|
||||
this.y = nbt.getInt("Height");
|
||||
this.z = nbt.getInt("Length");
|
||||
this.x = nbt.getInt("Width").orElse(0);
|
||||
this.y = nbt.getInt("Height").orElse(0);
|
||||
this.z = nbt.getInt("Length").orElse(0);
|
||||
this.states = new BlockState[this.x][this.z][this.y];
|
||||
|
||||
Int2ObjectArrayMap<BlockState> palette = new Int2ObjectArrayMap<>();
|
||||
CompoundTag paletteTag = nbt.getCompound("Palette");
|
||||
for (String tag : paletteTag.getAllKeys()) {
|
||||
int index = paletteTag.getInt(tag);
|
||||
CompoundTag paletteTag = nbt.getCompound("Palette").orElse(new CompoundTag());
|
||||
for (String tag : paletteTag.keySet()) {
|
||||
int index = paletteTag.getInt(tag).orElse(0);
|
||||
|
||||
SerializedBlockState serializedState = SerializedBlockState.getFromString(tag);
|
||||
if (serializedState == null) {
|
||||
@@ -64,7 +66,7 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
}
|
||||
|
||||
// BlockData is stored as an NBT byte[], however, the actual data that is represented is a varint[]
|
||||
byte[] rawBlockData = nbt.getByteArray("BlockData");
|
||||
byte[] rawBlockData = nbt.getByteArray("BlockData").orElseThrow();
|
||||
int[] blockData = new int[this.x * this.y * this.z];
|
||||
int offset = 0;
|
||||
for (int i = 0; i < blockData.length; i++) {
|
||||
@@ -107,7 +109,9 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
|
||||
private BlockState deserialize() {
|
||||
if (this.blockState == null) {
|
||||
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation);
|
||||
Block block = BuiltInRegistries.BLOCK.get(this.resourceLocation)
|
||||
.map(Holder.Reference::value)
|
||||
.orElse(Blocks.AIR);
|
||||
this.blockState = block.defaultBlockState();
|
||||
|
||||
this.properties.keySet().stream().sorted(String::compareTo).forEachOrdered(key -> {
|
||||
|
||||
@@ -21,7 +21,7 @@ import net.minecraft.world.level.Level;
|
||||
|
||||
public abstract class WorldSchematic extends Level {
|
||||
private WorldSchematic() {
|
||||
super(null, null, null, null, null, false, false, 0, 0);
|
||||
super(null, null, null, null, false, false, 0, 0);
|
||||
throw new LinkageError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user