Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12ddeee278 | ||
|
|
26e0af1188 | ||
|
|
42bb44120d | ||
|
|
aff430ac51 | ||
|
|
d79f7f9615 | ||
|
|
7e5dedd8f3 | ||
|
|
ba1ccce962 | ||
|
|
1dc5be3985 | ||
|
|
1d6f5df155 | ||
|
|
290e697d4a | ||
|
|
a5752507e1 | ||
|
|
1bfc0305fd | ||
|
|
81c53d5db1 | ||
|
|
9eefcbc9b6 | ||
|
|
52cfe5cf7e | ||
|
|
b550b92b0a | ||
|
|
28695031d7 | ||
|
|
50291089db | ||
|
|
5102d9164e | ||
|
|
a231748b4e | ||
|
|
800545f0b5 | ||
|
|
ec57888ce1 | ||
|
|
960ff6ed98 | ||
|
|
e682fc75a6 | ||
|
|
8867fb7010 | ||
|
|
acdcbf5146 | ||
|
|
6b2fd5acee | ||
|
|
8786148fef | ||
|
|
e66fdea500 | ||
|
|
74f46cd6eb | ||
|
|
1704d56274 | ||
|
|
81f7375591 | ||
|
|
74d82f2339 | ||
|
|
42c6abbf72 | ||
|
|
8bb19797e1 | ||
|
|
6b274b3f1e | ||
|
|
f02c3115d1 | ||
|
|
ee9ca6dd49 | ||
|
|
8a5e3f7009 | ||
|
|
b29878d0f2 | ||
|
|
19c8194eae | ||
|
|
d8381c71fd | ||
|
|
4b76fa995c | ||
|
|
088056b3d0 |
4
.github/workflows/gradle_build.yml
vendored
4
.github/workflows/gradle_build.yml
vendored
@@ -17,10 +17,10 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: gradle
|
||||
|
||||
|
||||
4
.github/workflows/run_tests.yml
vendored
4
.github/workflows/run_tests.yml
vendored
@@ -12,10 +12,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
|
||||
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
RUN apt update -y
|
||||
|
||||
RUN apt install \
|
||||
openjdk-17-jdk \
|
||||
openjdk-21-jdk \
|
||||
git \
|
||||
--assume-yes
|
||||
|
||||
|
||||
@@ -92,7 +92,9 @@ allprojects {
|
||||
mappings {
|
||||
intermediary()
|
||||
mojmap()
|
||||
parchment("1.20.2", "2023.10.22")
|
||||
parchment("1.20.6", "2024.05.01")
|
||||
|
||||
devFallbackNamespace "official"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ components.java {
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
proguardVersion "7.2.1"
|
||||
proguardVersion "7.4.2"
|
||||
compType "fabric"
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.22",
|
||||
"minecraft": ["1.20.3", "1.20.4"]
|
||||
"minecraft": ["1.21","1.21.1"]
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
|
||||
@@ -25,11 +25,7 @@ plugins {
|
||||
archivesBaseName = archivesBaseName + "-forge"
|
||||
|
||||
unimined.minecraft {
|
||||
mappings {
|
||||
devFallbackNamespace "intermediary"
|
||||
}
|
||||
|
||||
forge {
|
||||
minecraftForge {
|
||||
loader project.forge_version
|
||||
mixinConfig ["mixins.baritone.json"]
|
||||
}
|
||||
@@ -99,7 +95,7 @@ components.java {
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
proguardVersion "7.2.1"
|
||||
proguardVersion "7.4.2"
|
||||
compType "forge"
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,6 @@ A Minecraft pathfinder bot.
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.20.3, 1.20.4]"
|
||||
versionRange="[1.21, 1.21.1]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
||||
@@ -2,23 +2,23 @@ org.gradle.jvmargs=-Xmx4G
|
||||
|
||||
available_loaders=fabric,forge,neoforge,tweaker
|
||||
|
||||
mod_version=1.10.4
|
||||
mod_version=1.11.2
|
||||
maven_group=baritone
|
||||
archives_base_name=baritone
|
||||
|
||||
java_version=17
|
||||
java_version=21
|
||||
|
||||
minecraft_version=1.20.4
|
||||
minecraft_version=1.21
|
||||
|
||||
forge_version=49.0.3
|
||||
forge_version=51.0.16
|
||||
|
||||
neoforge_version=0-beta
|
||||
neoforge_version=20-beta
|
||||
|
||||
fabric_version=0.14.22
|
||||
fabric_version=0.15.11
|
||||
|
||||
nether_pathfinder_version=1.4.1
|
||||
|
||||
// These dependencies are used for common and tweaker
|
||||
// while mod loaders usually ship their own version
|
||||
mixin_version=0.8.5
|
||||
asm_version=9.3
|
||||
asm_version=9.7
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -25,9 +25,6 @@ plugins {
|
||||
archivesBaseName = archivesBaseName + "-neoforge"
|
||||
|
||||
unimined.minecraft {
|
||||
mappings {
|
||||
devFallbackNamespace "intermediary"
|
||||
}
|
||||
|
||||
neoForged {
|
||||
loader project.neoforge_version
|
||||
@@ -71,7 +68,7 @@ dependencies {
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
filesMatching("META-INF/neoforge.mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
@@ -108,7 +105,7 @@ components.java {
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
proguardVersion "7.2.1"
|
||||
proguardVersion "7.4.2"
|
||||
compType "neoforge"
|
||||
}
|
||||
|
||||
@@ -130,4 +127,4 @@ publishing {
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
|
||||
package baritone.launch;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
|
||||
@Mod("baritoe")
|
||||
@Mod(value = "baritoe", dist = Dist.CLIENT)
|
||||
public class BaritoneForgeModXD {
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||
# This is an example neoforge.mods.toml file. It contains the data relating to the loading mods.
|
||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
@@ -33,8 +33,8 @@ A Minecraft pathfinder bot.
|
||||
|
||||
[[dependencies.baritoe]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
type="required"
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="[1.20.3, 1.20.4]"
|
||||
versionRange="[1.21,1.21.1]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
@@ -30,7 +30,7 @@ public enum BlockById implements IDatatypeFor<Block> {
|
||||
|
||||
@Override
|
||||
public Block get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
|
||||
Block block;
|
||||
if ((block = BuiltInRegistries.BLOCK.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no block found by that id");
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum EntityClassById implements IDatatypeFor<EntityType> {
|
||||
|
||||
@Override
|
||||
public EntityType get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
|
||||
EntityType entity;
|
||||
if ((entity = BuiltInRegistries.ENTITY_TYPE.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("no entity found by that id");
|
||||
|
||||
@@ -77,7 +77,7 @@ public enum ForBlockOptionalMeta implements IDatatypeFor<BlockOptionalMeta> {
|
||||
properties = parts[1];
|
||||
}
|
||||
|
||||
Block block = BuiltInRegistries.BLOCK.getOptional(new ResourceLocation(blockId)).orElse(null);
|
||||
Block block = BuiltInRegistries.BLOCK.getOptional(ResourceLocation.parse(blockId)).orElse(null);
|
||||
if (block == null) {
|
||||
// This block doesn't exist so there's no properties to complete.
|
||||
return Stream.empty();
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum ItemById implements IDatatypeFor<Item> {
|
||||
|
||||
@Override
|
||||
public Item get(IDatatypeContext ctx) throws CommandException {
|
||||
ResourceLocation id = new ResourceLocation(ctx.getConsumer().getString());
|
||||
ResourceLocation id = ResourceLocation.parse(ctx.getConsumer().getString());
|
||||
Item item;
|
||||
if ((item = BuiltInRegistries.ITEM.getOptional(id).orElse(null)) == null) {
|
||||
throw new IllegalArgumentException("No item found by that id");
|
||||
|
||||
@@ -18,26 +18,38 @@
|
||||
package baritone.api.utils;
|
||||
|
||||
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 io.netty.util.concurrent.ThreadPerTaskExecutor;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.core.LayeredRegistryAccess;
|
||||
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.ReloadableResourceManager;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.world.RandomSequences;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
import net.minecraft.world.flag.FeatureFlags;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.CustomSpawner;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -48,8 +60,8 @@ 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.LootDataManager;
|
||||
import net.minecraft.world.level.storage.loot.LootParams;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
@@ -75,7 +87,6 @@ public final class BlockOptionalMeta {
|
||||
private final Set<BlockState> blockstates;
|
||||
private final ImmutableSet<Integer> stateHashes;
|
||||
private final ImmutableSet<Integer> stackHashes;
|
||||
private static LootDataManager lootTables;
|
||||
private static Map<Block, List<Item>> drops = new HashMap<>();
|
||||
|
||||
public BlockOptionalMeta(@Nonnull Block block) {
|
||||
@@ -218,43 +229,21 @@ public final class BlockOptionalMeta {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LootDataManager getManager() {
|
||||
if (lootTables == null) {
|
||||
MultiPackResourceManager resources = new MultiPackResourceManager(PackType.SERVER_DATA, List.of(getVanillaServerPack()));
|
||||
ReloadableResourceManager resourceManager = new ReloadableResourceManager(PackType.SERVER_DATA);
|
||||
lootTables = new LootDataManager();
|
||||
resourceManager.registerReloadListener(lootTables);
|
||||
try {
|
||||
resourceManager.createReload(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), CompletableFuture.completedFuture(Unit.INSTANCE), resources.listPacks().toList()).done().get();
|
||||
} catch (Exception exception) {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
}
|
||||
return lootTables;
|
||||
}
|
||||
|
||||
private static synchronized List<Item> drops(Block b) {
|
||||
return drops.computeIfAbsent(b, block -> {
|
||||
ResourceLocation lootTableLocation = block.getLootTable();
|
||||
if (lootTableLocation == BuiltInLootTables.EMPTY) {
|
||||
ResourceLocation lootTableLocation = block.getLootTable().location();
|
||||
if (lootTableLocation.equals(BuiltInLootTables.EMPTY.location())) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
List<Item> items = new ArrayList<>();
|
||||
try {
|
||||
ServerLevel lv2 = ServerLevelStub.fastCreate();
|
||||
|
||||
getManager().getLootTable(lootTableLocation).getRandomItemsRaw(
|
||||
new LootContext.Builder(
|
||||
new LootParams.Builder(ServerLevelStub.fastCreate())
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.atLowerCornerOf(BlockPos.ZERO))
|
||||
.withParameter(LootContextParams.TOOL, ItemStack.EMPTY)
|
||||
.withOptionalParameter(LootContextParams.BLOCK_ENTITY, null)
|
||||
.withParameter(LootContextParams.BLOCK_STATE, block.defaultBlockState())
|
||||
.create(LootContextParamSets.BLOCK)
|
||||
).withOptionalRandomSeed(1L)
|
||||
.create(null),
|
||||
stack -> items.add(stack.getItem())
|
||||
);
|
||||
LootParams.Builder lv5 = new LootParams.Builder(lv2)
|
||||
.withParameter(LootContextParams.ORIGIN, Vec3.ZERO)
|
||||
.withParameter(LootContextParams.BLOCK_STATE, b.defaultBlockState())
|
||||
.withParameter(LootContextParams.TOOL, new ItemStack(Items.NETHERITE_PICKAXE, 1));
|
||||
getDrops(block, lv5).stream().map(ItemStack::getItem).forEach(items::add);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -263,9 +252,22 @@ public final class BlockOptionalMeta {
|
||||
});
|
||||
}
|
||||
|
||||
private static class ServerLevelStub extends ServerLevel {
|
||||
private static List<ItemStack> getDrops(Block state, LootParams.Builder params) {
|
||||
ResourceKey<LootTable> lv = state.getLootTable();
|
||||
if (lv == BuiltInLootTables.EMPTY) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
LootParams lv2 = params.withParameter(LootContextParams.BLOCK_STATE, state.defaultBlockState()).create(LootContextParamSets.BLOCK);
|
||||
ServerLevelStub lv3 = (ServerLevelStub) lv2.getLevel();
|
||||
LootTable lv4 = lv3.holder().getLootTable(lv);
|
||||
return((ILootTable) lv4).invokeGetRandomItems(new LootContext.Builder(lv2).withOptionalRandomSeed(1).create(null));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ServerLevelStub extends ServerLevel {
|
||||
private static Minecraft client = Minecraft.getInstance();
|
||||
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);
|
||||
@@ -285,6 +287,15 @@ public final class BlockOptionalMeta {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryAccess registryAccess() {
|
||||
return registryAccess.join();
|
||||
}
|
||||
|
||||
public ReloadableServerRegistries.Holder holder() {
|
||||
return new ReloadableServerRegistries.Holder(registryAccess().freeze());
|
||||
}
|
||||
|
||||
public static Unsafe getUnsafe() {
|
||||
try {
|
||||
Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
@@ -295,5 +306,45 @@ public final class BlockOptionalMeta {
|
||||
}
|
||||
}
|
||||
|
||||
public static CompletableFuture<RegistryAccess> load() {
|
||||
PackRepository packRepository = Minecraft.getInstance().getResourcePackRepository();
|
||||
CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(
|
||||
PackType.SERVER_DATA,
|
||||
List.of(packRepository.getPack(BuiltInPackSource.VANILLA_ID).open())
|
||||
);
|
||||
LayeredRegistryAccess<RegistryLayer> layeredRegistryAccess = loadAndReplaceLayer(
|
||||
closeableResourceManager, RegistryLayer.createRegistryAccess(), RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES
|
||||
);
|
||||
return ReloadableServerResources.loadResources(
|
||||
closeableResourceManager,
|
||||
layeredRegistryAccess,
|
||||
FeatureFlags.VANILLA_SET,
|
||||
Commands.CommandSelection.INTEGRATED,
|
||||
2,
|
||||
Runnable::run,
|
||||
Minecraft.getInstance()
|
||||
).thenApply(reloadableServerResources -> reloadableServerResources.fullRegistries().get());
|
||||
}
|
||||
|
||||
private static LayeredRegistryAccess<RegistryLayer> loadAndReplaceLayer(
|
||||
ResourceManager resourceManager,
|
||||
LayeredRegistryAccess<RegistryLayer> registryAccess,
|
||||
RegistryLayer registryLayer,
|
||||
List<RegistryDataLoader.RegistryData<?>> registryData
|
||||
) {
|
||||
RegistryAccess.Frozen frozen = loadLayer(resourceManager, registryAccess, registryLayer, registryData);
|
||||
return registryAccess.replaceFrom(registryLayer, frozen);
|
||||
}
|
||||
|
||||
private static RegistryAccess.Frozen loadLayer(
|
||||
ResourceManager resourceManager,
|
||||
LayeredRegistryAccess<RegistryLayer> registryAccess,
|
||||
RegistryLayer registryLayer,
|
||||
List<RegistryDataLoader.RegistryData<?>> registryData
|
||||
) {
|
||||
RegistryAccess.Frozen frozen = registryAccess.getAccessForLoading(registryLayer);
|
||||
return RegistryDataLoader.load(resourceManager, frozen, registryData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ public class SettingsUtil {
|
||||
),
|
||||
ITEM(
|
||||
Item.class,
|
||||
str -> BuiltInRegistries.ITEM.get(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
str -> BuiltInRegistries.ITEM.get(ResourceLocation.parse(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
|
||||
item -> BuiltInRegistries.ITEM.getKey(item).toString()
|
||||
),
|
||||
LIST() {
|
||||
|
||||
28
src/api/java/baritone/api/utils/accessor/ILootTable.java
Normal file
28
src/api/java/baritone/api/utils/accessor/ILootTable.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.api.utils.accessor;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
|
||||
public interface ILootTable {
|
||||
|
||||
ObjectArrayList<ItemStack> invokeGetRandomItems(LootContext context);
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class BaritoneToast implements Toast {
|
||||
|
||||
|
||||
//TODO: check
|
||||
gui.blit(new ResourceLocation("textures/gui/toasts.png"), 0, 0, 0, 32, 160, 32);
|
||||
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);
|
||||
|
||||
@@ -19,41 +19,28 @@ package baritone.launch.mixins;
|
||||
|
||||
import baritone.api.utils.BlockOptionalMeta;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ReloadableServerRegistries;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootDataManager;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(LootContext.Builder.class)
|
||||
public class MixinLootContext {
|
||||
public abstract class MixinLootContextBuilder {
|
||||
|
||||
@Redirect(
|
||||
method = "create",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/server/level/ServerLevel.getServer()Lnet/minecraft/server/MinecraftServer;"
|
||||
)
|
||||
)
|
||||
private MinecraftServer getServer(ServerLevel world) {
|
||||
if (world == null) {
|
||||
return null;
|
||||
@Shadow public abstract ServerLevel getLevel();
|
||||
|
||||
@Redirect(method = "create", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;reloadableRegistries()Lnet/minecraft/server/ReloadableServerRegistries$Holder;"))
|
||||
private ReloadableServerRegistries.Holder create(MinecraftServer instance) {
|
||||
if (instance != null) {
|
||||
return instance.reloadableRegistries();
|
||||
}
|
||||
return world.getServer();
|
||||
if (getLevel() instanceof BlockOptionalMeta.ServerLevelStub sls) {
|
||||
return sls.holder();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "create",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getLootData()Lnet/minecraft/world/level/storage/loot/LootDataManager;"
|
||||
)
|
||||
)
|
||||
private LootDataManager getLootTableManager(MinecraftServer server) {
|
||||
if (server == null) {
|
||||
return BlockOptionalMeta.getManager();
|
||||
}
|
||||
return server.getLootData();
|
||||
}
|
||||
}
|
||||
34
src/launch/java/baritone/launch/mixins/MixinLootTable.java
Normal file
34
src/launch/java/baritone/launch/mixins/MixinLootTable.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.api.utils.accessor.ILootTable;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.LootTable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(LootTable.class)
|
||||
public abstract class MixinLootTable implements ILootTable {
|
||||
|
||||
@Invoker
|
||||
public abstract ObjectArrayList<ItemStack> invokeGetRandomItems(LootContext context);
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ 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;
|
||||
@@ -130,7 +131,7 @@ public class MixinMinecraft {
|
||||
method = "setLevel",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preLoadWorld(ClientLevel world, CallbackInfo ci) {
|
||||
private void preLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, CallbackInfo ci) {
|
||||
// If we're unloading the world but one doesn't exist, ignore it
|
||||
if (this.level == null && world == null) {
|
||||
return;
|
||||
@@ -150,7 +151,7 @@ public class MixinMinecraft {
|
||||
method = "setLevel",
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void postLoadWorld(ClientLevel world, CallbackInfo ci) {
|
||||
private void postLoadWorld(ClientLevel world, ReceivingLevelScreen.Reason arg2, 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
|
||||
|
||||
@@ -37,11 +37,6 @@ import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||
@Mixin(Screen.class)
|
||||
public abstract class MixinScreen implements IGuiScreen {
|
||||
|
||||
@Override
|
||||
@Invoker("openLink")
|
||||
public abstract void openLinkInvoker(URI url);
|
||||
|
||||
|
||||
//TODO: switch to enum extention with mixin 9.0 or whenever Mumfrey gets around to it
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;)V", remap = false, ordinal = 1), method = "handleComponentClicked", cancellable = true)
|
||||
public void handleCustomClickEvent(Style style, CallbackInfoReturnable<Boolean> cir) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.RenderEvent;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
@@ -41,12 +42,13 @@ public class MixinWorldRenderer {
|
||||
|
||||
@Inject(
|
||||
method = "renderLevel",
|
||||
at = @At("RETURN"),
|
||||
locals = LocalCapture.CAPTURE_FAILSOFT
|
||||
at = @At("RETURN")
|
||||
)
|
||||
private void onStartHand(PoseStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, Camera activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) {
|
||||
private void onStartHand(final DeltaTracker deltaTracker, final boolean bl, final Camera camera, final GameRenderer gameRenderer, final LightTexture lightTexture, final Matrix4f matrix4f, final Matrix4f matrix4f2, final CallbackInfo ci) {
|
||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, matrixStackIn, projectionIn));
|
||||
PoseStack poseStack = new PoseStack();
|
||||
poseStack.mulPose(matrix4f);
|
||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(deltaTracker.getGameTimeDeltaPartialTick(false), poseStack, matrix4f2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
"MixinFireworkRocketEntity",
|
||||
"MixinItemStack",
|
||||
"MixinLivingEntity",
|
||||
"MixinLootContext",
|
||||
"MixinLootContextBuilder",
|
||||
"MixinLootTable",
|
||||
"MixinMinecraft",
|
||||
"MixinNetworkManager",
|
||||
"MixinPalettedContainer",
|
||||
@@ -26,5 +27,7 @@
|
||||
"MixinPlayerController",
|
||||
"MixinScreen",
|
||||
"MixinWorldRenderer"
|
||||
],
|
||||
"mixins": [
|
||||
]
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import baritone.command.argument.CommandArguments;
|
||||
import baritone.command.manager.CommandManager;
|
||||
import baritone.utils.accessor.IGuiScreen;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.util.Tuple;
|
||||
@@ -97,8 +98,8 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
||||
return false;
|
||||
} else if (msg.trim().equalsIgnoreCase("orderpizza")) {
|
||||
try {
|
||||
((IGuiScreen) ctx.minecraft().screen).openLinkInvoker(new URI("https://www.dominos.com/en/pages/order/"));
|
||||
} catch (NullPointerException | URISyntaxException ignored) {}
|
||||
Util.getPlatform().openUri("https://www.dominos.com/en/pages/order/");
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
}
|
||||
if (msg.isEmpty()) {
|
||||
|
||||
@@ -42,6 +42,7 @@ import baritone.api.utils.BlockOptionalMetaLookup;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.schematic.StaticSchematic;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Vec3i;
|
||||
@@ -75,9 +76,9 @@ public class SelCommand extends Command {
|
||||
float opacity = Baritone.settings().selectionOpacity.value;
|
||||
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
||||
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
||||
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
IRenderer.emitAABB(event.getModelViewStack(), new AABB(pos1));
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||
IRenderer.emitAABB(bufferBuilder, event.getModelViewStack(), new AABB(pos1));
|
||||
IRenderer.endLines(bufferBuilder, ignoreDepth);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,11 +27,14 @@ import baritone.utils.ToolSet;
|
||||
import baritone.utils.pathing.BetterWorldBorder;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.*;
|
||||
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -108,19 +111,44 @@ public class CalculationContext {
|
||||
this.allowParkourAscend = Baritone.settings().allowParkourAscend.value;
|
||||
this.assumeWalkOnWater = Baritone.settings().assumeWalkOnWater.value;
|
||||
this.allowFallIntoLava = false; // Super secret internal setting for ElytraBehavior
|
||||
this.frostWalker = EnchantmentHelper.getEnchantmentLevel(Enchantments.FROST_WALKER, baritone.getPlayerContext().player());
|
||||
// todo: technically there can now be datapack enchants that replace blocks with any other at any range
|
||||
int frostWalkerLevel = 0;
|
||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemEnchantments itemEnchantments = baritone.getPlayerContext()
|
||||
.player()
|
||||
.getItemBySlot(slot)
|
||||
.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
if (enchant.is(Enchantments.FROST_WALKER)) {
|
||||
frostWalkerLevel = itemEnchantments.getLevel(enchant);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.frostWalker = frostWalkerLevel;
|
||||
this.allowDiagonalDescend = Baritone.settings().allowDiagonalDescend.value;
|
||||
this.allowDiagonalAscend = Baritone.settings().allowDiagonalAscend.value;
|
||||
this.allowDownward = Baritone.settings().allowDownward.value;
|
||||
this.minFallHeight = 3; // Minimum fall height used by MovementFall
|
||||
this.maxFallHeightNoWater = Baritone.settings().maxFallHeightNoWater.value;
|
||||
this.maxFallHeightBucket = Baritone.settings().maxFallHeightBucket.value;
|
||||
int depth = EnchantmentHelper.getDepthStrider(player);
|
||||
if (depth > 3) {
|
||||
depth = 3;
|
||||
float waterSpeedMultiplier = 1.0f;
|
||||
OUTER: for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemEnchantments itemEnchantments = baritone.getPlayerContext()
|
||||
.player()
|
||||
.getItemBySlot(slot)
|
||||
.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
List<EnchantmentAttributeEffect> effects = enchant.value()
|
||||
.getEffects(EnchantmentEffectComponents.ATTRIBUTES);
|
||||
for (EnchantmentAttributeEffect effect : effects) {
|
||||
if (effect.attribute().is(Attributes.WATER_MOVEMENT_EFFICIENCY.unwrapKey().get())) {
|
||||
waterSpeedMultiplier = effect.amount().calculate(itemEnchantments.getLevel(enchant));
|
||||
break OUTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
float mult = depth / 3.0F;
|
||||
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - mult) + ActionCosts.WALK_ONE_BLOCK_COST * mult;
|
||||
this.waterWalkSpeed = ActionCosts.WALK_ONE_IN_WATER_COST * (1 - waterSpeedMultiplier) + ActionCosts.WALK_ONE_BLOCK_COST * waterSpeedMultiplier;
|
||||
this.breakBlockAdditionalCost = Baritone.settings().blockBreakAdditionalPenalty.value;
|
||||
this.backtrackCostFavoringCoefficient = Baritone.settings().backtrackCostFavoringCoefficient.value;
|
||||
this.jumpPenalty = Baritone.settings().jumpPenalty.value;
|
||||
|
||||
@@ -31,7 +31,11 @@ import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.ToolSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.ItemEnchantments;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.piston.MovingPistonBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -177,15 +181,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (block instanceof CauldronBlock) {
|
||||
return NO;
|
||||
}
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (state.isPathfindable(null, null, PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
if (state.isPathfindable(PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,10 +227,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
return fluidState.getType() instanceof WaterFluid;
|
||||
}
|
||||
|
||||
// every block that overrides isPassable with anything more complicated than a "return true;" or "return false;"
|
||||
// has already been accounted for above
|
||||
// therefore it's safe to not construct a blockpos from our x, y, z ints and instead just pass null
|
||||
return state.isPathfindable(bsi.access, BlockPos.ZERO, PathComputationType.LAND); // workaround for future compatibility =P
|
||||
return state.isPathfindable(PathComputationType.LAND);
|
||||
}
|
||||
|
||||
static Ternary fullyPassableBlockState(BlockState state) {
|
||||
@@ -259,16 +255,10 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
}
|
||||
// door, fence gate, liquid, trapdoor have been accounted for, nothing else uses the world or pos parameters
|
||||
// at least in 1.12.2 vanilla, that is.....
|
||||
try { // A dodgy catch-all at the end, for most blocks with default behaviour this will work, however where blocks are special this will error out, and we can handle it when we have this information
|
||||
if (state.isPathfindable(null, null, PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
} catch (Throwable exception) {
|
||||
// see PR #1087 for why
|
||||
System.out.println("The block " + state.getBlock().getName().getString() + " requires a special case due to the exception " + exception.getMessage());
|
||||
return MAYBE;
|
||||
if (state.isPathfindable(PathComputationType.LAND)) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,11 +283,14 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
if (fullyPassable == NO) {
|
||||
return false;
|
||||
}
|
||||
return fullyPassablePosition(new BlockStateInterface(ctx), pos.getX(), pos.getY(), pos.getZ(), state); // meh
|
||||
return state.isPathfindable(PathComputationType.LAND);
|
||||
}
|
||||
|
||||
/**
|
||||
* params retained for backwards compatibility
|
||||
*/
|
||||
static boolean fullyPassablePosition(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||
return state.isPathfindable(bsi.access, bsi.isPassableBlockPos.set(x, y, z), PathComputationType.LAND);
|
||||
return state.isPathfindable(PathComputationType.LAND);
|
||||
}
|
||||
|
||||
static boolean isReplaceable(int x, int y, int z, BlockState state, BlockStateInterface bsi) {
|
||||
@@ -511,14 +504,27 @@ public interface MovementHelper extends ActionCosts, Helper {
|
||||
static boolean canUseFrostWalker(CalculationContext context, BlockState state) {
|
||||
return context.frostWalker != 0
|
||||
&& state == FrostedIceBlock.meltsInto()
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
&& state.getValue(LiquidBlock.LEVEL) == 0;
|
||||
}
|
||||
|
||||
static boolean canUseFrostWalker(IPlayerContext ctx, BlockPos pos) {
|
||||
boolean hasFrostWalker = false;
|
||||
OUTER: for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||
ItemEnchantments itemEnchantments = ctx
|
||||
.player()
|
||||
.getItemBySlot(slot)
|
||||
.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
if (enchant.is(Enchantments.FROST_WALKER)) {
|
||||
hasFrostWalker = true;
|
||||
break OUTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockState state = BlockStateInterface.get(ctx, pos);
|
||||
return EnchantmentHelper.hasFrostWalker(ctx.player())
|
||||
return hasFrostWalker
|
||||
&& state == FrostedIceBlock.meltsInto()
|
||||
&& ((Integer) state.getValue(LiquidBlock.LEVEL)) == 0;
|
||||
&& state.getValue(LiquidBlock.LEVEL) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,7 +46,6 @@ import baritone.utils.schematic.SelectionSchematic;
|
||||
import baritone.utils.schematic.SchematicSystem;
|
||||
import baritone.utils.schematic.litematica.LitematicaHelper;
|
||||
import baritone.utils.schematic.schematica.SchematicaHelper;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -1050,8 +1049,8 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
||||
if (!ignoreDirection && ignoredProps.isEmpty()) {
|
||||
return first.equals(second); // early return if no properties are being ignored
|
||||
}
|
||||
ImmutableMap<Property<?>, Comparable<?>> map1 = first.getValues();
|
||||
ImmutableMap<Property<?>, Comparable<?>> map2 = second.getValues();
|
||||
Map<Property<?>, Comparable<?>> map1 = first.getValues();
|
||||
Map<Property<?>, Comparable<?>> map2 = second.getValues();
|
||||
for (Property<?> prop : map1.keySet()) {
|
||||
if (map1.get(prop) != map2.get(prop)
|
||||
&& !(ignoreDirection && ORIENTATION_PROPS.contains(prop))
|
||||
|
||||
@@ -360,7 +360,7 @@ public class ElytraProcess extends BaritoneProcessHelper implements IBaritonePro
|
||||
|
||||
private boolean shouldLandForSafety() {
|
||||
ItemStack chest = ctx.player().getItemBySlot(EquipmentSlot.CHEST);
|
||||
if (chest.getItem() != Items.ELYTRA || chest.getItem().getMaxDamage() - chest.getDamageValue() < Baritone.settings().elytraMinimumDurability.value) {
|
||||
if (chest.getItem() != Items.ELYTRA || chest.getMaxDamage() - chest.getDamageValue() < Baritone.settings().elytraMinimumDurability.value) {
|
||||
// elytrabehavior replaces when durability <= minimumDurability, so if durability < minimumDurability then we can reasonably assume that the elytra will soon be broken without replacement
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.IRenderer;
|
||||
import baritone.utils.PathRenderer;
|
||||
import baritone.utils.accessor.IFireworkRocketEntity;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import it.unimi.dsi.fastutil.floats.FloatArrayList;
|
||||
import it.unimi.dsi.fastutil.floats.FloatIterator;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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;
|
||||
@@ -44,6 +46,7 @@ import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.component.Fireworks;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
@@ -422,28 +425,28 @@ public final class ElytraBehavior implements Helper {
|
||||
PathRenderer.drawGoal(event.getModelViewStack(), ctx, new GoalBlock(this.aimPos), event.getPartialTicks(), Color.GREEN);
|
||||
}
|
||||
if (!this.clearLines.isEmpty() && settings.elytraRenderRaytraces.value) {
|
||||
IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.GREEN, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
for (Pair<Vec3, Vec3> line : this.clearLines) {
|
||||
IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (!this.blockedLines.isEmpty() && Baritone.settings().elytraRenderRaytraces.value) {
|
||||
IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.BLUE, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
for (Pair<Vec3, Vec3> line : this.blockedLines) {
|
||||
IRenderer.emitLine(event.getModelViewStack(), line.first(), line.second());
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), line.first(), line.second());
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
if (this.simulationLine != null && Baritone.settings().elytraRenderSimulation.value) {
|
||||
IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(new Color(0x36CCDC), settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
final Vec3 offset = ctx.player().getPosition(event.getPartialTicks());
|
||||
for (int i = 0; i < this.simulationLine.size() - 1; i++) {
|
||||
final Vec3 src = this.simulationLine.get(i).add(offset);
|
||||
final Vec3 dst = this.simulationLine.get(i + 1).add(offset);
|
||||
IRenderer.emitLine(event.getModelViewStack(), src, dst);
|
||||
IRenderer.emitLine(bufferBuilder, event.getModelViewStack(), src, dst);
|
||||
}
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -922,9 +925,8 @@ public final class ElytraBehavior implements Helper {
|
||||
if (itemStack.getItem() != Items.FIREWORK_ROCKET) {
|
||||
return false;
|
||||
}
|
||||
// If it has NBT data, make sure it won't cause us to explode.
|
||||
final CompoundTag compound = itemStack.getTagElement("Fireworks");
|
||||
return compound == null || !compound.getAllKeys().contains("Explosions");
|
||||
Fireworks fw = itemStack.get(DataComponents.FIREWORKS);
|
||||
return fw != null && fw.explosions().isEmpty();
|
||||
}
|
||||
|
||||
private static boolean isBoostingFireworks(final ItemStack itemStack) {
|
||||
@@ -932,11 +934,9 @@ public final class ElytraBehavior implements Helper {
|
||||
}
|
||||
|
||||
private static OptionalInt getFireworkBoost(final ItemStack itemStack) {
|
||||
if (isFireworks(itemStack)) {
|
||||
final CompoundTag compound = itemStack.getTagElement("Fireworks");
|
||||
if (compound != null && compound.getAllKeys().contains("Flight")) {
|
||||
return OptionalInt.of(compound.getByte("Flight"));
|
||||
}
|
||||
Fireworks fw = itemStack.get(DataComponents.FIREWORKS);
|
||||
if (fw != null && fw.explosions().isEmpty()) {
|
||||
return OptionalInt.of(fw.flightDuration());
|
||||
}
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
@@ -1292,7 +1292,7 @@ public final class ElytraBehavior implements Helper {
|
||||
NonNullList<ItemStack> invy = ctx.player().getInventory().items;
|
||||
for (int i = 0; i < invy.size(); i++) {
|
||||
ItemStack slot = invy.get(i);
|
||||
if (slot.getItem() == Items.ELYTRA && (slot.getItem().getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) {
|
||||
if (slot.getItem() == Items.ELYTRA && (slot.getMaxDamage() - slot.getDamageValue()) > Baritone.settings().elytraMinimumDurability.value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -1306,7 +1306,7 @@ public final class ElytraBehavior implements Helper {
|
||||
|
||||
ItemStack chest = ctx.player().getItemBySlot(EquipmentSlot.CHEST);
|
||||
if (chest.getItem() != Items.ELYTRA
|
||||
|| chest.getItem().getMaxDamage() - chest.getDamageValue() > Baritone.settings().elytraMinimumDurability.value) {
|
||||
|| chest.getMaxDamage() - chest.getDamageValue() > Baritone.settings().elytraMinimumDurability.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import baritone.api.event.events.RenderEvent;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.selection.ISelection;
|
||||
import baritone.utils.IRenderer;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
||||
@@ -28,27 +29,27 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||
return;
|
||||
}
|
||||
|
||||
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(stack, selection.aabb(), SELECTION_BOX_EXPANSION);
|
||||
IRenderer.emitAABB(bufferBuilder, stack, selection.aabb(), SELECTION_BOX_EXPANSION);
|
||||
}
|
||||
|
||||
if (settings.renderSelectionCorners.value) {
|
||||
IRenderer.glColor(settings.colorSelectionPos1.value, opacity);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(stack, new AABB(selection.pos1()));
|
||||
IRenderer.emitAABB(bufferBuilder, stack, new AABB(selection.pos1()));
|
||||
}
|
||||
|
||||
IRenderer.glColor(settings.colorSelectionPos2.value, opacity);
|
||||
|
||||
for (ISelection selection : selections) {
|
||||
IRenderer.emitAABB(stack, new AABB(selection.pos2()));
|
||||
IRenderer.emitAABB(bufferBuilder, stack, new AABB(selection.pos2()));
|
||||
}
|
||||
}
|
||||
|
||||
IRenderer.endLines(ignoreDepth);
|
||||
IRenderer.endLines(bufferBuilder, ignoreDepth);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,9 +30,9 @@ import net.minecraft.world.level.Level;
|
||||
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.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
|
||||
/**
|
||||
* Wraps get for chuck caching capability
|
||||
|
||||
@@ -22,6 +22,7 @@ import baritone.api.BaritoneAPI;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.BetterBlockPos;
|
||||
import baritone.api.utils.Helper;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
@@ -126,11 +127,11 @@ public class GuiClick extends Screen implements Helper {
|
||||
// drawSingleSelectionBox WHEN?
|
||||
PathRenderer.drawManySelectionBoxes(modelViewStack, e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||
IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(Color.RED, Baritone.settings().pathRenderLineWidthPixels.value, true);
|
||||
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
||||
BetterBlockPos b = new BetterBlockPos(clickStart);
|
||||
IRenderer.emitAABB(modelViewStack, new AABB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||
IRenderer.endLines(true);
|
||||
IRenderer.emitAABB(bufferBuilder, modelViewStack, new AABB(Math.min(a.x, b.x), Math.min(a.y, b.y), Math.min(a.z, b.z), Math.max(a.x, b.x) + 1, Math.max(a.y, b.y) + 1, Math.max(a.z, b.z) + 1));
|
||||
IRenderer.endLines(bufferBuilder, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,12 @@ import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public interface IRenderer {
|
||||
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuilder();
|
||||
IEntityRenderManager renderManager = (IEntityRenderManager) Minecraft.getInstance().getEntityRenderDispatcher();
|
||||
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
|
||||
Settings settings = BaritoneAPI.getSettings();
|
||||
@@ -51,7 +48,7 @@ public interface IRenderer {
|
||||
IRenderer.color[3] = alpha;
|
||||
}
|
||||
|
||||
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
|
||||
static BufferBuilder startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShader(GameRenderer::getPositionColorShader);
|
||||
RenderSystem.blendFuncSeparate(
|
||||
@@ -69,15 +66,19 @@ public interface IRenderer {
|
||||
RenderSystem.disableDepthTest();
|
||||
}
|
||||
RenderSystem.setShader(GameRenderer::getRendertypeLinesShader);
|
||||
buffer.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
|
||||
return tessellator.begin(VertexFormat.Mode.LINES, DefaultVertexFormat.POSITION_COLOR_NORMAL);
|
||||
}
|
||||
|
||||
static void startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
startLines(color, .4f, lineWidth, ignoreDepth);
|
||||
static BufferBuilder startLines(Color color, float lineWidth, boolean ignoreDepth) {
|
||||
return startLines(color, .4f, lineWidth, ignoreDepth);
|
||||
}
|
||||
|
||||
static void endLines(boolean ignoredDepth) {
|
||||
tessellator.end();
|
||||
static void endLines(BufferBuilder bufferBuilder, boolean ignoredDepth) {
|
||||
MeshData meshData = bufferBuilder.build();
|
||||
if (meshData != null) {
|
||||
BufferUploader.drawWithShader(meshData);
|
||||
}
|
||||
|
||||
if (ignoredDepth) {
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
@@ -87,7 +88,7 @@ public interface IRenderer {
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
final double dx = x2 - x1;
|
||||
final double dy = y2 - y1;
|
||||
final double dz = z2 - z1;
|
||||
@@ -97,60 +98,59 @@ public interface IRenderer {
|
||||
final float ny = (float) (dy * invMag);
|
||||
final float nz = (float) (dz * invMag);
|
||||
|
||||
emitLine(stack, x1, y1, z1, x2, y2, z2, nx, ny, nz);
|
||||
emitLine(bufferBuilder, stack, x1, y1, z1, x2, y2, z2, nx, ny, nz);
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack,
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack,
|
||||
double x1, double y1, double z1,
|
||||
double x2, double y2, double z2,
|
||||
double nx, double ny, double nz) {
|
||||
emitLine(stack,
|
||||
emitLine(bufferBuilder, stack,
|
||||
(float) x1, (float) y1, (float) z1,
|
||||
(float) x2, (float) y2, (float) z2,
|
||||
(float) nx, (float) ny, (float) nz
|
||||
);
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack,
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack,
|
||||
float x1, float y1, float z1,
|
||||
float x2, float y2, float z2,
|
||||
float nx, float ny, float nz) {
|
||||
final Matrix4f matrix4f = stack.last().pose();
|
||||
final Matrix3f normal = stack.last().normal();
|
||||
PoseStack.Pose pose = stack.last();
|
||||
|
||||
buffer.vertex(matrix4f, x1, y1, z1).color(color[0], color[1], color[2], color[3]).normal(normal, nx, ny, nz).endVertex();
|
||||
buffer.vertex(matrix4f, x2, y2, z2).color(color[0], color[1], color[2], color[3]).normal(normal, nx, ny, nz).endVertex();
|
||||
bufferBuilder.addVertex(pose, x1, y1, z1).setColor(color[0], color[1], color[2], color[3]).setNormal(pose, nx, ny, nz);
|
||||
bufferBuilder.addVertex(pose, x2, y2, z2).setColor(color[0], color[1], color[2], color[3]).setNormal(pose, nx, ny, nz);
|
||||
}
|
||||
|
||||
static void emitAABB(PoseStack stack, AABB aabb) {
|
||||
static void emitAABB(BufferBuilder bufferBuilder, PoseStack stack, AABB aabb) {
|
||||
AABB toDraw = aabb.move(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ());
|
||||
|
||||
// bottom
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.minY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.minY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
// top
|
||||
emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.maxY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 0.0, 1.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, -1.0, 0.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.maxY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 0.0, -1.0);
|
||||
// corners
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
emitLine(stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.minZ, toDraw.minX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.minZ, toDraw.maxX, toDraw.maxY, toDraw.minZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.maxX, toDraw.minY, toDraw.maxZ, toDraw.maxX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
emitLine(bufferBuilder, stack, toDraw.minX, toDraw.minY, toDraw.maxZ, toDraw.minX, toDraw.maxY, toDraw.maxZ, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
static void emitAABB(PoseStack stack, AABB aabb, double expand) {
|
||||
emitAABB(stack, aabb.inflate(expand, expand, expand));
|
||||
static void emitAABB(BufferBuilder bufferBuilder, PoseStack stack, AABB aabb, double expand) {
|
||||
emitAABB(bufferBuilder, stack, aabb.inflate(expand, expand, expand));
|
||||
}
|
||||
|
||||
static void emitLine(PoseStack stack, Vec3 start, Vec3 end) {
|
||||
static void emitLine(BufferBuilder bufferBuilder, PoseStack stack, Vec3 start, Vec3 end) {
|
||||
double vpX = renderManager.renderPosX();
|
||||
double vpY = renderManager.renderPosY();
|
||||
double vpZ = renderManager.renderPosZ();
|
||||
emitLine(stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ);
|
||||
emitLine(bufferBuilder, stack, start.x - vpX, start.y - vpY, start.z - vpZ, end.x - vpX, end.y - vpY, end.z - vpZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||
import baritone.behavior.PathingBehavior;
|
||||
import baritone.pathing.path.PathExecutor;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.blockentity.BeaconRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -37,6 +38,7 @@ import net.minecraft.world.level.dimension.DimensionType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
@@ -50,7 +52,7 @@ import java.util.List;
|
||||
*/
|
||||
public final class PathRenderer implements IRenderer {
|
||||
|
||||
private static final ResourceLocation TEXTURE_BEACON_BEAM = new ResourceLocation("textures/entity/beacon_beam.png");
|
||||
private static final ResourceLocation TEXTURE_BEACON_BEAM = ResourceLocation.parse("textures/entity/beacon_beam.png");
|
||||
|
||||
|
||||
private PathRenderer() {}
|
||||
@@ -133,7 +135,7 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
public static void drawPath(PoseStack stack, List<BetterBlockPos> positions, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0, double offset) {
|
||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||
|
||||
int fadeStart = fadeStart0 + startIndex;
|
||||
int fadeEnd = fadeEnd0 + startIndex;
|
||||
@@ -167,13 +169,13 @@ public final class PathRenderer implements IRenderer {
|
||||
IRenderer.glColor(color, alpha);
|
||||
}
|
||||
|
||||
emitPathLine(stack, start.x, start.y, start.z, end.x, end.y, end.z, offset);
|
||||
emitPathLine(bufferBuilder, stack, start.x, start.y, start.z, end.x, end.y, end.z, offset);
|
||||
}
|
||||
|
||||
IRenderer.endLines(settings.renderPathIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderPathIgnoreDepth.value);
|
||||
}
|
||||
|
||||
private static void emitPathLine(PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, double offset) {
|
||||
private static void emitPathLine(BufferBuilder bufferBuilder, PoseStack stack, double x1, double y1, double z1, double x2, double y2, double z2, double offset) {
|
||||
final double extraOffset = offset + 0.03D;
|
||||
|
||||
double vpX = posX();
|
||||
@@ -181,20 +183,20 @@ public final class PathRenderer implements IRenderer {
|
||||
double vpZ = posZ();
|
||||
boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value;
|
||||
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x1 + offset - vpX, y1 + offset - vpY, z1 + offset - vpZ,
|
||||
x2 + offset - vpX, y2 + offset - vpY, z2 + offset - vpZ
|
||||
);
|
||||
if (renderPathAsFrickinThingy) {
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x2 + offset - vpX, y2 + offset - vpY, z2 + offset - vpZ,
|
||||
x2 + offset - vpX, y2 + extraOffset - vpY, z2 + offset - vpZ
|
||||
);
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x2 + offset - vpX, y2 + extraOffset - vpY, z2 + offset - vpZ,
|
||||
x1 + offset - vpX, y1 + extraOffset - vpY, z1 + offset - vpZ
|
||||
);
|
||||
IRenderer.emitLine(stack,
|
||||
IRenderer.emitLine(bufferBuilder, stack,
|
||||
x1 + offset - vpX, y1 + extraOffset - vpY, z1 + offset - vpZ,
|
||||
x1 + offset - vpX, y1 + offset - vpY, z1 + offset - vpZ
|
||||
);
|
||||
@@ -202,7 +204,7 @@ public final class PathRenderer implements IRenderer {
|
||||
}
|
||||
|
||||
public static void drawManySelectionBoxes(PoseStack stack, Entity player, Collection<BlockPos> positions, Color color) {
|
||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
BufferBuilder bufferBuilder = IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
|
||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||
BlockStateInterface bsi = new BlockStateInterface(BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext()); // TODO this assumes same dimension between primary baritone and render view? is this safe?
|
||||
@@ -212,17 +214,20 @@ public final class PathRenderer implements IRenderer {
|
||||
VoxelShape shape = state.getShape(player.level(), pos);
|
||||
AABB toDraw = shape.isEmpty() ? Shapes.block().bounds() : shape.bounds();
|
||||
toDraw = toDraw.move(pos);
|
||||
IRenderer.emitAABB(stack, toDraw, .002D);
|
||||
IRenderer.emitAABB(bufferBuilder, stack, toDraw, .002D);
|
||||
});
|
||||
|
||||
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||
}
|
||||
|
||||
public static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color) {
|
||||
drawGoal(stack, ctx, goal, partialTicks, color, true);
|
||||
drawGoal(null, stack, ctx, goal, partialTicks, color, true);
|
||||
}
|
||||
|
||||
private static void drawGoal(PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color, boolean setupRender) {
|
||||
private static void drawGoal(@Nullable BufferBuilder bufferBuilder, PoseStack stack, IPlayerContext ctx, Goal goal, float partialTicks, Color color, boolean setupRender) {
|
||||
if (!setupRender && bufferBuilder == null) {
|
||||
throw new RuntimeException("BufferBuilder must not be null if setupRender is false");
|
||||
}
|
||||
double renderPosX = posX();
|
||||
double renderPosY = posY();
|
||||
double renderPosZ = posZ();
|
||||
@@ -254,7 +259,7 @@ public final class PathRenderer implements IRenderer {
|
||||
y2 -= 0.5;
|
||||
maxY--;
|
||||
}
|
||||
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
} else if (goal instanceof GoalXZ) {
|
||||
GoalXZ goalPos = (GoalXZ) goal;
|
||||
minY = ctx.world().getMinBuildHeight();
|
||||
@@ -280,7 +285,7 @@ public final class PathRenderer implements IRenderer {
|
||||
settings.renderGoalAnimated.value ? ctx.world().getGameTime() : 0,
|
||||
(int) minY,
|
||||
(int) maxY,
|
||||
color.getColorComponents(null),
|
||||
color.getRGB(),
|
||||
|
||||
// Arguments filled by the private method lol
|
||||
0.2F,
|
||||
@@ -304,19 +309,19 @@ public final class PathRenderer implements IRenderer {
|
||||
y2 = 0;
|
||||
minY -= renderPosY;
|
||||
maxY -= renderPosY;
|
||||
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
} else if (goal instanceof GoalComposite) {
|
||||
// Simple way to determine if goals can be batched, without having some sort of GoalRenderer
|
||||
boolean batch = Arrays.stream(((GoalComposite) goal).goals()).allMatch(IGoalRenderPos.class::isInstance);
|
||||
|
||||
BufferBuilder buf = bufferBuilder;
|
||||
if (batch) {
|
||||
IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
buf = IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
for (Goal g : ((GoalComposite) goal).goals()) {
|
||||
drawGoal(stack, ctx, g, partialTicks, color, !batch);
|
||||
drawGoal(buf, stack, ctx, g, partialTicks, color, !batch);
|
||||
}
|
||||
if (batch) {
|
||||
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
||||
IRenderer.endLines(buf, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
} else if (goal instanceof GoalInverted) {
|
||||
drawGoal(stack, ctx, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
|
||||
@@ -330,37 +335,37 @@ public final class PathRenderer implements IRenderer {
|
||||
maxY = minY + 2;
|
||||
y1 = 1 + y + goalpos.level - renderPosY;
|
||||
y2 = 1 - y + goalpos.level - renderPosY;
|
||||
drawDankLitGoalBox(stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
drawDankLitGoalBox(bufferBuilder, stack, color, minX, maxX, minZ, maxZ, minY, maxY, y1, y2, setupRender);
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawDankLitGoalBox(PoseStack stack, Color colorIn, double minX, double maxX, double minZ, double maxZ, double minY, double maxY, double y1, double y2, boolean setupRender) {
|
||||
private static void drawDankLitGoalBox(BufferBuilder bufferBuilder, PoseStack stack, Color colorIn, double minX, double maxX, double minZ, double maxZ, double minY, double maxY, double y1, double y2, boolean setupRender) {
|
||||
if (setupRender) {
|
||||
IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
bufferBuilder = IRenderer.startLines(colorIn, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
|
||||
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1);
|
||||
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2);
|
||||
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y1);
|
||||
renderHorizontalQuad(bufferBuilder, stack, minX, maxX, minZ, maxZ, y2);
|
||||
|
||||
for (double y = minY; y < maxY; y += 16) {
|
||||
double max = Math.min(maxY, y + 16);
|
||||
IRenderer.emitLine(stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, minZ, minX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, minZ, maxX, max, minZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, maxZ, maxX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, maxZ, minX, max, maxZ, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
if (setupRender) {
|
||||
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
||||
IRenderer.endLines(bufferBuilder, settings.renderGoalIgnoreDepth.value);
|
||||
}
|
||||
}
|
||||
|
||||
private static void renderHorizontalQuad(PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
|
||||
private static void renderHorizontalQuad(BufferBuilder bufferBuilder, PoseStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
|
||||
if (y != 0) {
|
||||
IRenderer.emitLine(stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0);
|
||||
IRenderer.emitLine(stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, minZ, maxX, y, minZ, 1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, minZ, maxX, y, maxZ, 0.0, 0.0, 1.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, maxX, y, maxZ, minX, y, maxZ, -1.0, 0.0, 0.0);
|
||||
IRenderer.emitLine(bufferBuilder, stack, minX, y, maxZ, minX, y, minZ, 0.0, 0.0, -1.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,19 @@ package baritone.utils;
|
||||
|
||||
import baritone.Baritone;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.SwordItem;
|
||||
import net.minecraft.world.item.TieredItem;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.item.enchantment.*;
|
||||
import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -86,14 +89,22 @@ public class ToolSet {
|
||||
private int getMaterialCost(ItemStack itemStack) {
|
||||
if (itemStack.getItem() instanceof TieredItem) {
|
||||
TieredItem tool = (TieredItem) itemStack.getItem();
|
||||
return tool.getTier().getLevel();
|
||||
return (int) tool.getTier().getAttackDamageBonus();
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasSilkTouch(ItemStack stack) {
|
||||
return EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0;
|
||||
ItemEnchantments enchantments = stack.getEnchantments();
|
||||
for (Holder<Enchantment> enchant : enchantments.keySet()) {
|
||||
// silk touch enchantment is still special cased as affecting block drops
|
||||
// not possible to add custom attribute via datapack
|
||||
if (enchant.is(Enchantments.SILK_TOUCH) && enchantments.getLevel(enchant) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,9 +201,15 @@ public class ToolSet {
|
||||
|
||||
float speed = item.getDestroySpeed(state);
|
||||
if (speed > 1) {
|
||||
int effLevel = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.BLOCK_EFFICIENCY, item);
|
||||
if (effLevel > 0 && !item.isEmpty()) {
|
||||
speed += effLevel * effLevel + 1;
|
||||
final ItemEnchantments itemEnchantments = item.getEnchantments();
|
||||
OUTER: for (Holder<Enchantment> enchant : itemEnchantments.keySet()) {
|
||||
List<EnchantmentAttributeEffect> effects = enchant.value().getEffects(EnchantmentEffectComponents.ATTRIBUTES);
|
||||
for (EnchantmentAttributeEffect e : effects) {
|
||||
if (e.attribute().is(Attributes.MINING_EFFICIENCY.unwrapKey().get())) {
|
||||
speed += e.amount().calculate(itemEnchantments.getLevel(enchant));
|
||||
break OUTER;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,9 @@ public enum DefaultSchematicFormats implements ISchematicFormat {
|
||||
case 4: //1.12
|
||||
case 5: //1.13-1.17
|
||||
throw new UnsupportedOperationException("This litematic Version is too old.");
|
||||
case 6: //1.18+
|
||||
case 6: //1.18-1.20
|
||||
throw new UnsupportedOperationException("This litematic Version is too old.");
|
||||
case 7: //1.21+
|
||||
return new LitematicaSchematic(nbt);
|
||||
default:
|
||||
throw new UnsupportedOperationException("Unsuported Version of a Litematica Schematic");
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
BlockState[] blockList = new BlockState[blockStatePalette.size()];
|
||||
|
||||
for (int i = 0; i < blockStatePalette.size(); i++) {
|
||||
Block block = BuiltInRegistries.BLOCK.get(new ResourceLocation((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
|
||||
Block block = BuiltInRegistries.BLOCK.get(ResourceLocation.parse((((CompoundTag) blockStatePalette.get(i)).getString("Name"))));
|
||||
CompoundTag properties = ((CompoundTag) blockStatePalette.get(i)).getCompound("Properties");
|
||||
|
||||
blockList[i] = getBlockState(block, properties);
|
||||
@@ -273,4 +273,4 @@ public final class LitematicaSchematic extends CompositeSchematic implements ISt
|
||||
return this.arraySize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class SpongeSchematic extends StaticSchematic {
|
||||
String location = m.group("location");
|
||||
String properties = m.group("properties");
|
||||
|
||||
ResourceLocation resourceLocation = new ResourceLocation(location);
|
||||
ResourceLocation resourceLocation = ResourceLocation.parse(location);
|
||||
Map<String, String> propertiesMap = new HashMap<>();
|
||||
if (properties != null) {
|
||||
for (String property : properties.split(",")) {
|
||||
|
||||
@@ -95,7 +95,7 @@ jar {
|
||||
}
|
||||
|
||||
task proguard(type: ProguardTask) {
|
||||
proguardVersion "7.2.1"
|
||||
proguardVersion "7.4.2"
|
||||
}
|
||||
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
Reference in New Issue
Block a user