Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8949bdab48 | |||
| 94741142ec |
+3
-3
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
group 'baritone'
|
group 'baritone'
|
||||||
version '1.5.1'
|
version '1.4.4'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -82,7 +82,7 @@ task sourceJar(type: Jar, dependsOn: classes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20200213-1.15.1'
|
mappings channel: 'snapshot', version: '20190814-1.14.3'
|
||||||
reobfMappings 'notch'
|
reobfMappings 'notch'
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
@@ -138,7 +138,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'com.github.ImpactDevelopment:Vanilla:1.15.2'
|
minecraft 'com.github.ImpactDevelopment:Vanilla:1.14.4'
|
||||||
|
|
||||||
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
|
||||||
exclude module: 'lwjgl'
|
exclude module: 'lwjgl'
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ import java.awt.*;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.List;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -830,12 +830,10 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
|
public final Setting<Boolean> mineScanDroppedItems = new Setting<>(true);
|
||||||
|
|
||||||
// Hyritone start
|
|
||||||
/**
|
/**
|
||||||
* Detect ore locations with a separate world seed.
|
* Hyritone: Detect ore locations with a separate world seed.
|
||||||
*/
|
*/
|
||||||
public final Setting<Boolean> mineWithSeed = new Setting<>(false);
|
public final Setting<Boolean> mineWithSeed = new Setting<>(false);
|
||||||
// Hyritone end
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* While mining, wait this number of milliseconds after mining an ore to see if it will drop an item
|
* While mining, wait this number of milliseconds after mining an ore to see if it will drop an item
|
||||||
@@ -965,11 +963,6 @@ public final class Settings {
|
|||||||
*/
|
*/
|
||||||
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print out ALL command exceptions as a stack trace to stdout, even simple syntax errors
|
|
||||||
*/
|
|
||||||
public final Setting<Boolean> verboseCommandExceptions = new Setting<>(false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size of the box that is rendered when the current goal is a GoalYLevel
|
* The size of the box that is rendered when the current goal is a GoalYLevel
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
|
|
||||||
package baritone.api.event.events;
|
package baritone.api.event.events;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 8/5/2018
|
* @since 8/5/2018
|
||||||
@@ -31,13 +28,8 @@ public final class RenderEvent {
|
|||||||
*/
|
*/
|
||||||
private final float partialTicks;
|
private final float partialTicks;
|
||||||
|
|
||||||
private final Matrix4f projectionMatrix;
|
public RenderEvent(float partialTicks) {
|
||||||
private final MatrixStack modelViewStack;
|
|
||||||
|
|
||||||
public RenderEvent(float partialTicks, MatrixStack modelViewStack, Matrix4f projectionMatrix) {
|
|
||||||
this.partialTicks = partialTicks;
|
this.partialTicks = partialTicks;
|
||||||
this.modelViewStack = modelViewStack;
|
|
||||||
this.projectionMatrix = projectionMatrix;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,12 +38,4 @@ public final class RenderEvent {
|
|||||||
public final float getPartialTicks() {
|
public final float getPartialTicks() {
|
||||||
return this.partialTicks;
|
return this.partialTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MatrixStack getModelViewStack() {
|
|
||||||
return this.modelViewStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Matrix4f getProjectionMatrix() {
|
|
||||||
return this.projectionMatrix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,14 +20,14 @@ package baritone.api.utils;
|
|||||||
import baritone.api.utils.accessor.IItemStack;
|
import baritone.api.utils.accessor.IItemStack;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import io.netty.util.concurrent.ThreadPerTaskExecutor;
|
import io.netty.util.concurrent.ThreadPerTaskExecutor;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.resources.*;
|
import net.minecraft.resources.*;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.Unit;
|
import net.minecraft.util.Unit;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.world.storage.loot.*;
|
import net.minecraft.world.storage.loot.*;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@@ -46,7 +46,6 @@ public final class BlockOptionalMeta {
|
|||||||
private final ImmutableSet<Integer> stackHashes;
|
private final ImmutableSet<Integer> stackHashes;
|
||||||
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
private static final Pattern pattern = Pattern.compile("^(.+?)(?::(\\d+))?$");
|
||||||
private static LootTableManager manager;
|
private static LootTableManager manager;
|
||||||
private static LootPredicateManager predicate = new LootPredicateManager();
|
|
||||||
private static Map<Block, List<Item>> drops = new HashMap<>();
|
private static Map<Block, List<Item>> drops = new HashMap<>();
|
||||||
|
|
||||||
public BlockOptionalMeta(@Nonnull Block block) {
|
public BlockOptionalMeta(@Nonnull Block block) {
|
||||||
@@ -65,7 +64,13 @@ public final class BlockOptionalMeta {
|
|||||||
|
|
||||||
MatchResult matchResult = matcher.toMatchResult();
|
MatchResult matchResult = matcher.toMatchResult();
|
||||||
|
|
||||||
block = BlockUtils.stringToBlockRequired(matchResult.group(1));
|
ResourceLocation id = new ResourceLocation(matchResult.group(1));
|
||||||
|
|
||||||
|
if (!Registry.BLOCK.containsKey(id)) {
|
||||||
|
throw new IllegalArgumentException("Invalid block ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
block = Registry.BLOCK.getValue(id).orElse(null);
|
||||||
blockstates = getStates(block);
|
blockstates = getStates(block);
|
||||||
stateHashes = getStateHashes(blockstates);
|
stateHashes = getStateHashes(blockstates);
|
||||||
stackHashes = getStackHashes(blockstates);
|
stackHashes = getStackHashes(blockstates);
|
||||||
@@ -138,7 +143,7 @@ public final class BlockOptionalMeta {
|
|||||||
rpl.reloadPacksFromFinders();
|
rpl.reloadPacksFromFinders();
|
||||||
IResourcePack thePack = ((ResourcePackInfo) rpl.getAllPacks().iterator().next()).getResourcePack();
|
IResourcePack thePack = ((ResourcePackInfo) rpl.getAllPacks().iterator().next()).getResourcePack();
|
||||||
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA, null);
|
IReloadableResourceManager resourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA, null);
|
||||||
manager = new LootTableManager(predicate);
|
manager = new LootTableManager();
|
||||||
resourceManager.addReloadListener(manager);
|
resourceManager.addReloadListener(manager);
|
||||||
try {
|
try {
|
||||||
resourceManager.reloadResourcesAndThen(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
|
resourceManager.reloadResourcesAndThen(new ThreadPerTaskExecutor(Thread::new), new ThreadPerTaskExecutor(Thread::new), Collections.singletonList(thePack), CompletableFuture.completedFuture(Unit.INSTANCE)).get();
|
||||||
@@ -149,10 +154,6 @@ public final class BlockOptionalMeta {
|
|||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LootPredicateManager getPredicateManager() {
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static synchronized List<Item> drops(Block b) {
|
private static synchronized List<Item> drops(Block b) {
|
||||||
return drops.computeIfAbsent(b, block -> {
|
return drops.computeIfAbsent(b, block -> {
|
||||||
ResourceLocation lootTableLocation = block.getLootTable();
|
ResourceLocation lootTableLocation = block.getLootTable();
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public interface IPlayerContext {
|
|||||||
|
|
||||||
default BetterBlockPos playerFeet() {
|
default BetterBlockPos playerFeet() {
|
||||||
// TODO find a better way to deal with soul sand!!!!!
|
// TODO find a better way to deal with soul sand!!!!!
|
||||||
BetterBlockPos feet = new BetterBlockPos(player().getPositionVec().x, player().getPositionVec().y + 0.1251, player().getPositionVec().z);
|
BetterBlockPos feet = new BetterBlockPos(player().posX, player().posY + 0.1251, player().posZ);
|
||||||
|
|
||||||
// sometimes when calling this from another thread or while world is null, it'll throw a NullPointerException
|
// sometimes when calling this from another thread or while world is null, it'll throw a NullPointerException
|
||||||
// that causes the game to immediately crash
|
// that causes the game to immediately crash
|
||||||
@@ -76,11 +76,11 @@ public interface IPlayerContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default Vec3d playerFeetAsVec() {
|
default Vec3d playerFeetAsVec() {
|
||||||
return new Vec3d(player().getPositionVec().x, player().getPositionVec().y, player().getPositionVec().z);
|
return new Vec3d(player().posX, player().posY, player().posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Vec3d playerHead() {
|
default Vec3d playerHead() {
|
||||||
return new Vec3d(player().getPositionVec().x, player().getPositionVec().y + player().getEyeHeight(), player().getPositionVec().z);
|
return new Vec3d(player().posX, player().posY + player().getEyeHeight(), player().posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
default Rotation playerRotations() {
|
default Rotation playerRotations() {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public final class VecUtils {
|
|||||||
* @see #getBlockPosCenter(BlockPos)
|
* @see #getBlockPosCenter(BlockPos)
|
||||||
*/
|
*/
|
||||||
public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
|
public static double entityDistanceToCenter(Entity entity, BlockPos pos) {
|
||||||
return distanceToCenter(pos, entity.getPositionVec().x, entity.getPositionVec().y, entity.getPositionVec().z);
|
return distanceToCenter(pos, entity.posX, entity.posY, entity.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -118,6 +118,6 @@ public final class VecUtils {
|
|||||||
* @see #getBlockPosCenter(BlockPos)
|
* @see #getBlockPosCenter(BlockPos)
|
||||||
*/
|
*/
|
||||||
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
|
public static double entityFlatDistanceToCenter(Entity entity, BlockPos pos) {
|
||||||
return distanceToCenter(pos, entity.getPositionVec().x, pos.getY() + 0.5, entity.getPositionVec().z);
|
return distanceToCenter(pos, entity.posX, pos.getY() + 0.5, entity.posZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class LaunchTesting {
|
|||||||
attemptLogin(arguments, System.getenv("username"), System.getenv("password"));
|
attemptLogin(arguments, System.getenv("username"), System.getenv("password"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove
|
// Unify username
|
||||||
arguments.put("username", "TestUser");
|
arguments.put("username", "TestUser");
|
||||||
|
|
||||||
List<String> argsArray = new ArrayList<>();
|
List<String> argsArray = new ArrayList<>();
|
||||||
|
|||||||
+6
-6
@@ -18,22 +18,22 @@
|
|||||||
package baritone.launch.mixins;
|
package baritone.launch.mixins;
|
||||||
|
|
||||||
import baritone.utils.accessor.IBitArray;
|
import baritone.utils.accessor.IBitArray;
|
||||||
import baritone.utils.accessor.IPalettedContainer;
|
import baritone.utils.accessor.IBlockStateContainer;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.util.BitArray;
|
import net.minecraft.util.BitArray;
|
||||||
import net.minecraft.util.palette.IPalette;
|
import net.minecraft.world.chunk.BlockStateContainer;
|
||||||
import net.minecraft.util.palette.PalettedContainer;
|
import net.minecraft.world.chunk.IBlockStatePalette;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
@Mixin(PalettedContainer.class)
|
@Mixin(BlockStateContainer.class)
|
||||||
public abstract class MixinPalettedContainer implements IPalettedContainer {
|
public abstract class MixinBlockStateContainer implements IBlockStateContainer {
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
protected BitArray storage;
|
protected BitArray storage;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
protected IPalette<BlockState> palette;
|
protected IBlockStatePalette<BlockState> palette;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getAtPalette(int index) {
|
public BlockState getAtPalette(int index) {
|
||||||
+17
-18
@@ -22,7 +22,7 @@ import baritone.api.event.events.TabCompleteEvent;
|
|||||||
import com.mojang.brigadier.context.StringRange;
|
import com.mojang.brigadier.context.StringRange;
|
||||||
import com.mojang.brigadier.suggestion.Suggestion;
|
import com.mojang.brigadier.suggestion.Suggestion;
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
import com.mojang.brigadier.suggestion.Suggestions;
|
||||||
import net.minecraft.client.gui.CommandSuggestionHelper;
|
import net.minecraft.client.gui.screen.ChatScreen;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -40,28 +40,27 @@ import java.util.stream.Stream;
|
|||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 10/9/2019
|
* @since 10/9/2019
|
||||||
*/
|
*/
|
||||||
@Mixin(CommandSuggestionHelper.class)
|
@Mixin(ChatScreen.class)
|
||||||
public class MixinCommandSuggestionHelper {
|
public class MixinChatScreen {
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
protected TextFieldWidget inputField;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
private TextFieldWidget field_228095_d_;
|
protected List<String> commandUsage;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
private CompletableFuture<Suggestions> pendingSuggestions;
|
||||||
private List<String> field_228103_l_;
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
private CompletableFuture<Suggestions> field_228107_p_;
|
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "func_228111_a_",
|
method = "updateSuggestion",
|
||||||
at = @At("HEAD"),
|
at = @At("HEAD"),
|
||||||
cancellable = true
|
cancellable = true
|
||||||
)
|
)
|
||||||
private void preUpdateSuggestion(CallbackInfo ci) {
|
private void preUpdateSuggestion(CallbackInfo ci) {
|
||||||
// Anything that is present in the input text before the cursor position
|
// Anything that is present in the input text before the cursor position
|
||||||
String prefix = this.field_228095_d_.getText().substring(0, Math.min(this.field_228095_d_.getText().length(), this.field_228095_d_.getCursorPosition()));
|
String prefix = this.inputField.getText().substring(0, Math.min(this.inputField.getText().length(), this.inputField.getCursorPosition()));
|
||||||
|
|
||||||
TabCompleteEvent event = new TabCompleteEvent(prefix);
|
TabCompleteEvent event = new TabCompleteEvent(prefix);
|
||||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onPreTabComplete(event);
|
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onPreTabComplete(event);
|
||||||
@@ -75,14 +74,14 @@ public class MixinCommandSuggestionHelper {
|
|||||||
ci.cancel();
|
ci.cancel();
|
||||||
|
|
||||||
// TODO: Support populating the command usage
|
// TODO: Support populating the command usage
|
||||||
this.field_228103_l_.clear();
|
this.commandUsage.clear();
|
||||||
|
|
||||||
if (event.completions.length == 0) {
|
if (event.completions.length == 0) {
|
||||||
this.field_228107_p_ = Suggestions.empty();
|
this.pendingSuggestions = Suggestions.empty();
|
||||||
} else {
|
} else {
|
||||||
int offset = this.field_228095_d_.getText().endsWith(" ")
|
int offset = this.inputField.getText().endsWith(" ")
|
||||||
? this.field_228095_d_.getCursorPosition()
|
? this.inputField.getCursorPosition()
|
||||||
: this.field_228095_d_.getText().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes
|
: this.inputField.getText().lastIndexOf(" ") + 1; // If there is no space this is still 0 haha yes
|
||||||
|
|
||||||
List<Suggestion> suggestionList = Stream.of(event.completions)
|
List<Suggestion> suggestionList = Stream.of(event.completions)
|
||||||
.map(s -> new Suggestion(StringRange.between(offset, offset + s.length()), s))
|
.map(s -> new Suggestion(StringRange.between(offset, offset + s.length()), s))
|
||||||
@@ -92,8 +91,8 @@ public class MixinCommandSuggestionHelper {
|
|||||||
StringRange.between(offset, offset + suggestionList.stream().mapToInt(s -> s.getText().length()).max().orElse(0)),
|
StringRange.between(offset, offset + suggestionList.stream().mapToInt(s -> s.getText().length()).max().orElse(0)),
|
||||||
suggestionList);
|
suggestionList);
|
||||||
|
|
||||||
this.field_228107_p_ = new CompletableFuture<>();
|
this.pendingSuggestions = new CompletableFuture<>();
|
||||||
this.field_228107_p_.complete(suggestions);
|
this.pendingSuggestions.complete(suggestions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,23 +20,29 @@ package baritone.launch.mixins;
|
|||||||
import baritone.utils.accessor.IEntityRenderManager;
|
import baritone.utils.accessor.IEntityRenderManager;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
@Mixin(EntityRendererManager.class)
|
@Mixin(EntityRendererManager.class)
|
||||||
public class MixinEntityRenderManager implements IEntityRenderManager {
|
public class MixinEntityRenderManager implements IEntityRenderManager {
|
||||||
|
@Shadow
|
||||||
|
private double renderPosX;
|
||||||
|
@Shadow
|
||||||
|
private double renderPosY;
|
||||||
|
@Shadow
|
||||||
|
private double renderPosZ;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double renderPosX() {
|
public double renderPosX() {
|
||||||
return ((EntityRendererManager) (Object) this).info.getProjectedView().x;
|
return renderPosX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double renderPosY() {
|
public double renderPosY() {
|
||||||
return ((EntityRendererManager) (Object) this).info.getProjectedView().y;
|
return renderPosY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double renderPosZ() {
|
public double renderPosZ() {
|
||||||
return ((EntityRendererManager) (Object) this).info.getProjectedView().z;
|
return renderPosZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-15
@@ -20,29 +20,26 @@ package baritone.launch.mixins;
|
|||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.event.events.RenderEvent;
|
import baritone.api.event.events.RenderEvent;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.*;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
||||||
|
|
||||||
/**
|
@Mixin(GameRenderer.class)
|
||||||
* @author Brady
|
public class MixinGameRenderer {
|
||||||
* @since 2/13/2020
|
|
||||||
*/
|
|
||||||
@Mixin(WorldRenderer.class)
|
|
||||||
public class MixinWorldRenderer {
|
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "updateCameraAndRender",
|
method = "updateCameraAndRender(FJ)V",
|
||||||
at = @At("RETURN"),
|
at = @At(
|
||||||
locals = LocalCapture.CAPTURE_FAILSOFT
|
value = "INVOKE_STRING",
|
||||||
|
target = "Lnet/minecraft/profiler/IProfiler;endStartSection(Ljava/lang/String;)V",
|
||||||
|
args = {"ldc=hand"}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
private void onStartHand(MatrixStack matrixStackIn, float partialTicks, long finishTimeNano, boolean drawBlockOutline, ActiveRenderInfo activeRenderInfoIn, GameRenderer gameRendererIn, LightTexture lightmapIn, Matrix4f projectionIn, CallbackInfo ci) {
|
private void renderWorldPass(float partialTicks, long finishTimeNano, CallbackInfo ci) {
|
||||||
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
|
||||||
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks, matrixStackIn, projectionIn));
|
ibaritone.getGameEventHandler().onRenderPass(new RenderEvent(partialTicks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,6 @@ import baritone.api.utils.BlockOptionalMeta;
|
|||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.server.ServerWorld;
|
import net.minecraft.world.server.ServerWorld;
|
||||||
import net.minecraft.world.storage.loot.LootContext;
|
import net.minecraft.world.storage.loot.LootContext;
|
||||||
import net.minecraft.world.storage.loot.LootPredicateManager;
|
|
||||||
import net.minecraft.world.storage.loot.LootTableManager;
|
import net.minecraft.world.storage.loot.LootTableManager;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
@@ -57,18 +56,4 @@ public class MixinLootContext {
|
|||||||
}
|
}
|
||||||
return server.getLootTableManager();
|
return server.getLootTableManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(
|
|
||||||
method = "build",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "net/minecraft/server/MinecraftServer.func_229736_aP_()Lnet/minecraft/world/storage/loot/LootPredicateManager;"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private LootPredicateManager getLootPredicateManager(MinecraftServer server) {
|
|
||||||
if (server == null) {
|
|
||||||
return BlockOptionalMeta.getPredicateManager();
|
|
||||||
}
|
|
||||||
return server.func_229736_aP_();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package baritone.launch.mixins;
|
|||||||
|
|
||||||
import baritone.api.BaritoneAPI;
|
import baritone.api.BaritoneAPI;
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
|
import baritone.api.event.events.BlockInteractEvent;
|
||||||
import baritone.api.event.events.TickEvent;
|
import baritone.api.event.events.TickEvent;
|
||||||
import baritone.api.event.events.WorldEvent;
|
import baritone.api.event.events.WorldEvent;
|
||||||
import baritone.api.event.events.type.EventState;
|
import baritone.api.event.events.type.EventState;
|
||||||
@@ -27,6 +28,10 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.ActionResultType;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import org.spongepowered.asm.lib.Opcodes;
|
import org.spongepowered.asm.lib.Opcodes;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -34,6 +39,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
@@ -50,7 +56,7 @@ public class MixinMinecraft {
|
|||||||
public ClientWorld world;
|
public ClientWorld world;
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "<init>",
|
method = "init",
|
||||||
at = @At("RETURN")
|
at = @At("RETURN")
|
||||||
)
|
)
|
||||||
private void postInit(CallbackInfo ci) {
|
private void postInit(CallbackInfo ci) {
|
||||||
@@ -58,8 +64,11 @@ public class MixinMinecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "startTimerHackThread",
|
method = "init",
|
||||||
at = @At("HEAD")
|
at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "net/minecraft/client/Minecraft.startTimerHackThread()V"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
private void preInit(CallbackInfo ci) {
|
private void preInit(CallbackInfo ci) {
|
||||||
BaritoneAutoTest.INSTANCE.onPreInit();
|
BaritoneAutoTest.INSTANCE.onPreInit();
|
||||||
@@ -139,24 +148,16 @@ public class MixinMinecraft {
|
|||||||
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.passEvents;
|
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.passEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
@Inject(
|
||||||
// FIXME
|
|
||||||
// bradyfix
|
|
||||||
// i cant mixin
|
|
||||||
// lol
|
|
||||||
// https://discordapp.com/channels/208753003996512258/503692253881958400/674760939681349652
|
|
||||||
// https://discordapp.com/channels/208753003996512258/503692253881958400/674756457966862376
|
|
||||||
/*@Inject(
|
|
||||||
method = "rightClickMouse",
|
method = "rightClickMouse",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "net/minecraft/client/entity/player/ClientPlayerEntity.swingArm(Lnet/minecraft/util/Hand;)V",
|
target = "net/minecraft/client/entity/player/ClientPlayerEntity.swingArm(Lnet/minecraft/util/Hand;)V"
|
||||||
ordinal = 1
|
|
||||||
),
|
),
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
)
|
)
|
||||||
private void onBlockUse(CallbackInfo ci, Hand var1[], int var2, int var3, Hand enumhand, ItemStack itemstack, EntityRayTraceResult rt, Entity ent, ActionResultType art, BlockRayTraceResult raytrace, int i, ActionResultType enumactionresult) {
|
private void onBlockUse(CallbackInfo ci, Hand var1[], int var2, int var3, Hand enumhand, ItemStack itemstack, BlockRayTraceResult raytrace, int i, ActionResultType enumactionresult) {
|
||||||
// rightClickMouse is only for the main player
|
// rightClickMouse is only for the main player
|
||||||
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(raytrace.getPos(), BlockInteractEvent.Type.USE));
|
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(raytrace.getPos(), BlockInteractEvent.Type.USE));
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,24 +76,24 @@ public abstract class MixinMouse implements IMouse
|
|||||||
@Override
|
@Override
|
||||||
public void rightHold()
|
public void rightHold()
|
||||||
{
|
{
|
||||||
mouseButtonCallback(minecraft.getMainWindow().getHandle(), 1, 1, 0);
|
mouseButtonCallback(minecraft.mainWindow.getHandle(), 1, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void rightRelease()
|
public void rightRelease()
|
||||||
{
|
{
|
||||||
mouseButtonCallback(minecraft.getMainWindow().getHandle(), 1, 0, 0);
|
mouseButtonCallback(minecraft.mainWindow.getHandle(), 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void leftHold()
|
public void leftHold()
|
||||||
{
|
{
|
||||||
mouseButtonCallback(minecraft.getMainWindow().getHandle(), 0, 1, 0);
|
mouseButtonCallback(minecraft.mainWindow.getHandle(), 0, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void leftRelease()
|
public void leftRelease()
|
||||||
{
|
{
|
||||||
mouseButtonCallback(minecraft.getMainWindow().getHandle(), 0, 0, 0);
|
mouseButtonCallback(minecraft.mainWindow.getHandle(), 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,21 @@
|
|||||||
},
|
},
|
||||||
"client": [
|
"client": [
|
||||||
"MixinBitArray",
|
"MixinBitArray",
|
||||||
|
"MixinBlockStateContainer",
|
||||||
|
"MixinChatScreen",
|
||||||
"MixinChunkArray",
|
"MixinChunkArray",
|
||||||
"MixinClientChunkProvider",
|
"MixinClientChunkProvider",
|
||||||
"MixinClientPlayerEntity",
|
"MixinClientPlayerEntity",
|
||||||
"MixinClientPlayNetHandler",
|
"MixinClientPlayNetHandler",
|
||||||
"MixinCommandSuggestionHelper",
|
|
||||||
"MixinEntity",
|
"MixinEntity",
|
||||||
"MixinEntityRenderManager",
|
"MixinEntityRenderManager",
|
||||||
|
"MixinGameRenderer",
|
||||||
"MixinItemStack",
|
"MixinItemStack",
|
||||||
"MixinLivingEntity",
|
"MixinLivingEntity",
|
||||||
"MixinLootContext",
|
"MixinLootContext",
|
||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinNetworkManager",
|
"MixinNetworkManager",
|
||||||
"MixinPalettedContainer",
|
|
||||||
"MixinPlayerController",
|
"MixinPlayerController",
|
||||||
"MixinScreen",
|
"MixinScreen"
|
||||||
"MixinWorldRenderer"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -25,14 +25,14 @@ import baritone.api.utils.Helper;
|
|||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.behavior.*;
|
import baritone.behavior.*;
|
||||||
import baritone.cache.WorldProvider;
|
import baritone.cache.WorldProvider;
|
||||||
|
import baritone.command.manager.CommandManager;
|
||||||
import baritone.event.GameEventHandler;
|
import baritone.event.GameEventHandler;
|
||||||
import baritone.process.*;
|
import baritone.process.*;
|
||||||
import baritone.selection.SelectionManager;
|
import baritone.selection.SelectionManager;
|
||||||
import baritone.utils.*;
|
import baritone.utils.*;
|
||||||
import baritone.command.manager.CommandManager;
|
|
||||||
import baritone.utils.player.PrimaryPlayerContext;
|
import baritone.utils.player.PrimaryPlayerContext;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.hydev.hyritone.Hyritone;
|
import org.hydev.hyritone.Hyritone;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public final class InventoryBehavior extends Behavior {
|
|||||||
|
|
||||||
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
public boolean selectThrowawayForLocation(boolean select, int x, int y, int z) {
|
||||||
BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z, baritone.bsi.get0(x, y, z));
|
BlockState maybe = baritone.getBuilderProcess().placeAt(x, y, z, baritone.bsi.get0(x, y, z));
|
||||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {}))))) {
|
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && maybe.equals(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().posX, ctx.player().posY, ctx.player().posZ), Direction.UP, ctx.playerFeet(), false)) {}))))) {
|
||||||
return true; // gotem
|
return true; // gotem
|
||||||
}
|
}
|
||||||
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
if (maybe != null && throwaway(select, stack -> stack.getItem() instanceof BlockItem && ((BlockItem) stack.getItem()).getBlock().equals(maybe.getBlock()))) {
|
||||||
|
|||||||
@@ -381,8 +381,8 @@ public final class PathingBehavior extends Behavior implements IPathingBehavior,
|
|||||||
BetterBlockPos feet = ctx.playerFeet();
|
BetterBlockPos feet = ctx.playerFeet();
|
||||||
if (!MovementHelper.canWalkOn(ctx, feet.down())) {
|
if (!MovementHelper.canWalkOn(ctx, feet.down())) {
|
||||||
if (ctx.player().onGround) {
|
if (ctx.player().onGround) {
|
||||||
double playerX = ctx.player().getPositionVec().x;
|
double playerX = ctx.player().posX;
|
||||||
double playerZ = ctx.player().getPositionVec().z;
|
double playerZ = ctx.player().posZ;
|
||||||
ArrayList<BetterBlockPos> closest = new ArrayList<>();
|
ArrayList<BetterBlockPos> closest = new ArrayList<>();
|
||||||
for (int dx = -1; dx <= 1; dx++) {
|
for (int dx = -1; dx <= 1; dx++) {
|
||||||
for (int dz = -1; dz <= 1; dz++) {
|
for (int dz = -1; dz <= 1; dz++) {
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ import baritone.utils.pathing.PathingBlockType;
|
|||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.palette.PalettedContainer;
|
import net.minecraft.world.chunk.BlockStateContainer;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.ChunkSection;
|
import net.minecraft.world.chunk.ChunkSection;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public final class ChunkPacker {
|
|||||||
// since a bitset is initialized to all zero, and air is saved as zeros
|
// since a bitset is initialized to all zero, and air is saved as zeros
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PalettedContainer<BlockState> bsc = extendedblockstorage.getData();
|
BlockStateContainer<BlockState> bsc = extendedblockstorage.getData();
|
||||||
int yReal = y0 << 4;
|
int yReal = y0 << 4;
|
||||||
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
// the mapping of BlockStateContainer.getIndex from xyz to index is y << 8 | z << 4 | x;
|
||||||
// for better cache locality, iterate in that order
|
// for better cache locality, iterate in that order
|
||||||
|
|||||||
+3
-2
@@ -22,7 +22,7 @@ import baritone.api.cache.IWorldScanner;
|
|||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.BlockOptionalMetaLookup;
|
import baritone.api.utils.BlockOptionalMetaLookup;
|
||||||
import baritone.api.utils.IPlayerContext;
|
import baritone.api.utils.IPlayerContext;
|
||||||
import baritone.utils.accessor.IPalettedContainer;
|
import baritone.utils.accessor.IBlockStateContainer;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.multiplayer.ClientChunkProvider;
|
import net.minecraft.client.multiplayer.ClientChunkProvider;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -30,6 +30,7 @@ import net.minecraft.util.math.ChunkPos;
|
|||||||
import net.minecraft.world.chunk.AbstractChunkProvider;
|
import net.minecraft.world.chunk.AbstractChunkProvider;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.ChunkSection;
|
import net.minecraft.world.chunk.ChunkSection;
|
||||||
|
import net.minecraft.world.chunk.IChunk;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
@@ -155,7 +156,7 @@ public enum WorldScanner implements IWorldScanner {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int yReal = y0 << 4;
|
int yReal = y0 << 4;
|
||||||
IPalettedContainer bsc = (IPalettedContainer) section.getData();
|
IBlockStateContainer bsc = (IBlockStateContainer) section.getData();
|
||||||
// storageArray uses an optimized algorithm that's faster than getAt
|
// storageArray uses an optimized algorithm that's faster than getAt
|
||||||
// creating this array and then using getAtPalette is faster than even getFast(int index)
|
// creating this array and then using getAtPalette is faster than even getFast(int index)
|
||||||
int[] storage = bsc.storageArray();
|
int[] storage = bsc.storageArray();
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
|
|
||||||
package baritone.command.argument;
|
package baritone.command.argument;
|
||||||
|
|
||||||
import baritone.Baritone;
|
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
import baritone.api.command.argument.IArgConsumer;
|
|
||||||
import baritone.api.command.argument.ICommandArgument;
|
import baritone.api.command.argument.ICommandArgument;
|
||||||
import baritone.api.command.datatypes.IDatatype;
|
import baritone.api.command.datatypes.IDatatype;
|
||||||
import baritone.api.command.datatypes.IDatatypeContext;
|
import baritone.api.command.datatypes.IDatatypeContext;
|
||||||
@@ -29,6 +27,7 @@ import baritone.api.command.exception.CommandException;
|
|||||||
import baritone.api.command.exception.CommandInvalidTypeException;
|
import baritone.api.command.exception.CommandInvalidTypeException;
|
||||||
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
import baritone.api.command.exception.CommandNotEnoughArgumentsException;
|
||||||
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
import baritone.api.command.exception.CommandTooManyArgumentsException;
|
||||||
|
import baritone.api.command.argument.IArgConsumer;
|
||||||
import baritone.api.command.manager.ICommandManager;
|
import baritone.api.command.manager.ICommandManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -317,9 +316,6 @@ public class ArgConsumer implements IArgConsumer {
|
|||||||
try {
|
try {
|
||||||
return datatype.apply(this.context, original);
|
return datatype.apply(this.context, original);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Baritone.settings().verboseCommandExceptions.value) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
throw new CommandInvalidTypeException(hasAny() ? peek() : consumed(), datatype.getClass().getSimpleName(), e);
|
throw new CommandInvalidTypeException(hasAny() ? peek() : consumed(), datatype.getClass().getSimpleName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,9 +345,6 @@ public class ArgConsumer implements IArgConsumer {
|
|||||||
try {
|
try {
|
||||||
return datatype.get(this.context);
|
return datatype.get(this.context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Baritone.settings().verboseCommandExceptions.value) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
throw new CommandInvalidTypeException(hasAny() ? peek() : consumed(), datatype.getClass().getSimpleName(), e);
|
throw new CommandInvalidTypeException(hasAny() ? peek() : consumed(), datatype.getClass().getSimpleName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class SelCommand extends Command {
|
|||||||
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
float lineWidth = Baritone.settings().selectionLineWidth.value;
|
||||||
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
boolean ignoreDepth = Baritone.settings().renderSelectionIgnoreDepth.value;
|
||||||
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
IRenderer.startLines(color, opacity, lineWidth, ignoreDepth);
|
||||||
IRenderer.drawAABB(event.getModelViewStack(), new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
IRenderer.drawAABB(new AxisAlignedBB(pos1, pos1.add(1, 1, 1)));
|
||||||
IRenderer.endLines(ignoreDepth);
|
IRenderer.endLines(ignoreDepth);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
if (block instanceof AirBlock) { // early return for most common case
|
if (block instanceof AirBlock) { // early return for most common case
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock || block == Blocks.HONEY_BLOCK) {
|
if (block == Blocks.FIRE || block == Blocks.TRIPWIRE || block == Blocks.COBWEB || block == Blocks.END_PORTAL || block == Blocks.COCOA || block instanceof AbstractSkullBlock || block == Blocks.BUBBLE_COLUMN || block instanceof ShulkerBoxBlock || block instanceof SlabBlock || block instanceof TrapDoorBlock) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
if (Baritone.settings().blocksToAvoid.value.contains(block)) {
|
||||||
@@ -295,7 +295,7 @@ public interface MovementHelper extends ActionCosts, Helper {
|
|||||||
*/
|
*/
|
||||||
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, BlockState state) {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN || block == Blocks.HONEY_BLOCK) {
|
if (block instanceof AirBlock || block == Blocks.MAGMA_BLOCK || block == Blocks.BUBBLE_COLUMN) {
|
||||||
// early return for most common case (air)
|
// early return for most common case (air)
|
||||||
// plus magma, which is a normal cube but it hurts you
|
// plus magma, which is a normal cube but it hurts you
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class MovementAscend extends Movement {
|
|||||||
ticksWithoutPlacement++;
|
ticksWithoutPlacement++;
|
||||||
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) {
|
if (MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false) == PlaceResult.READY_TO_PLACE) {
|
||||||
state.setInput(Input.SNEAK, true);
|
state.setInput(Input.SNEAK, true);
|
||||||
if (ctx.player().isCrouching()) {
|
if (ctx.player().isSneaking()) {
|
||||||
state.setInput(Input.CLICK_RIGHT, true);
|
state.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -199,8 +199,8 @@ public class MovementAscend extends Movement {
|
|||||||
|
|
||||||
int xAxis = Math.abs(src.getX() - dest.getX()); // either 0 or 1
|
int xAxis = Math.abs(src.getX() - dest.getX()); // either 0 or 1
|
||||||
int zAxis = Math.abs(src.getZ() - dest.getZ()); // either 0 or 1
|
int zAxis = Math.abs(src.getZ() - dest.getZ()); // either 0 or 1
|
||||||
double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().getPositionVec().x) + zAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().getPositionVec().z);
|
double flatDistToNext = xAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().posX) + zAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().posZ);
|
||||||
double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().getPositionVec().x) + xAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().getPositionVec().z);
|
double sideDist = zAxis * Math.abs((dest.getX() + 0.5D) - ctx.player().posX) + xAxis * Math.abs((dest.getZ() + 0.5D) - ctx.player().posZ);
|
||||||
|
|
||||||
double lateralMotion = xAxis * ctx.player().getMotion().z + zAxis * ctx.player().getMotion().x;
|
double lateralMotion = xAxis * ctx.player().getMotion().z + zAxis * ctx.player().getMotion().x;
|
||||||
if (Math.abs(lateralMotion) > 0.1) {
|
if (Math.abs(lateralMotion) > 0.1) {
|
||||||
|
|||||||
@@ -212,11 +212,11 @@ public class MovementDescend extends Movement {
|
|||||||
|
|
||||||
BlockPos playerFeet = ctx.playerFeet();
|
BlockPos playerFeet = ctx.playerFeet();
|
||||||
BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ());
|
BlockPos fakeDest = new BlockPos(dest.getX() * 2 - src.getX(), dest.getY(), dest.getZ() * 2 - src.getZ());
|
||||||
if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().getPositionVec().y - dest.getY() < 0.5)) { // lilypads
|
if ((playerFeet.equals(dest) || playerFeet.equals(fakeDest)) && (MovementHelper.isLiquid(ctx, dest) || ctx.player().posY - dest.getY() < 0.5)) { // lilypads
|
||||||
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
|
// Wait until we're actually on the ground before saying we're done because sometimes we continue to fall if the next action starts immediately
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
/* else {
|
/* else {
|
||||||
// System.out.println(player().getPositionVec().y + " " + playerFeet.getY() + " " + (player().getPositionVec().y - playerFeet.getY()));
|
// System.out.println(player().posY + " " + playerFeet.getY() + " " + (player().posY - playerFeet.getY()));
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
if (safeMode()) {
|
if (safeMode()) {
|
||||||
@@ -231,11 +231,11 @@ public class MovementDescend extends Movement {
|
|||||||
)).setInput(Input.MOVE_FORWARD, true);
|
)).setInput(Input.MOVE_FORWARD, true);
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
double diffX = ctx.player().getPositionVec().x - (dest.getX() + 0.5);
|
double diffX = ctx.player().posX - (dest.getX() + 0.5);
|
||||||
double diffZ = ctx.player().getPositionVec().z - (dest.getZ() + 0.5);
|
double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);
|
||||||
double ab = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
double ab = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
||||||
double x = ctx.player().getPositionVec().x - (src.getX() + 0.5);
|
double x = ctx.player().posX - (src.getX() + 0.5);
|
||||||
double z = ctx.player().getPositionVec().z - (src.getZ() + 0.5);
|
double z = ctx.player().posZ - (src.getZ() + 0.5);
|
||||||
double fromStart = Math.sqrt(x * x + z * z);
|
double fromStart = Math.sqrt(x * x + z * z);
|
||||||
if (!playerFeet.equals(dest) || ab > 0.25) {
|
if (!playerFeet.equals(dest) || ab > 0.25) {
|
||||||
if (numTicks++ < 20 && fromStart < 1.25) {
|
if (numTicks++ < 20 && fromStart < 1.25) {
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ public class MovementDiagonal extends Movement {
|
|||||||
} else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) {
|
} else if (!playerInValidPosition() && !(MovementHelper.isLiquid(ctx, src) && getValidPositions().contains(ctx.playerFeet().up()))) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
if (dest.y > src.y && ctx.player().getPositionVec().y < src.y + 0.1 && ctx.player().collidedHorizontally) {
|
if (dest.y > src.y && ctx.player().posY < src.y + 0.1 && ctx.player().collidedHorizontally) {
|
||||||
state.setInput(Input.JUMP, true);
|
state.setInput(Input.JUMP, true);
|
||||||
}
|
}
|
||||||
if (sprint()) {
|
if (sprint()) {
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ public class MovementDownward extends Movement {
|
|||||||
} else if (!playerInValidPosition()) {
|
} else if (!playerInValidPosition()) {
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
double diffX = ctx.player().getPositionVec().x - (dest.getX() + 0.5);
|
double diffX = ctx.player().posX - (dest.getX() + 0.5);
|
||||||
double diffZ = ctx.player().getPositionVec().z - (dest.getZ() + 0.5);
|
double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);
|
||||||
double ab = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
double ab = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
||||||
|
|
||||||
if (numTicks++ < 10 && ab < 0.2) {
|
if (numTicks++ < 10 && ab < 0.2) {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class MovementFall extends Movement {
|
|||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.player().getPositionVec().y - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().onGround) {
|
if (ctx.player().posY - dest.getY() < ctx.playerController().getBlockReachDistance() && !ctx.player().onGround) {
|
||||||
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER);
|
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_WATER);
|
||||||
|
|
||||||
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
targetRotation = new Rotation(toDest.getYaw(), 90.0F);
|
||||||
@@ -115,7 +115,7 @@ public class MovementFall extends Movement {
|
|||||||
} else {
|
} else {
|
||||||
state.setTarget(new MovementTarget(toDest, false));
|
state.setTarget(new MovementTarget(toDest, false));
|
||||||
}
|
}
|
||||||
if (playerFeet.equals(dest) && (ctx.player().getPositionVec().y - playerFeet.getY() < 0.094 || isWater)) { // 0.094 because lilypads
|
if (playerFeet.equals(dest) && (ctx.player().posY - 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 (isWater) { // only match water, not flowing water (which we cannot pick up with a bucket)
|
||||||
if (PlayerInventory.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
if (PlayerInventory.isHotbar(ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY))) {
|
||||||
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
ctx.player().inventory.currentItem = ctx.player().inventory.getSlotFor(STACK_BUCKET_EMPTY);
|
||||||
@@ -134,7 +134,7 @@ public class MovementFall extends Movement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder)
|
Vec3d destCenter = VecUtils.getBlockPosCenter(dest); // we are moving to the 0.5 center not the edge (like if we were falling on a ladder)
|
||||||
if (Math.abs(ctx.player().getPositionVec().x + ctx.player().getMotion().x - destCenter.x) > 0.1 || Math.abs(ctx.player().getPositionVec().z + ctx.player().getMotion().z - destCenter.z) > 0.1) {
|
if (Math.abs(ctx.player().posX + ctx.player().getMotion().x - destCenter.x) > 0.1 || Math.abs(ctx.player().posZ + ctx.player().getMotion().z - destCenter.z) > 0.1) {
|
||||||
if (!ctx.player().onGround && Math.abs(ctx.player().getMotion().y) > 0.4) {
|
if (!ctx.player().onGround && Math.abs(ctx.player().getMotion().y) > 0.4) {
|
||||||
state.setInput(Input.SNEAK, true);
|
state.setInput(Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,7 @@ public class MovementFall extends Movement {
|
|||||||
if (avoid == null) {
|
if (avoid == null) {
|
||||||
avoid = src.subtract(dest);
|
avoid = src.subtract(dest);
|
||||||
} else {
|
} else {
|
||||||
double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().getPositionVec().x)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().getPositionVec().z));
|
double dist = Math.abs(avoid.getX() * (destCenter.x - avoid.getX() / 2.0 - ctx.player().posX)) + Math.abs(avoid.getZ() * (destCenter.z - avoid.getZ() / 2.0 - ctx.player().posZ));
|
||||||
if (dist < 0.6) {
|
if (dist < 0.6) {
|
||||||
state.setInput(Input.MOVE_FORWARD, true);
|
state.setInput(Input.MOVE_FORWARD, true);
|
||||||
} else if (!ctx.player().onGround) {
|
} else if (!ctx.player().onGround) {
|
||||||
|
|||||||
@@ -246,19 +246,19 @@ public class MovementParkour extends Movement {
|
|||||||
// but i did it anyway
|
// but i did it anyway
|
||||||
return state.setStatus(MovementStatus.SUCCESS);
|
return state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
if (ctx.player().getPositionVec().y - ctx.playerFeet().getY() < 0.094) { // lilypads
|
if (ctx.player().posY - ctx.playerFeet().getY() < 0.094) { // lilypads
|
||||||
state.setStatus(MovementStatus.SUCCESS);
|
state.setStatus(MovementStatus.SUCCESS);
|
||||||
}
|
}
|
||||||
} else if (!ctx.playerFeet().equals(src)) {
|
} else if (!ctx.playerFeet().equals(src)) {
|
||||||
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().getPositionVec().y - src.y > 0.0001) {
|
if (ctx.playerFeet().equals(src.offset(direction)) || ctx.player().posY - src.y > 0.0001) {
|
||||||
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
|
if (!MovementHelper.canWalkOn(ctx, dest.down()) && !ctx.player().onGround && MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), true) == PlaceResult.READY_TO_PLACE) {
|
||||||
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
// go in the opposite order to check DOWN before all horizontals -- down is preferable because you don't have to look to the side while in midair, which could mess up the trajectory
|
||||||
state.setInput(Input.CLICK_RIGHT, true);
|
state.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
// prevent jumping too late by checking for ascend
|
// prevent jumping too late by checking for ascend
|
||||||
if (dist == 3 && !ascend) { // this is a 2 block gap, dest = src + direction * 3
|
if (dist == 3 && !ascend) { // this is a 2 block gap, dest = src + direction * 3
|
||||||
double xDiff = (src.x + 0.5) - ctx.player().getPositionVec().x;
|
double xDiff = (src.x + 0.5) - ctx.player().posX;
|
||||||
double zDiff = (src.z + 0.5) - ctx.player().getPositionVec().z;
|
double zDiff = (src.z + 0.5) - ctx.player().posZ;
|
||||||
double distFromStart = Math.max(Math.abs(xDiff), Math.abs(zDiff));
|
double distFromStart = Math.max(Math.abs(xDiff), Math.abs(zDiff));
|
||||||
if (distFromStart < 0.7) {
|
if (distFromStart < 0.7) {
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class MovementPillar extends Movement {
|
|||||||
// stay centered while swimming up a water column
|
// stay centered while swimming up a water column
|
||||||
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
state.setTarget(new MovementState.MovementTarget(RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.getBlockPosCenter(dest), ctx.playerRotations()), false));
|
||||||
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
Vec3d destCenter = VecUtils.getBlockPosCenter(dest);
|
||||||
if (Math.abs(ctx.player().getPositionVec().x - destCenter.x) > 0.2 || Math.abs(ctx.player().getPositionVec().z - destCenter.z) > 0.2) {
|
if (Math.abs(ctx.player().posX - destCenter.x) > 0.2 || Math.abs(ctx.player().posZ - destCenter.z) > 0.2) {
|
||||||
state.setInput(Input.MOVE_FORWARD, true);
|
state.setInput(Input.MOVE_FORWARD, true);
|
||||||
}
|
}
|
||||||
if (ctx.playerFeet().equals(dest)) {
|
if (ctx.playerFeet().equals(dest)) {
|
||||||
@@ -218,11 +218,11 @@ public class MovementPillar extends Movement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
state.setInput(Input.SNEAK, ctx.player().getPositionVec().y > dest.getY() || ctx.player().getPositionVec().y < src.getY() + 0.2D); // delay placement by 1 tick for ncp compatibility
|
state.setInput(Input.SNEAK, ctx.player().posY > dest.getY() || ctx.player().posY < src.getY() + 0.2D); // delay placement by 1 tick for ncp compatibility
|
||||||
// since (lower down) we only right click once player.isSneaking, and that happens the tick after we request to sneak
|
// since (lower down) we only right click once player.isSneaking, and that happens the tick after we request to sneak
|
||||||
|
|
||||||
double diffX = ctx.player().getPositionVec().x - (dest.getX() + 0.5);
|
double diffX = ctx.player().posX - (dest.getX() + 0.5);
|
||||||
double diffZ = ctx.player().getPositionVec().z - (dest.getZ() + 0.5);
|
double diffZ = ctx.player().posZ - (dest.getZ() + 0.5);
|
||||||
double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);
|
||||||
double flatMotion = Math.sqrt(ctx.player().getMotion().x * ctx.player().getMotion().x + ctx.player().getMotion().z * ctx.player().getMotion().z);
|
double flatMotion = Math.sqrt(ctx.player().getMotion().x * ctx.player().getMotion().x + ctx.player().getMotion().z * ctx.player().getMotion().z);
|
||||||
if (dist > 0.17) {//why 0.17? because it seemed like a good number, that's why
|
if (dist > 0.17) {//why 0.17? because it seemed like a good number, that's why
|
||||||
@@ -236,7 +236,7 @@ public class MovementPillar extends Movement {
|
|||||||
state.setTarget(new MovementState.MovementTarget(rotation, true));
|
state.setTarget(new MovementState.MovementTarget(rotation, true));
|
||||||
} else if (flatMotion < 0.05) {
|
} else if (flatMotion < 0.05) {
|
||||||
// If our Y coordinate is above our goal, stop jumping
|
// If our Y coordinate is above our goal, stop jumping
|
||||||
state.setInput(Input.JUMP, ctx.player().getPositionVec().y < dest.getY());
|
state.setInput(Input.JUMP, ctx.player().posY < dest.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -251,7 +251,7 @@ public class MovementPillar extends Movement {
|
|||||||
state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping
|
state.setInput(Input.JUMP, false); // breaking is like 5x slower when you're jumping
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
state.setInput(Input.CLICK_LEFT, true);
|
||||||
blockIsThere = false;
|
blockIsThere = false;
|
||||||
} else if (ctx.player().isCrouching() && (ctx.isLookingAt(src.down()) || ctx.isLookingAt(src)) && ctx.player().getPositionVec().y > dest.getY() + 0.1) {
|
} else if (ctx.player().isSneaking() && (ctx.isLookingAt(src.down()) || ctx.isLookingAt(src)) && ctx.player().posY > dest.getY() + 0.1) {
|
||||||
state.setInput(Input.CLICK_RIGHT, true);
|
state.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class MovementTraverse extends Movement {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
// and we aren't already pressed up against the block
|
// and we aren't already pressed up against the block
|
||||||
double dist = Math.max(Math.abs(ctx.player().getPositionVec().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().getPositionVec().z - (dest.getZ() + 0.5D)));
|
double dist = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D)));
|
||||||
if (dist < 0.83) {
|
if (dist < 0.83) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ public class MovementTraverse extends Movement {
|
|||||||
}
|
}
|
||||||
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
Block low = BlockStateInterface.get(ctx, src).getBlock();
|
||||||
Block high = BlockStateInterface.get(ctx, src.up()).getBlock();
|
Block high = BlockStateInterface.get(ctx, src.up()).getBlock();
|
||||||
if (ctx.player().getPositionVec().y > src.y + 0.1D && !ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
if (ctx.player().posY > src.y + 0.1D && !ctx.player().onGround && (low == Blocks.VINE || low == Blocks.LADDER || high == Blocks.VINE || high == Blocks.LADDER)) {
|
||||||
// hitting W could cause us to climb the ladder instead of going forward
|
// hitting W could cause us to climb the ladder instead of going forward
|
||||||
// wait until we're on the ground
|
// wait until we're on the ground
|
||||||
return state;
|
return state;
|
||||||
@@ -272,21 +272,21 @@ public class MovementTraverse extends Movement {
|
|||||||
wasTheBridgeBlockAlwaysThere = false;
|
wasTheBridgeBlockAlwaysThere = false;
|
||||||
Block standingOn = BlockStateInterface.get(ctx, feet.down()).getBlock();
|
Block standingOn = BlockStateInterface.get(ctx, feet.down()).getBlock();
|
||||||
if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof SlabBlock) { // see issue #118
|
if (standingOn.equals(Blocks.SOUL_SAND) || standingOn instanceof SlabBlock) { // see issue #118
|
||||||
double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().getPositionVec().x), Math.abs(dest.getZ() + 0.5 - ctx.player().getPositionVec().z));
|
double dist = Math.max(Math.abs(dest.getX() + 0.5 - ctx.player().posX), Math.abs(dest.getZ() + 0.5 - ctx.player().posZ));
|
||||||
if (dist < 0.85) { // 0.5 + 0.3 + epsilon
|
if (dist < 0.85) { // 0.5 + 0.3 + epsilon
|
||||||
MovementHelper.moveTowards(ctx, state, dest);
|
MovementHelper.moveTowards(ctx, state, dest);
|
||||||
return state.setInput(Input.MOVE_FORWARD, false)
|
return state.setInput(Input.MOVE_FORWARD, false)
|
||||||
.setInput(Input.MOVE_BACK, true);
|
.setInput(Input.MOVE_BACK, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double dist1 = Math.max(Math.abs(ctx.player().getPositionVec().x - (dest.getX() + 0.5D)), Math.abs(ctx.player().getPositionVec().z - (dest.getZ() + 0.5D)));
|
double dist1 = Math.max(Math.abs(ctx.player().posX - (dest.getX() + 0.5D)), Math.abs(ctx.player().posZ - (dest.getZ() + 0.5D)));
|
||||||
PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false);
|
PlaceResult p = MovementHelper.attemptToPlaceABlock(state, baritone, dest.down(), false);
|
||||||
if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) {
|
if ((p == PlaceResult.READY_TO_PLACE || dist1 < 0.6) && !Baritone.settings().assumeSafeWalk.value) {
|
||||||
state.setInput(Input.SNEAK, true);
|
state.setInput(Input.SNEAK, true);
|
||||||
}
|
}
|
||||||
switch (p) {
|
switch (p) {
|
||||||
case READY_TO_PLACE: {
|
case READY_TO_PLACE: {
|
||||||
if (ctx.player().isCrouching() || Baritone.settings().assumeSafeWalk.value) {
|
if (ctx.player().isSneaking() || Baritone.settings().assumeSafeWalk.value) {
|
||||||
state.setInput(Input.CLICK_RIGHT, true);
|
state.setInput(Input.CLICK_RIGHT, true);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
@@ -319,7 +319,7 @@ public class MovementTraverse extends Movement {
|
|||||||
|
|
||||||
Rotation backToFace = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
Rotation backToFace = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), new Vec3d(faceX, faceY, faceZ), ctx.playerRotations());
|
||||||
float pitch = backToFace.getPitch();
|
float pitch = backToFace.getPitch();
|
||||||
double dist2 = Math.max(Math.abs(ctx.player().getPositionVec().x - faceX), Math.abs(ctx.player().getPositionVec().z - faceZ));
|
double dist2 = Math.max(Math.abs(ctx.player().posX - faceX), Math.abs(ctx.player().posZ - faceZ));
|
||||||
if (dist2 < 0.29) { // see issue #208
|
if (dist2 < 0.29) { // see issue #208
|
||||||
float yaw = RotationUtils.calcRotationFromVec3d(VecUtils.getBlockPosCenter(dest), ctx.playerHead(), ctx.playerRotations()).getYaw();
|
float yaw = RotationUtils.calcRotationFromVec3d(VecUtils.getBlockPosCenter(dest), ctx.playerHead(), ctx.playerRotations()).getYaw();
|
||||||
state.setTarget(new MovementState.MovementTarget(new Rotation(yaw, pitch), true));
|
state.setTarget(new MovementState.MovementTarget(new Rotation(yaw, pitch), true));
|
||||||
|
|||||||
@@ -414,7 +414,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
// playerFeet adds 0.1251 to account for soul sand
|
// playerFeet adds 0.1251 to account for soul sand
|
||||||
// farmland is 0.9375
|
// farmland is 0.9375
|
||||||
// 0.07 is to account for farmland
|
// 0.07 is to account for farmland
|
||||||
if (ctx.player().getPositionVec().y >= center.getY() - 0.07) {
|
if (ctx.player().posY >= center.getY() - 0.07) {
|
||||||
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, false);
|
behavior.baritone.getInputOverrideHandler().setInputForceState(Input.JUMP, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean skipNow(IPlayerContext ctx, IMovement current) {
|
private static boolean skipNow(IPlayerContext ctx, IMovement current) {
|
||||||
double offTarget = Math.abs(current.getDirection().getX() * (current.getSrc().z + 0.5D - ctx.player().getPositionVec().z)) + Math.abs(current.getDirection().getZ() * (current.getSrc().x + 0.5D - ctx.player().getPositionVec().x));
|
double offTarget = Math.abs(current.getDirection().getX() * (current.getSrc().z + 0.5D - ctx.player().posZ)) + Math.abs(current.getDirection().getZ() * (current.getSrc().x + 0.5D - ctx.player().posX));
|
||||||
if (offTarget > 0.1) {
|
if (offTarget > 0.1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ public class PathExecutor implements IPathExecutor, Helper {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// wait 0.3
|
// wait 0.3
|
||||||
double flatDist = Math.abs(current.getDirection().getX() * (headBonk.getX() + 0.5D - ctx.player().getPositionVec().x)) + Math.abs(current.getDirection().getZ() * (headBonk.getZ() + 0.5 - ctx.player().getPositionVec().z));
|
double flatDist = Math.abs(current.getDirection().getX() * (headBonk.getX() + 0.5D - ctx.player().posX)) + Math.abs(current.getDirection().getZ() * (headBonk.getZ() + 0.5 - ctx.player().posZ));
|
||||||
return flatDist > 0.8;
|
return flatDist > 0.8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
BetterBlockPos pos = toBreak.get().getA();
|
BetterBlockPos pos = toBreak.get().getA();
|
||||||
baritone.getLookBehavior().updateTarget(rot, true);
|
baritone.getLookBehavior().updateTarget(rot, true);
|
||||||
MovementHelper.switchToBestToolFor(ctx, bcc.get(pos));
|
MovementHelper.switchToBestToolFor(ctx, bcc.get(pos));
|
||||||
if (ctx.player().isCrouching()) {
|
if (ctx.player().isSneaking()) {
|
||||||
// really horrible bug where a block is visible for breaking while sneaking but not otherwise
|
// really horrible bug where a block is visible for breaking while sneaking but not otherwise
|
||||||
// so you can't see it, it goes to place something else, sneaks, then the next tick it tries to break
|
// so you can't see it, it goes to place something else, sneaks, then the next tick it tries to break
|
||||||
// and is unable since it's unsneaked in the intermediary tick
|
// and is unable since it's unsneaked in the intermediary tick
|
||||||
@@ -781,7 +781,7 @@ public final class BuilderProcess extends BaritoneProcessHelper implements IBuil
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// <toxic cloud>
|
// <toxic cloud>
|
||||||
result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().getPositionVec().x, ctx.player().getPositionVec().y, ctx.player().getPositionVec().z), Direction.UP, ctx.playerFeet(), false)) {})));
|
result.add(((BlockItem) stack.getItem()).getBlock().getStateForPlacement(new BlockItemUseContext(new ItemUseContext(ctx.world(), ctx.player(), Hand.MAIN_HAND, stack, new BlockRayTraceResult(new Vec3d(ctx.player().posX, ctx.player().posY, ctx.player().posZ), Direction.UP, ctx.playerFeet(), false)) {})));
|
||||||
// </toxic cloud>
|
// </toxic cloud>
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
|
|||||||
ItemEntity ei = (ItemEntity) entity;
|
ItemEntity ei = (ItemEntity) entity;
|
||||||
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
|
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {
|
||||||
// +0.1 because of farmland's 0.9375 dummy height lol
|
// +0.1 because of farmland's 0.9375 dummy height lol
|
||||||
goalz.add(new GoalBlock(new BlockPos(entity.getPositionVec().x, entity.getPositionVec().y + 0.1, entity.getPositionVec().z)));
|
goalz.add(new GoalBlock(new BlockPos(entity.posX, entity.posY + 0.1, entity.posZ)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
|
|||||||
pos = new BlockPos(following);
|
pos = new BlockPos(following);
|
||||||
} else {
|
} else {
|
||||||
GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value);
|
GoalXZ g = GoalXZ.fromDirection(following.getPositionVector(), Baritone.settings().followOffsetDirection.value, Baritone.settings().followOffsetDistance.value);
|
||||||
pos = new BlockPos(g.getX(), following.getPositionVec().y, g.getZ());
|
pos = new BlockPos(g.getX(), following.posY, g.getZ());
|
||||||
}
|
}
|
||||||
return new GoalNear(pos, Baritone.settings().followRadius.value);
|
return new GoalNear(pos, Baritone.settings().followRadius.value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,10 +39,9 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import org.hydev.hyritone.Hyritone;
|
import org.hydev.hyritone.Hyritone;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static baritone.Baritone.settings;
|
|
||||||
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
import static baritone.api.pathing.movement.ActionCosts.COST_INF;
|
||||||
import static java.util.stream.Collectors.toList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mine blocks of a certain type
|
* Mine blocks of a certain type
|
||||||
@@ -85,7 +84,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (calcFailed) {
|
if (calcFailed) {
|
||||||
if (!knownOreLocations.isEmpty() && settings().blacklistClosestOnFailure.value) {
|
if (!knownOreLocations.isEmpty() && Baritone.settings().blacklistClosestOnFailure.value) {
|
||||||
logDirect("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...");
|
logDirect("Unable to find any path to " + filter + ", blacklisting presumably unreachable closest instance...");
|
||||||
knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)).ifPresent(blacklist::add);
|
knownOreLocations.stream().min(Comparator.comparingDouble(ctx.playerFeet()::distanceSq)).ifPresent(blacklist::add);
|
||||||
knownOreLocations.removeIf(blacklist::contains);
|
knownOreLocations.removeIf(blacklist::contains);
|
||||||
@@ -95,19 +94,19 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!settings().allowBreak.value) {
|
if (!Baritone.settings().allowBreak.value) {
|
||||||
logDirect("Unable to mine when allowBreak is false!");
|
logDirect("Unable to mine when allowBreak is false!");
|
||||||
cancel();
|
cancel();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
updateLoucaSystem();
|
updateLoucaSystem();
|
||||||
int mineGoalUpdateInterval = settings().mineGoalUpdateInterval.value;
|
int mineGoalUpdateInterval = Baritone.settings().mineGoalUpdateInterval.value;
|
||||||
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
List<BlockPos> curr = new ArrayList<>(knownOreLocations);
|
||||||
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
if (mineGoalUpdateInterval != 0 && tickCount++ % mineGoalUpdateInterval == 0) { // big brain
|
||||||
CalculationContext context = new CalculationContext(baritone, true);
|
CalculationContext context = new CalculationContext(baritone, true);
|
||||||
Baritone.getExecutor().execute(() -> rescan(curr, context));
|
Baritone.getExecutor().execute(() -> rescan(curr, context));
|
||||||
}
|
}
|
||||||
if (settings().legitMine.value) {
|
if (Baritone.settings().legitMine.value) {
|
||||||
addNearby();
|
addNearby();
|
||||||
}
|
}
|
||||||
Optional<BlockPos> shaft = curr.stream()
|
Optional<BlockPos> shaft = curr.stream()
|
||||||
@@ -146,7 +145,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
Map<BlockPos, Long> copy = new HashMap<>(anticipatedDrops);
|
Map<BlockPos, Long> copy = new HashMap<>(anticipatedDrops);
|
||||||
ctx.getSelectedBlock().ifPresent(pos -> {
|
ctx.getSelectedBlock().ifPresent(pos -> {
|
||||||
if (knownOreLocations.contains(pos)) {
|
if (knownOreLocations.contains(pos)) {
|
||||||
copy.put(pos, System.currentTimeMillis() + settings().mineDropLoiterDurationMSThanksLouca.value);
|
copy.put(pos, System.currentTimeMillis() + Baritone.settings().mineDropLoiterDurationMSThanksLouca.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// elaborate dance to avoid concurrentmodificationexcepption since rescan thread reads this
|
// elaborate dance to avoid concurrentmodificationexcepption since rescan thread reads this
|
||||||
@@ -170,7 +169,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PathingCommand updateGoal() {
|
private PathingCommand updateGoal() {
|
||||||
boolean legit = settings().legitMine.value;
|
boolean legit = Baritone.settings().legitMine.value;
|
||||||
List<BlockPos> locs = knownOreLocations;
|
List<BlockPos> locs = knownOreLocations;
|
||||||
if (!locs.isEmpty()) {
|
if (!locs.isEmpty()) {
|
||||||
CalculationContext context = new CalculationContext(baritone);
|
CalculationContext context = new CalculationContext(baritone);
|
||||||
@@ -185,7 +184,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// only in non-Xray mode (aka legit mode) do we do this
|
// only in non-Xray mode (aka legit mode) do we do this
|
||||||
int y = settings().legitMineYLevel.value;
|
int y = Baritone.settings().legitMineYLevel.value;
|
||||||
if (branchPoint == null) {
|
if (branchPoint == null) {
|
||||||
/*if (!baritone.getPathingBehavior().isPathing() && playerFeet().y == y) {
|
/*if (!baritone.getPathingBehavior().isPathing() && playerFeet().y == y) {
|
||||||
// cool, path is over and we are at desired y
|
// cool, path is over and we are at desired y
|
||||||
@@ -213,7 +212,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settings().legitMine.value) {
|
if (Baritone.settings().legitMine.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> dropped = droppedItemsScan();
|
List<BlockPos> dropped = droppedItemsScan();
|
||||||
@@ -233,7 +232,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
BlockState state = context.bsi.get0(pos);
|
BlockState state = context.bsi.get0(pos);
|
||||||
if (settings().internalMiningAirException.value && state.getBlock() instanceof AirBlock) {
|
if (Baritone.settings().internalMiningAirException.value && state.getBlock() instanceof AirBlock) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return filter.has(state) && plausibleToBreak(context, pos);
|
return filter.has(state) && plausibleToBreak(context, pos);
|
||||||
@@ -241,7 +240,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
|
|
||||||
private Goal coalesce(BlockPos loc, List<BlockPos> locs, CalculationContext context) {
|
private Goal coalesce(BlockPos loc, List<BlockPos> locs, CalculationContext context) {
|
||||||
boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.up()).getBlock() instanceof FallingBlock);
|
boolean assumeVerticalShaftMine = !(baritone.bsi.get0(loc.up()).getBlock() instanceof FallingBlock);
|
||||||
if (!settings().forceInternalMining.value) {
|
if (!Baritone.settings().forceInternalMining.value) {
|
||||||
if (assumeVerticalShaftMine) {
|
if (assumeVerticalShaftMine) {
|
||||||
// we can get directly below the block
|
// we can get directly below the block
|
||||||
return new GoalThreeBlocks(loc);
|
return new GoalThreeBlocks(loc);
|
||||||
@@ -302,7 +301,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<BlockPos> droppedItemsScan() {
|
public List<BlockPos> droppedItemsScan() {
|
||||||
if (!settings().mineScanDroppedItems.value) {
|
if (!Baritone.settings().mineScanDroppedItems.value) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
List<BlockPos> ret = new ArrayList<>();
|
List<BlockPos> ret = new ArrayList<>();
|
||||||
@@ -323,7 +322,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
List<Block> untracked = new ArrayList<>();
|
List<Block> untracked = new ArrayList<>();
|
||||||
|
|
||||||
// Check mine with seed
|
// Check mine with seed
|
||||||
if (!settings().mineWithSeed.value)
|
if (!Baritone.settings().mineWithSeed.value)
|
||||||
{
|
{
|
||||||
// Search the actual world
|
// Search the actual world
|
||||||
for (BlockOptionalMeta bom : filter.blocks()) {
|
for (BlockOptionalMeta bom : filter.blocks()) {
|
||||||
@@ -334,7 +333,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
// maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that
|
// maxRegionDistanceSq 2 means adjacent directly or adjacent diagonally; nothing further than that
|
||||||
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(
|
locs.addAll(ctx.worldData.getCachedWorld().getLocationsOf(
|
||||||
BlockUtils.blockToString(block),
|
BlockUtils.blockToString(block),
|
||||||
settings().maxCachedWorldScanCount.value,
|
Baritone.settings().maxCachedWorldScanCount.value,
|
||||||
pf.x,
|
pf.x,
|
||||||
pf.z,
|
pf.z,
|
||||||
2
|
2
|
||||||
@@ -346,7 +345,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
|
|
||||||
locs = prune(ctx, locs, filter, max, blacklist, dropped);
|
locs = prune(ctx, locs, filter, max, blacklist, dropped);
|
||||||
|
|
||||||
if (!untracked.isEmpty() || (settings().extendCacheOnThreshold.value && locs.size() < max)) {
|
if (!untracked.isEmpty() || (Baritone.settings().extendCacheOnThreshold.value && locs.size() < max)) {
|
||||||
locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(
|
locs.addAll(WorldScanner.INSTANCE.scanChunkRadius(
|
||||||
ctx.getBaritone().getPlayerContext(),
|
ctx.getBaritone().getPlayerContext(),
|
||||||
filter,
|
filter,
|
||||||
@@ -357,7 +356,8 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
}
|
}
|
||||||
|
|
||||||
locs.addAll(alreadyKnown);
|
locs.addAll(alreadyKnown);
|
||||||
locs = prune(ctx, locs, filter, max, blacklist, dropped);
|
|
||||||
|
return prune(ctx, locs, filter, max, blacklist, dropped);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -383,7 +383,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
// is an x-ray and it'll get caught
|
// is an x-ray and it'll get caught
|
||||||
if (filter.has(bsi.get0(x, y, z))) {
|
if (filter.has(bsi.get0(x, y, z))) {
|
||||||
BlockPos pos = new BlockPos(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
if ((settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) {
|
if ((Baritone.settings().legitMineIncludeDiagonals.value && knownOreLocations.stream().anyMatch(ore -> ore.distanceSq(pos) <= 2 /* sq means this is pytha dist <= sqrt(2) */)) || RotationUtils.reachable(ctx.player(), pos, fakedBlockReachDistance).isPresent()) {
|
||||||
knownOreLocations.add(pos);
|
knownOreLocations.add(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,10 +407,10 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
.distinct()
|
.distinct()
|
||||||
|
|
||||||
// remove any that are within loaded chunks that aren't actually what we want
|
// remove any that are within loaded chunks that aren't actually what we want
|
||||||
.filter(pos -> settings().mineWithSeed.value || !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || filter.has(ctx.get(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos))
|
.filter(pos -> Baritone.settings().mineWithSeed.value || !ctx.bsi.worldContainsLoadedChunk(pos.getX(), pos.getZ()) || filter.has(ctx.get(pos.getX(), pos.getY(), pos.getZ())) || dropped.contains(pos))
|
||||||
|
|
||||||
// Hyritone: remove air
|
// Hyritone: remove air
|
||||||
.filter(pos -> !settings().mineWithSeed.value || !ctx.get(pos).isAir() || dropped.contains(pos))
|
.filter(pos -> !Baritone.settings().mineWithSeed.value || !ctx.get(pos).isAir() || dropped.contains(pos))
|
||||||
|
|
||||||
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
// remove any that are implausible to mine (encased in bedrock, or touching lava)
|
||||||
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
|
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos))
|
||||||
@@ -418,7 +418,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
.filter(pos -> !blacklist.contains(pos))
|
.filter(pos -> !blacklist.contains(pos))
|
||||||
|
|
||||||
.sorted(Comparator.comparingDouble(new BlockPos(ctx.getBaritone().getPlayerContext().player())::distanceSq))
|
.sorted(Comparator.comparingDouble(new BlockPos(ctx.getBaritone().getPlayerContext().player())::distanceSq))
|
||||||
.collect(toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (locs.size() > max) {
|
if (locs.size() > max) {
|
||||||
return locs.subList(0, max);
|
return locs.subList(0, max);
|
||||||
@@ -445,7 +445,7 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
|
|||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
|
||||||
// Hyritone start - #1: Users are not idiots, if they disabled allow break, it's not for mining.
|
// Hyritone start - #1: Users are not idiots, if they disabled allow break, it's not for mining.
|
||||||
/*if (filter != null && !Baritone.settings().allowBreak.value) {
|
/*if (filter != null && !settings().allowBreak.value) {
|
||||||
logDirect("Unable to mine when allowBreak is false!");
|
logDirect("Unable to mine when allowBreak is false!");
|
||||||
this.mine(quantity, (BlockOptionalMetaLookup) null);
|
this.mine(quantity, (BlockOptionalMetaLookup) null);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import baritone.api.event.events.RenderEvent;
|
|||||||
import baritone.api.event.listener.AbstractGameEventListener;
|
import baritone.api.event.listener.AbstractGameEventListener;
|
||||||
import baritone.api.selection.ISelection;
|
import baritone.api.selection.ISelection;
|
||||||
import baritone.utils.IRenderer;
|
import baritone.utils.IRenderer;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
|
||||||
public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
||||||
@@ -19,7 +18,7 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
|||||||
baritone.getGameEventHandler().registerEventListener(this);
|
baritone.getGameEventHandler().registerEventListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderSelections(MatrixStack stack, ISelection[] selections) {
|
public static void renderSelections(ISelection[] selections) {
|
||||||
float opacity = settings.selectionOpacity.value;
|
float opacity = settings.selectionOpacity.value;
|
||||||
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
boolean ignoreDepth = settings.renderSelectionIgnoreDepth.value;
|
||||||
float lineWidth = settings.selectionLineWidth.value;
|
float lineWidth = settings.selectionLineWidth.value;
|
||||||
@@ -31,20 +30,20 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
|||||||
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
IRenderer.startLines(settings.colorSelection.value, opacity, lineWidth, ignoreDepth);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
for (ISelection selection : selections) {
|
||||||
IRenderer.drawAABB(stack, selection.aabb(), SELECTION_BOX_EXPANSION);
|
IRenderer.drawAABB(selection.aabb(), SELECTION_BOX_EXPANSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.renderSelectionCorners.value) {
|
if (settings.renderSelectionCorners.value) {
|
||||||
IRenderer.glColor(settings.colorSelectionPos1.value, opacity);
|
IRenderer.glColor(settings.colorSelectionPos1.value, opacity);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
for (ISelection selection : selections) {
|
||||||
IRenderer.drawAABB(stack, new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)));
|
IRenderer.drawAABB(new AxisAlignedBB(selection.pos1(), selection.pos1().add(1, 1, 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
IRenderer.glColor(settings.colorSelectionPos2.value, opacity);
|
IRenderer.glColor(settings.colorSelectionPos2.value, opacity);
|
||||||
|
|
||||||
for (ISelection selection : selections) {
|
for (ISelection selection : selections) {
|
||||||
IRenderer.drawAABB(stack, new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1)));
|
IRenderer.drawAABB(new AxisAlignedBB(selection.pos2(), selection.pos2().add(1, 1, 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +52,6 @@ public class SelectionRenderer implements IRenderer, AbstractGameEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRenderPass(RenderEvent event) {
|
public void onRenderPass(RenderEvent event) {
|
||||||
renderSelections(event.getModelViewStack(), manager.getSelections());
|
renderSelections(manager.getSelections());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class BlockStateInterface {
|
|||||||
private final ClientChunkProvider provider;
|
private final ClientChunkProvider provider;
|
||||||
private final WorldData worldData;
|
private final WorldData worldData;
|
||||||
protected final IBlockReader world;
|
protected final IBlockReader world;
|
||||||
public final BlockPos.Mutable isPassableBlockPos;
|
public final BlockPos.MutableBlockPos isPassableBlockPos;
|
||||||
public final IBlockReader access;
|
public final IBlockReader access;
|
||||||
|
|
||||||
private Chunk prev = null;
|
private Chunk prev = null;
|
||||||
@@ -77,7 +77,7 @@ public class BlockStateInterface {
|
|||||||
if (!Minecraft.getInstance().isOnExecutionThread()) {
|
if (!Minecraft.getInstance().isOnExecutionThread()) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
this.isPassableBlockPos = new BlockPos.Mutable();
|
this.isPassableBlockPos = new BlockPos.MutableBlockPos();
|
||||||
this.access = new BlockStateInterfaceAccessWrapper(this);
|
this.access = new BlockStateInterfaceAccessWrapper(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +101,11 @@ public class BlockStateInterface {
|
|||||||
|
|
||||||
public BlockState get0(int x, int y, int z) { // Mickey resigned
|
public BlockState get0(int x, int y, int z) { // Mickey resigned
|
||||||
|
|
||||||
|
// Invalid vertical position
|
||||||
|
if (y < 0 || y >= 256) {
|
||||||
|
return AIR;
|
||||||
|
}
|
||||||
|
|
||||||
// Hyritone: Replace the block with seed block
|
// Hyritone: Replace the block with seed block
|
||||||
if (Baritone.settings().mineWithSeed.value)
|
if (Baritone.settings().mineWithSeed.value)
|
||||||
{
|
{
|
||||||
@@ -111,11 +116,6 @@ public class BlockStateInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invalid vertical position
|
|
||||||
if (y < 0 || y >= 256) {
|
|
||||||
return AIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useTheRealWorld) {
|
if (useTheRealWorld) {
|
||||||
Chunk cached = prev;
|
Chunk cached = prev;
|
||||||
// there's great cache locality in block state lookups
|
// there's great cache locality in block state lookups
|
||||||
|
|||||||
@@ -23,20 +23,21 @@ import baritone.api.pathing.goals.GoalBlock;
|
|||||||
import baritone.api.pathing.goals.GoalTwoBlocks;
|
import baritone.api.pathing.goals.GoalTwoBlocks;
|
||||||
import baritone.api.utils.BetterBlockPos;
|
import baritone.api.utils.BetterBlockPos;
|
||||||
import baritone.api.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
|
||||||
import net.minecraft.client.renderer.Vector4f;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
import net.minecraft.util.text.event.ClickEvent;
|
import net.minecraft.util.text.event.ClickEvent;
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.nio.FloatBuffer;
|
||||||
|
import java.nio.IntBuffer;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
import static baritone.api.command.IBaritoneChatControl.FORCE_COMMAND_PREFIX;
|
||||||
@@ -44,7 +45,11 @@ import static org.lwjgl.opengl.GL11.*;
|
|||||||
|
|
||||||
public class GuiClick extends Screen implements Helper {
|
public class GuiClick extends Screen implements Helper {
|
||||||
|
|
||||||
private Matrix4f projectionViewMatrix;
|
// My name is Brady and I grant leijurv permission to use this pasted code
|
||||||
|
private final FloatBuffer MODELVIEW = BufferUtils.createFloatBuffer(16);
|
||||||
|
private final FloatBuffer PROJECTION = BufferUtils.createFloatBuffer(16);
|
||||||
|
private final IntBuffer VIEWPORT = BufferUtils.createIntBuffer(16);
|
||||||
|
private final FloatBuffer TO_WORLD_BUFFER = BufferUtils.createFloatBuffer(3);
|
||||||
|
|
||||||
private BlockPos clickStart;
|
private BlockPos clickStart;
|
||||||
private BlockPos currentMouseOver;
|
private BlockPos currentMouseOver;
|
||||||
@@ -62,10 +67,9 @@ public class GuiClick extends Screen implements Helper {
|
|||||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||||
double mx = mc.mouseHelper.getMouseX();
|
double mx = mc.mouseHelper.getMouseX();
|
||||||
double my = mc.mouseHelper.getMouseY();
|
double my = mc.mouseHelper.getMouseY();
|
||||||
|
my = mc.mainWindow.getHeight() - my;
|
||||||
my = mc.getMainWindow().getHeight() - my;
|
my *= mc.mainWindow.getFramebufferHeight() / (double) mc.mainWindow.getHeight();
|
||||||
my *= mc.getMainWindow().getFramebufferHeight() / (double) mc.getMainWindow().getHeight();
|
mx *= mc.mainWindow.getFramebufferWidth() / (double) mc.mainWindow.getWidth();
|
||||||
mx *= mc.getMainWindow().getFramebufferWidth() / (double) mc.getMainWindow().getWidth();
|
|
||||||
Vec3d near = toWorld(mx, my, 0);
|
Vec3d near = toWorld(mx, my, 0);
|
||||||
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
Vec3d far = toWorld(mx, my, 1); // "Use 0.945 that's what stack overflow says" - leijurv
|
||||||
if (near != null && far != null) {
|
if (near != null && far != null) {
|
||||||
@@ -110,52 +114,224 @@ public class GuiClick extends Screen implements Helper {
|
|||||||
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
return super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRender(MatrixStack modelViewStack, Matrix4f projectionMatrix) {
|
public void onRender() {
|
||||||
this.projectionViewMatrix = projectionMatrix.copy();
|
GlStateManager.getMatrix(GL_MODELVIEW_MATRIX, (FloatBuffer) MODELVIEW.clear());
|
||||||
this.projectionViewMatrix.mul(modelViewStack.getLast().getMatrix());
|
GlStateManager.getMatrix(GL_PROJECTION_MATRIX, (FloatBuffer) PROJECTION.clear());
|
||||||
this.projectionViewMatrix.invert();
|
GL11.glGetIntegerv(GL_VIEWPORT, (IntBuffer) VIEWPORT.clear());
|
||||||
|
|
||||||
if (currentMouseOver != null) {
|
if (currentMouseOver != null) {
|
||||||
Entity e = mc.getRenderViewEntity();
|
Entity e = mc.getRenderViewEntity();
|
||||||
// drawSingleSelectionBox WHEN?
|
// drawSingleSelectionBox WHEN?
|
||||||
PathRenderer.drawManySelectionBoxes(modelViewStack, e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
PathRenderer.drawManySelectionBoxes(e, Collections.singletonList(currentMouseOver), Color.CYAN);
|
||||||
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
if (clickStart != null && !clickStart.equals(currentMouseOver)) {
|
||||||
RenderSystem.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
RenderSystem.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
|
GlStateManager.color4f(Color.RED.getColorComponents(null)[0], Color.RED.getColorComponents(null)[1], Color.RED.getColorComponents(null)[2], 0.4F);
|
||||||
RenderSystem.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
GlStateManager.lineWidth(Baritone.settings().pathRenderLineWidthPixels.value);
|
||||||
RenderSystem.disableTexture();
|
GlStateManager.disableTexture();
|
||||||
RenderSystem.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
RenderSystem.disableDepthTest();
|
GlStateManager.disableDepthTest();
|
||||||
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
BetterBlockPos a = new BetterBlockPos(currentMouseOver);
|
||||||
BetterBlockPos b = new BetterBlockPos(clickStart);
|
BetterBlockPos b = new BetterBlockPos(clickStart);
|
||||||
IRenderer.drawAABB(modelViewStack, new AxisAlignedBB(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.drawAABB(new AxisAlignedBB(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));
|
||||||
RenderSystem.enableDepthTest();
|
GlStateManager.enableDepthTest();
|
||||||
|
|
||||||
RenderSystem.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
RenderSystem.enableTexture();
|
GlStateManager.enableTexture();
|
||||||
RenderSystem.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vec3d toWorld(double x, double y, double z) {
|
private Vec3d toWorld(double x, double y, double z) {
|
||||||
if (this.projectionViewMatrix == null) {
|
boolean result = gluUnProject((float) x, (float) y, (float) z, MODELVIEW, PROJECTION, VIEWPORT, (FloatBuffer) TO_WORLD_BUFFER.clear());
|
||||||
return null;
|
if (result) {
|
||||||
|
return new Vec3d(TO_WORLD_BUFFER.get(0), TO_WORLD_BUFFER.get(1), TO_WORLD_BUFFER.get(2));
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
x /= mc.getMainWindow().getFramebufferWidth();
|
// skidded from lwjgl2 :ok_hand:
|
||||||
y /= mc.getMainWindow().getFramebufferHeight();
|
// its uhhhhh mit license so its ok
|
||||||
x = x * 2 - 1;
|
// here is the uhh license
|
||||||
y = y * 2 - 1;
|
/*
|
||||||
|
* Copyright (c) 2002-2007 Lightweight Java Game Library Project
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are
|
||||||
|
* met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* * Neither the name of 'Light Weight Java Game Library' nor the names of
|
||||||
|
* its contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static boolean gluUnProject(
|
||||||
|
float winx,
|
||||||
|
float winy,
|
||||||
|
float winz,
|
||||||
|
FloatBuffer modelMatrix,
|
||||||
|
FloatBuffer projMatrix,
|
||||||
|
IntBuffer viewport,
|
||||||
|
FloatBuffer obj_pos) {
|
||||||
|
FloatBuffer finalMatrix = BufferUtils.createFloatBuffer(16);
|
||||||
|
float[] in = new float[4];
|
||||||
|
float[] out = new float[4];
|
||||||
|
|
||||||
|
__gluMultMatricesf(modelMatrix, projMatrix, finalMatrix);
|
||||||
|
|
||||||
|
if (!__gluInvertMatrixf(finalMatrix, finalMatrix))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
in[0] = winx;
|
||||||
|
in[1] = winy;
|
||||||
|
in[2] = winz;
|
||||||
|
in[3] = 1.0f;
|
||||||
|
|
||||||
|
// Map x and y from window coordinates
|
||||||
|
in[0] = (in[0] - viewport.get(viewport.position() + 0)) / viewport.get(viewport.position() + 2);
|
||||||
|
in[1] = (in[1] - viewport.get(viewport.position() + 1)) / viewport.get(viewport.position() + 3);
|
||||||
|
|
||||||
|
// Map to range -1 to 1
|
||||||
|
in[0] = in[0] * 2 - 1;
|
||||||
|
in[1] = in[1] * 2 - 1;
|
||||||
|
in[2] = in[2] * 2 - 1;
|
||||||
|
|
||||||
|
__gluMultMatrixVecf(finalMatrix, in, out);
|
||||||
|
|
||||||
|
if (out[3] == 0.0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
out[3] = 1.0f / out[3];
|
||||||
|
|
||||||
|
obj_pos.put(obj_pos.position() + 0, out[0] * out[3]);
|
||||||
|
obj_pos.put(obj_pos.position() + 1, out[1] * out[3]);
|
||||||
|
obj_pos.put(obj_pos.position() + 2, out[2] * out[3]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void __gluMultMatrixVecf(FloatBuffer m, float[] in, float[] out) {
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
out[i] =
|
||||||
|
in[0] * m.get(m.position() + 0 * 4 + i)
|
||||||
|
+ in[1] * m.get(m.position() + 1 * 4 + i)
|
||||||
|
+ in[2] * m.get(m.position() + 2 * 4 + i)
|
||||||
|
+ in[3] * m.get(m.position() + 3 * 4 + i);
|
||||||
|
|
||||||
Vector4f pos = new Vector4f((float) x, (float) y, (float) z, 1.0F);
|
|
||||||
pos.transform(this.projectionViewMatrix);
|
|
||||||
if (pos.getW() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pos.perspectiveDivide();
|
private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) {
|
||||||
return new Vec3d(pos.getX(), pos.getY(), pos.getZ());
|
for (int i = 0; i < 4; i++) {
|
||||||
|
for (int j = 0; j < 4; j++) {
|
||||||
|
r.put(r.position() + i * 4 + j,
|
||||||
|
a.get(a.position() + i * 4 + 0) * b.get(b.position() + 0 * 4 + j) + a.get(a.position() + i * 4 + 1) * b.get(b.position() + 1 * 4 + j) + a.get(a.position() + i * 4 + 2) * b.get(b.position() + 2 * 4 + j) + a.get(a.position() + i * 4 + 3) * b.get(b.position() + 3 * 4 + j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
|
||||||
|
int i, j, k, swap;
|
||||||
|
float t;
|
||||||
|
FloatBuffer temp = BufferUtils.createFloatBuffer(16);
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
temp.put(i, src.get(i + src.position()));
|
||||||
|
}
|
||||||
|
__gluMakeIdentityf(inverse);
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
/*
|
||||||
|
* * Look for largest element in column
|
||||||
|
*/
|
||||||
|
swap = i;
|
||||||
|
for (j = i + 1; j < 4; j++) {
|
||||||
|
/*
|
||||||
|
* if (fabs(temp[j][i]) > fabs(temp[i][i])) { swap = j;
|
||||||
|
*/
|
||||||
|
if (Math.abs(temp.get(j * 4 + i)) > Math.abs(temp.get(i * 4 + i))) {
|
||||||
|
swap = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (swap != i) {
|
||||||
|
/*
|
||||||
|
* * Swap rows.
|
||||||
|
*/
|
||||||
|
for (k = 0; k < 4; k++) {
|
||||||
|
t = temp.get(i * 4 + k);
|
||||||
|
temp.put(i * 4 + k, temp.get(swap * 4 + k));
|
||||||
|
temp.put(swap * 4 + k, t);
|
||||||
|
|
||||||
|
t = inverse.get(i * 4 + k);
|
||||||
|
inverse.put(i * 4 + k, inverse.get(swap * 4 + k));
|
||||||
|
//inverse.put((i << 2) + k, inverse.get((swap << 2) + k));
|
||||||
|
inverse.put(swap * 4 + k, t);
|
||||||
|
//inverse.put((swap << 2) + k, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp.get(i * 4 + i) == 0) {
|
||||||
|
/*
|
||||||
|
* * No non-zero pivot. The matrix is singular, which shouldn't *
|
||||||
|
* happen. This means the user gave us a bad matrix.
|
||||||
|
*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
t = temp.get(i * 4 + i);
|
||||||
|
for (k = 0; k < 4; k++) {
|
||||||
|
temp.put(i * 4 + k, temp.get(i * 4 + k) / t);
|
||||||
|
inverse.put(i * 4 + k, inverse.get(i * 4 + k) / t);
|
||||||
|
}
|
||||||
|
for (j = 0; j < 4; j++) {
|
||||||
|
if (j != i) {
|
||||||
|
t = temp.get(j * 4 + i);
|
||||||
|
for (k = 0; k < 4; k++) {
|
||||||
|
temp.put(j * 4 + k, temp.get(j * 4 + k) - temp.get(i * 4 + k) * t);
|
||||||
|
inverse.put(j * 4 + k, inverse.get(j * 4 + k) - inverse.get(i * 4 + k) * t);
|
||||||
|
/*inverse.put(
|
||||||
|
(j << 2) + k,
|
||||||
|
inverse.get((j << 2) + k) - inverse.get((i << 2) + k) * t);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final float[] IDENTITY_MATRIX =
|
||||||
|
new float[]{
|
||||||
|
1.0f, 0.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 1.0f, 0.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 1.0f, 0.0f,
|
||||||
|
0.0f, 0.0f, 0.0f, 1.0f};
|
||||||
|
|
||||||
|
private static void __gluMakeIdentityf(FloatBuffer m) {
|
||||||
|
int oldPos = m.position();
|
||||||
|
m.put(IDENTITY_MATRIX);
|
||||||
|
m.position(oldPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,8 @@ import baritone.api.BaritoneAPI;
|
|||||||
import baritone.api.Settings;
|
import baritone.api.Settings;
|
||||||
import baritone.api.utils.Helper;
|
import baritone.api.utils.Helper;
|
||||||
import baritone.utils.accessor.IEntityRenderManager;
|
import baritone.utils.accessor.IEntityRenderManager;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
import net.minecraft.client.renderer.BufferBuilder;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
@@ -42,20 +40,20 @@ public interface IRenderer {
|
|||||||
|
|
||||||
static void glColor(Color color, float alpha) {
|
static void glColor(Color color, float alpha) {
|
||||||
float[] colorComponents = color.getColorComponents(null);
|
float[] colorComponents = color.getColorComponents(null);
|
||||||
RenderSystem.color4f(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
|
GlStateManager.color4f(colorComponents[0], colorComponents[1], colorComponents[2], alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
|
static void startLines(Color color, float alpha, float lineWidth, boolean ignoreDepth) {
|
||||||
RenderSystem.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
RenderSystem.disableLighting();
|
GlStateManager.disableLighting();
|
||||||
RenderSystem.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
GlStateManager.blendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||||
glColor(color, alpha);
|
glColor(color, alpha);
|
||||||
RenderSystem.lineWidth(lineWidth);
|
GlStateManager.lineWidth(lineWidth);
|
||||||
RenderSystem.disableTexture();
|
GlStateManager.disableTexture();
|
||||||
RenderSystem.depthMask(false);
|
GlStateManager.depthMask(false);
|
||||||
|
|
||||||
if (ignoreDepth) {
|
if (ignoreDepth) {
|
||||||
RenderSystem.disableDepthTest();
|
GlStateManager.disableDepthTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,51 +63,50 @@ public interface IRenderer {
|
|||||||
|
|
||||||
static void endLines(boolean ignoredDepth) {
|
static void endLines(boolean ignoredDepth) {
|
||||||
if (ignoredDepth) {
|
if (ignoredDepth) {
|
||||||
RenderSystem.enableDepthTest();
|
GlStateManager.enableDepthTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem.depthMask(true);
|
GlStateManager.depthMask(true);
|
||||||
RenderSystem.enableTexture();
|
GlStateManager.enableTexture();
|
||||||
RenderSystem.enableLighting();
|
GlStateManager.enableLighting();
|
||||||
RenderSystem.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawAABB(MatrixStack stack, AxisAlignedBB aabb) {
|
static void drawAABB(AxisAlignedBB aabb) {
|
||||||
AxisAlignedBB toDraw = aabb.offset(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ());
|
AxisAlignedBB toDraw = aabb.offset(-renderManager.renderPosX(), -renderManager.renderPosY(), -renderManager.renderPosZ());
|
||||||
|
|
||||||
Matrix4f matrix4f = stack.getLast().getMatrix();
|
|
||||||
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
||||||
// bottom
|
// bottom
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||||
// top
|
// top
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||||
// corners
|
// corners
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.minY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.minY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.minZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.maxY, toDraw.minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.minY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.maxX, (float) toDraw.maxY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.maxX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.minY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.minY, toDraw.maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) toDraw.minX, (float) toDraw.maxY, (float) toDraw.maxZ).endVertex();
|
buffer.pos(toDraw.minX, toDraw.maxY, toDraw.maxZ).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawAABB(MatrixStack stack, AxisAlignedBB aabb, double expand) {
|
static void drawAABB(AxisAlignedBB aabb, double expand) {
|
||||||
drawAABB(stack, aabb.grow(expand, expand, expand));
|
drawAABB(aabb.grow(expand, expand, expand));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,8 @@ import baritone.api.utils.Helper;
|
|||||||
import baritone.api.utils.interfaces.IGoalRenderPos;
|
import baritone.api.utils.interfaces.IGoalRenderPos;
|
||||||
import baritone.behavior.PathingBehavior;
|
import baritone.behavior.PathingBehavior;
|
||||||
import baritone.pathing.path.PathExecutor;
|
import baritone.pathing.path.PathExecutor;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.renderer.Matrix4f;
|
|
||||||
import net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer;
|
import net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -73,7 +71,7 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
float partialTicks = event.getPartialTicks();
|
float partialTicks = event.getPartialTicks();
|
||||||
Goal goal = behavior.getGoal();
|
Goal goal = behavior.getGoal();
|
||||||
if (Helper.mc.currentScreen instanceof GuiClick) {
|
if (Helper.mc.currentScreen instanceof GuiClick) {
|
||||||
((GuiClick) Helper.mc.currentScreen).onRender(event.getModelViewStack(), event.getProjectionMatrix());
|
((GuiClick) Helper.mc.currentScreen).onRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId();
|
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId();
|
||||||
@@ -94,7 +92,7 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (goal != null && settings.renderGoal.value) {
|
if (goal != null && settings.renderGoal.value) {
|
||||||
drawDankLitGoalBox(event.getModelViewStack(), renderView, goal, partialTicks, settings.colorGoalBox.value);
|
drawDankLitGoalBox(renderView, goal, partialTicks, settings.colorGoalBox.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!settings.renderPath.value) {
|
if (!settings.renderPath.value) {
|
||||||
@@ -104,9 +102,9 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
PathExecutor current = behavior.getCurrent(); // this should prevent most race conditions?
|
PathExecutor current = behavior.getCurrent(); // this should prevent most race conditions?
|
||||||
PathExecutor next = behavior.getNext(); // like, now it's not possible for current!=null to be true, then suddenly false because of another thread
|
PathExecutor next = behavior.getNext(); // like, now it's not possible for current!=null to be true, then suddenly false because of another thread
|
||||||
if (current != null && settings.renderSelectionBoxes.value) {
|
if (current != null && settings.renderSelectionBoxes.value) {
|
||||||
drawManySelectionBoxes(event.getModelViewStack(), renderView, current.toBreak(), settings.colorBlocksToBreak.value);
|
drawManySelectionBoxes(renderView, current.toBreak(), settings.colorBlocksToBreak.value);
|
||||||
drawManySelectionBoxes(event.getModelViewStack(), renderView, current.toPlace(), settings.colorBlocksToPlace.value);
|
drawManySelectionBoxes(renderView, current.toPlace(), settings.colorBlocksToPlace.value);
|
||||||
drawManySelectionBoxes(event.getModelViewStack(), renderView, current.toWalkInto(), settings.colorBlocksToWalkInto.value);
|
drawManySelectionBoxes(renderView, current.toWalkInto(), settings.colorBlocksToWalkInto.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
|
//drawManySelectionBoxes(player, Collections.singletonList(behavior.pathStart()), partialTicks, Color.WHITE);
|
||||||
@@ -114,27 +112,27 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
// Render the current path, if there is one
|
// Render the current path, if there is one
|
||||||
if (current != null && current.getPath() != null) {
|
if (current != null && current.getPath() != null) {
|
||||||
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
int renderBegin = Math.max(current.getPosition() - 3, 0);
|
||||||
drawPath(event.getModelViewStack(), current.getPath(), renderBegin, settings.colorCurrentPath.value, settings.fadePath.value, 10, 20);
|
drawPath(current.getPath(), renderBegin, settings.colorCurrentPath.value, settings.fadePath.value, 10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next != null && next.getPath() != null) {
|
if (next != null && next.getPath() != null) {
|
||||||
drawPath(event.getModelViewStack(), next.getPath(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
|
drawPath(next.getPath(), 0, settings.colorNextPath.value, settings.fadePath.value, 10, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a path calculation currently running, render the path calculation process
|
// If there is a path calculation currently running, render the path calculation process
|
||||||
behavior.getInProgress().ifPresent(currentlyRunning -> {
|
behavior.getInProgress().ifPresent(currentlyRunning -> {
|
||||||
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
currentlyRunning.bestPathSoFar().ifPresent(p -> {
|
||||||
drawPath(event.getModelViewStack(), p, 0, settings.colorBestPathSoFar.value, settings.fadePath.value, 10, 20);
|
drawPath(p, 0, settings.colorBestPathSoFar.value, settings.fadePath.value, 10, 20);
|
||||||
});
|
});
|
||||||
|
|
||||||
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
currentlyRunning.pathToMostRecentNodeConsidered().ifPresent(mr -> {
|
||||||
drawPath(event.getModelViewStack(), mr, 0, settings.colorMostRecentConsidered.value, settings.fadePath.value, 10, 20);
|
drawPath(mr, 0, settings.colorMostRecentConsidered.value, settings.fadePath.value, 10, 20);
|
||||||
drawManySelectionBoxes(event.getModelViewStack(), renderView, Collections.singletonList(mr.getDest()), settings.colorMostRecentConsidered.value);
|
drawManySelectionBoxes(renderView, Collections.singletonList(mr.getDest()), settings.colorMostRecentConsidered.value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawPath(MatrixStack stack, IPath path, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
public static void drawPath(IPath path, int startIndex, Color color, boolean fadeOut, int fadeStart0, int fadeEnd0) {
|
||||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderPathIgnoreDepth.value);
|
||||||
|
|
||||||
int fadeStart = fadeStart0 + startIndex;
|
int fadeStart = fadeStart0 + startIndex;
|
||||||
@@ -170,7 +168,7 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
IRenderer.glColor(color, alpha);
|
IRenderer.glColor(color, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawLine(stack, start.x, start.y, start.z, end.x, end.y, end.z);
|
drawLine(start.x, start.y, start.z, end.x, end.y, end.z);
|
||||||
|
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
@@ -179,26 +177,24 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void drawLine(MatrixStack stack, double x1, double y1, double z1, double x2, double y2, double z2) {
|
public static void drawLine(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||||
Matrix4f matrix4f = stack.getLast().getMatrix();
|
|
||||||
|
|
||||||
double vpX = posX();
|
double vpX = posX();
|
||||||
double vpY = posY();
|
double vpY = posY();
|
||||||
double vpZ = posZ();
|
double vpZ = posZ();
|
||||||
boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value;
|
boolean renderPathAsFrickinThingy = !settings.renderPathAsLine.value;
|
||||||
|
|
||||||
buffer.begin(renderPathAsFrickinThingy ? GL_LINE_STRIP : GL_LINES, DefaultVertexFormats.POSITION);
|
buffer.begin(renderPathAsFrickinThingy ? GL_LINE_STRIP : GL_LINES, DefaultVertexFormats.POSITION);
|
||||||
buffer.pos(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.5D - vpY), (float) (z1 + 0.5D - vpZ)).endVertex();
|
buffer.pos(x1 + 0.5D - vpX, y1 + 0.5D - vpY, z1 + 0.5D - vpZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.5D - vpY), (float) (z2 + 0.5D - vpZ)).endVertex();
|
buffer.pos(x2 + 0.5D - vpX, y2 + 0.5D - vpY, z2 + 0.5D - vpZ).endVertex();
|
||||||
|
|
||||||
if (renderPathAsFrickinThingy) {
|
if (renderPathAsFrickinThingy) {
|
||||||
buffer.pos(matrix4f, (float) (x2 + 0.5D - vpX), (float) (y2 + 0.53D - vpY), (float) (z2 + 0.5D - vpZ)).endVertex();
|
buffer.pos(x2 + 0.5D - vpX, y2 + 0.53D - vpY, z2 + 0.5D - vpZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.53D - vpY), (float) (z1 + 0.5D - vpZ)).endVertex();
|
buffer.pos(x1 + 0.5D - vpX, y1 + 0.53D - vpY, z1 + 0.5D - vpZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) (x1 + 0.5D - vpX), (float) (y1 + 0.5D - vpY), (float) (z1 + 0.5D - vpZ)).endVertex();
|
buffer.pos(x1 + 0.5D - vpX, y1 + 0.5D - vpY, z1 + 0.5D - vpZ).endVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawManySelectionBoxes(MatrixStack stack, Entity player, Collection<BlockPos> positions, Color color) {
|
public static void drawManySelectionBoxes(Entity player, Collection<BlockPos> positions, Color color) {
|
||||||
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
IRenderer.startLines(color, settings.pathRenderLineWidthPixels.value, settings.renderSelectionBoxesIgnoreDepth.value);
|
||||||
|
|
||||||
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
//BlockPos blockpos = movingObjectPositionIn.getBlockPos();
|
||||||
@@ -209,13 +205,13 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
VoxelShape shape = state.getShape(player.world, pos);
|
VoxelShape shape = state.getShape(player.world, pos);
|
||||||
AxisAlignedBB toDraw = shape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : shape.getBoundingBox();
|
AxisAlignedBB toDraw = shape.isEmpty() ? VoxelShapes.fullCube().getBoundingBox() : shape.getBoundingBox();
|
||||||
toDraw = toDraw.offset(pos);
|
toDraw = toDraw.offset(pos);
|
||||||
IRenderer.drawAABB(stack, toDraw, .002D);
|
IRenderer.drawAABB(toDraw, .002D);
|
||||||
});
|
});
|
||||||
|
|
||||||
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);
|
IRenderer.endLines(settings.renderSelectionBoxesIgnoreDepth.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawDankLitGoalBox(MatrixStack stack, Entity player, Goal goal, float partialTicks, Color color) {
|
public static void drawDankLitGoalBox(Entity player, Goal goal, float partialTicks, Color color) {
|
||||||
double renderPosX = posX();
|
double renderPosX = posX();
|
||||||
double renderPosY = posY();
|
double renderPosY = posY();
|
||||||
double renderPosZ = posZ();
|
double renderPosZ = posZ();
|
||||||
@@ -250,32 +246,27 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
|
|
||||||
Helper.mc.getTextureManager().bindTexture(TEXTURE_BEACON_BEAM);
|
Helper.mc.getTextureManager().bindTexture(TEXTURE_BEACON_BEAM);
|
||||||
if (settings.renderGoalIgnoreDepth.value) {
|
if (settings.renderGoalIgnoreDepth.value) {
|
||||||
RenderSystem.disableDepthTest();
|
GlStateManager.disableDepthTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.push(); // push
|
|
||||||
stack.translate(goalPos.getX() - renderPosX, -renderPosY, goalPos.getZ() - renderPosZ); // translate
|
|
||||||
|
|
||||||
BeaconTileEntityRenderer.renderBeamSegment(
|
BeaconTileEntityRenderer.renderBeamSegment(
|
||||||
stack,
|
goalPos.getX() - renderPosX,
|
||||||
mc.getRenderTypeBuffers().getBufferSource(),
|
-renderPosY,
|
||||||
TEXTURE_BEACON_BEAM,
|
goalPos.getZ() - renderPosZ,
|
||||||
partialTicks,
|
partialTicks,
|
||||||
1.0F,
|
1.0,
|
||||||
player.world.getGameTime(),
|
player.world.getGameTime(),
|
||||||
0,
|
0,
|
||||||
256,
|
256,
|
||||||
color.getColorComponents(null),
|
color.getColorComponents(null),
|
||||||
|
|
||||||
// Arguments filled by the private method lol
|
// Arguments filled by the private method lol
|
||||||
0.2F,
|
0.2D,
|
||||||
0.25F
|
0.25D
|
||||||
);
|
);
|
||||||
|
|
||||||
stack.pop(); // pop
|
|
||||||
|
|
||||||
if (settings.renderGoalIgnoreDepth.value) {
|
if (settings.renderGoalIgnoreDepth.value) {
|
||||||
RenderSystem.enableDepthTest();
|
GlStateManager.enableDepthTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
@@ -293,18 +284,18 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
maxY = 256 - renderPosY;
|
maxY = 256 - renderPosY;
|
||||||
} else if (goal instanceof GoalComposite) {
|
} else if (goal instanceof GoalComposite) {
|
||||||
for (Goal g : ((GoalComposite) goal).goals()) {
|
for (Goal g : ((GoalComposite) goal).goals()) {
|
||||||
drawDankLitGoalBox(stack, player, g, partialTicks, color);
|
drawDankLitGoalBox(player, g, partialTicks, color);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (goal instanceof GoalInverted) {
|
} else if (goal instanceof GoalInverted) {
|
||||||
drawDankLitGoalBox(stack, player, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
|
drawDankLitGoalBox(player, ((GoalInverted) goal).origin, partialTicks, settings.colorInvertedGoalBox.value);
|
||||||
return;
|
return;
|
||||||
} else if (goal instanceof GoalYLevel) {
|
} else if (goal instanceof GoalYLevel) {
|
||||||
GoalYLevel goalpos = (GoalYLevel) goal;
|
GoalYLevel goalpos = (GoalYLevel) goal;
|
||||||
minX = player.getPositionVec().x - settings.yLevelBoxSize.value - renderPosX;
|
minX = player.posX - settings.yLevelBoxSize.value - renderPosX;
|
||||||
minZ = player.getPositionVec().z - settings.yLevelBoxSize.value - renderPosZ;
|
minZ = player.posZ - settings.yLevelBoxSize.value - renderPosZ;
|
||||||
maxX = player.getPositionVec().x + settings.yLevelBoxSize.value - renderPosX;
|
maxX = player.posX + settings.yLevelBoxSize.value - renderPosX;
|
||||||
maxZ = player.getPositionVec().z + settings.yLevelBoxSize.value - renderPosZ;
|
maxZ = player.posZ + settings.yLevelBoxSize.value - renderPosZ;
|
||||||
minY = ((GoalYLevel) goal).level - renderPosY;
|
minY = ((GoalYLevel) goal).level - renderPosY;
|
||||||
maxY = minY + 2;
|
maxY = minY + 2;
|
||||||
y1 = 1 + y + goalpos.level - renderPosY;
|
y1 = 1 + y + goalpos.level - renderPosY;
|
||||||
@@ -315,32 +306,31 @@ public final class PathRenderer implements IRenderer, Helper {
|
|||||||
|
|
||||||
IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
IRenderer.startLines(color, settings.goalRenderLineWidthPixels.value, settings.renderGoalIgnoreDepth.value);
|
||||||
|
|
||||||
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y1);
|
renderHorizontalQuad(minX, maxX, minZ, maxZ, y1);
|
||||||
renderHorizontalQuad(stack, minX, maxX, minZ, maxZ, y2);
|
renderHorizontalQuad(minX, maxX, minZ, maxZ, y2);
|
||||||
|
|
||||||
|
|
||||||
Matrix4f matrix4f = stack.getLast().getMatrix();
|
|
||||||
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
buffer.begin(GL_LINES, DefaultVertexFormats.POSITION);
|
||||||
buffer.pos(matrix4f, (float) minX, (float) minY, (float) minZ).endVertex();
|
buffer.pos(minX, minY, minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) minX, (float) maxY, (float) minZ).endVertex();
|
buffer.pos(minX, maxY, minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) maxX, (float) minY, (float) minZ).endVertex();
|
buffer.pos(maxX, minY, minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) maxX, (float) maxY, (float) minZ).endVertex();
|
buffer.pos(maxX, maxY, minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) maxX, (float) minY, (float) maxZ).endVertex();
|
buffer.pos(maxX, minY, maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) maxX, (float) maxY, (float) maxZ).endVertex();
|
buffer.pos(maxX, maxY, maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) minX, (float) minY, (float) maxZ).endVertex();
|
buffer.pos(minX, minY, maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) minX, (float) maxY, (float) maxZ).endVertex();
|
buffer.pos(minX, maxY, maxZ).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
|
|
||||||
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
IRenderer.endLines(settings.renderGoalIgnoreDepth.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderHorizontalQuad(MatrixStack stack, double minX, double maxX, double minZ, double maxZ, double y) {
|
private static void renderHorizontalQuad(double minX, double maxX, double minZ, double maxZ, double y) {
|
||||||
if (y != 0) {
|
if (y != 0) {
|
||||||
Matrix4f matrix4f = stack.getLast().getMatrix();
|
|
||||||
buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION);
|
buffer.begin(GL_LINE_LOOP, DefaultVertexFormats.POSITION);
|
||||||
buffer.pos(matrix4f, (float) minX, (float) y, (float) minZ).endVertex();
|
buffer.pos(minX, y, minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) maxX, (float) y, (float) minZ).endVertex();
|
buffer.pos(maxX, y, minZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) maxX, (float) y, (float) maxZ).endVertex();
|
buffer.pos(maxX, y, maxZ).endVertex();
|
||||||
buffer.pos(matrix4f, (float) minX, (float) y, (float) maxZ).endVertex();
|
buffer.pos(minX, y, maxZ).endVertex();
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class PlayerMovementInput extends MovementInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void func_225607_a_(boolean p_225607_1_) {
|
public void tick(boolean p_217607_1_, boolean p_217607_2_) {
|
||||||
this.moveStrafe = 0.0F;
|
this.moveStrafe = 0.0F;
|
||||||
this.moveForward = 0.0F;
|
this.moveForward = 0.0F;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public class PlayerMovementInput extends MovementInput {
|
|||||||
this.moveStrafe--;
|
this.moveStrafe--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.field_228350_h_ = handler.isInputForcedDown(Input.SNEAK)) {
|
if (this.sneak = handler.isInputForcedDown(Input.SNEAK)) {
|
||||||
this.moveStrafe *= 0.3D;
|
this.moveStrafe *= 0.3D;
|
||||||
this.moveForward *= 0.3D;
|
this.moveForward *= 0.3D;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ package baritone.utils.accessor;
|
|||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
|
||||||
public interface IPalettedContainer {
|
public interface IBlockStateContainer {
|
||||||
|
|
||||||
BlockState getAtPalette(int index);
|
BlockState getAtPalette(int index);
|
||||||
|
|
||||||
@@ -70,4 +70,4 @@ public final class MCEditSchematic extends StaticSchematic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ package org.hydev.hyritone;
|
|||||||
|
|
||||||
import baritone.Baritone;
|
import baritone.Baritone;
|
||||||
import org.hydev.hyritone.seedxray.SeedServerCache;
|
import org.hydev.hyritone.seedxray.SeedServerCache;
|
||||||
|
import org.hydev.hyritone.task.TaskManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Write a description for this class!
|
* TODO: Write a description for this class!
|
||||||
@@ -33,9 +34,11 @@ import org.hydev.hyritone.seedxray.SeedServerCache;
|
|||||||
public class Hyritone
|
public class Hyritone
|
||||||
{
|
{
|
||||||
public static SeedServerCache seedServerCache;
|
public static SeedServerCache seedServerCache;
|
||||||
|
public static TaskManager taskManager;
|
||||||
|
|
||||||
public Hyritone(Baritone baritone)
|
public Hyritone(Baritone baritone)
|
||||||
{
|
{
|
||||||
seedServerCache = new SeedServerCache(baritone);
|
seedServerCache = new SeedServerCache(baritone);
|
||||||
|
taskManager = new TaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,9 +68,12 @@ public class SeedServerCache extends Behavior
|
|||||||
public Map<String, BlockState> blocksMap = new HashMap<>();
|
public Map<String, BlockState> blocksMap = new HashMap<>();
|
||||||
|
|
||||||
public boolean enabled = false;
|
public boolean enabled = false;
|
||||||
public String blockToFind = "diamond_ore";
|
|
||||||
public boolean updating = false;
|
public boolean updating = false;
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
public SeedXrayProperties properties = SeedXrayProperties.DIAMOND;
|
||||||
|
public int max = 64;
|
||||||
|
|
||||||
public int ticks = 100;
|
public int ticks = 100;
|
||||||
|
|
||||||
public SeedServerCache(Baritone baritone)
|
public SeedServerCache(Baritone baritone)
|
||||||
@@ -112,14 +115,14 @@ public class SeedServerCache extends Behavior
|
|||||||
// Get request
|
// Get request
|
||||||
HttpGet get = new HttpGet("http://localhost:12255/api/get-locations-of");
|
HttpGet get = new HttpGet("http://localhost:12255/api/get-locations-of");
|
||||||
get.setHeader("world", "world");
|
get.setHeader("world", "world");
|
||||||
get.setHeader("block", blockToFind);
|
get.setHeader("block", properties.blockToFind);
|
||||||
get.setHeader("maximum", "64");
|
get.setHeader("maximum", "" + max);
|
||||||
get.setHeader("center-x", "" + cacheLocation.getX());
|
get.setHeader("center-x", "" + cacheLocation.getX());
|
||||||
get.setHeader("center-y", "" + cacheLocation.getY());
|
get.setHeader("center-y", "" + cacheLocation.getY());
|
||||||
get.setHeader("center-z", "" + cacheLocation.getZ());
|
get.setHeader("center-z", "" + cacheLocation.getZ());
|
||||||
get.setHeader("max-search-rad", "64");
|
get.setHeader("max-search-rad", "64");
|
||||||
get.setHeader("y-min", "3");
|
get.setHeader("y-min", "" + properties.yMin);
|
||||||
get.setHeader("y-max", "16");
|
get.setHeader("y-max", "" + properties.yMax);
|
||||||
|
|
||||||
debug("==============================================");
|
debug("==============================================");
|
||||||
debug("Getting block data from seed exploit server...");
|
debug("Getting block data from seed exploit server...");
|
||||||
@@ -161,7 +164,7 @@ public class SeedServerCache extends Behavior
|
|||||||
if (!enabled) return;
|
if (!enabled) return;
|
||||||
|
|
||||||
// Render xray
|
// Render xray
|
||||||
PathRenderer.drawManySelectionBoxes(event.getModelViewStack(), Helper.mc.getRenderViewEntity(), cacheBlocks, Color.cyan);
|
PathRenderer.drawManySelectionBoxes(Helper.mc.getRenderViewEntity(), cacheBlocks, Color.cyan);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -53,19 +53,35 @@ public class SeedXrayCommand extends Command
|
|||||||
{
|
{
|
||||||
if (Baritone.settings().mineWithSeed.value = seedServerCache.enabled = !seedServerCache.enabled)
|
if (Baritone.settings().mineWithSeed.value = seedServerCache.enabled = !seedServerCache.enabled)
|
||||||
{
|
{
|
||||||
|
// Set args
|
||||||
|
args.requireMin(1);
|
||||||
|
args.requireMax(2);
|
||||||
|
|
||||||
|
// Ore
|
||||||
|
if (!args.hasAny()) return;
|
||||||
|
String ore = args.getString();
|
||||||
|
SeedXrayProperties properties = SeedXrayProperties.byName(ore);
|
||||||
|
seedServerCache.properties = properties;
|
||||||
|
|
||||||
|
// Max
|
||||||
|
if (args.hasAny())
|
||||||
|
{
|
||||||
|
seedServerCache.max = args.getAs(Integer.class);
|
||||||
|
}
|
||||||
|
|
||||||
print("Seed xray enabled");
|
print("Seed xray enabled");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print("Seed xray disabled");
|
|
||||||
|
|
||||||
// Reset status
|
// Reset status
|
||||||
seedServerCache.ticks = 100;
|
seedServerCache.ticks = 100;
|
||||||
seedServerCache.enabled = false;
|
|
||||||
seedServerCache.blocksMap = new HashMap<>();
|
seedServerCache.blocksMap = new HashMap<>();
|
||||||
seedServerCache.cacheLocation = null;
|
seedServerCache.cacheLocation = null;
|
||||||
seedServerCache.cacheBlocks = new ArrayList<>();
|
seedServerCache.cacheBlocks = new ArrayList<>();
|
||||||
seedServerCache.updating = false;
|
seedServerCache.updating = false;
|
||||||
|
seedServerCache.max = 64;
|
||||||
|
|
||||||
|
print("Seed xray disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +101,7 @@ public class SeedXrayCommand extends Command
|
|||||||
"This function draws ESP boxes around the ores that exists in the seed server that are not mined.",
|
"This function draws ESP boxes around the ores that exists in the seed server that are not mined.",
|
||||||
"",
|
"",
|
||||||
"Usage:",
|
"Usage:",
|
||||||
"> seedxray"
|
"> seedxray <ore preset> (max)"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.hydev.hyritone.seedxray;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write a description for this class!
|
||||||
|
* <p>
|
||||||
|
* Class created by the HyDEV Team on 2020-02-23!
|
||||||
|
*
|
||||||
|
* @author HyDEV Team (https://github.com/HyDevelop)
|
||||||
|
* @author Hykilpikonna (https://github.com/hykilpikonna)
|
||||||
|
* @author Vanilla (https://github.com/VergeDX)
|
||||||
|
* @since 2020-02-23 11:32
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum SeedXrayProperties
|
||||||
|
{
|
||||||
|
DIAMOND("diamond", "diamond_ore", 3, 16),
|
||||||
|
IRON("iron", "iron_ore", 20, 60),
|
||||||
|
REDSTONE("redstone", "redstone_ore", 3, 16),
|
||||||
|
LAPIS("lapis", "lapis_lazuri_ore", 5, 30),
|
||||||
|
GOLD("gold", "gold_ore", 5, 30),
|
||||||
|
GOLD_BADLANDS("gold_badlands", "gold_ore", 32, 70),
|
||||||
|
EMERALD("emerald", "emerald_ore", 5, 30);
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
public String blockToFind;
|
||||||
|
public int yMin;
|
||||||
|
public int yMax;
|
||||||
|
|
||||||
|
public static SeedXrayProperties byName(String name)
|
||||||
|
{
|
||||||
|
name = name.toLowerCase().replace("-", "_");
|
||||||
|
|
||||||
|
for (SeedXrayProperties value : SeedXrayProperties.values())
|
||||||
|
{
|
||||||
|
if (value.name.equals(name) || value.blockToFind.equals(name))
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.hydev.hyritone.task;
|
||||||
|
|
||||||
|
import baritone.api.IBaritone;
|
||||||
|
import baritone.api.command.Command;
|
||||||
|
import baritone.api.command.argument.IArgConsumer;
|
||||||
|
import baritone.api.command.exception.CommandException;
|
||||||
|
import org.hydev.hyritone.Hyritone;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write a description for this class!
|
||||||
|
* <p>
|
||||||
|
* Class created by the HyDEV Team on 2020-02-21!
|
||||||
|
*
|
||||||
|
* @author HyDEV Team (https://github.com/HyDevelop)
|
||||||
|
* @author Hykilpikonna (https://github.com/hykilpikonna)
|
||||||
|
* @author Vanilla (https://github.com/VergeDX)
|
||||||
|
* @since 2020-02-21 19:47
|
||||||
|
*/
|
||||||
|
public class TaskCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates a new Baritone control command.
|
||||||
|
*
|
||||||
|
* @param baritone
|
||||||
|
* @param names The names of this command. This is what you put after the command prefix.
|
||||||
|
*/
|
||||||
|
public TaskCommand(IBaritone baritone, String... names)
|
||||||
|
{
|
||||||
|
super(baritone, "task");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String label, IArgConsumer args) throws CommandException
|
||||||
|
{
|
||||||
|
if (Hyritone.taskManager.getRunState() != null) Hyritone.taskManager.stop();
|
||||||
|
else Hyritone.taskManager.run(TaskPresets.presets.get("AutoEmeralds"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException
|
||||||
|
{
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getShortDesc()
|
||||||
|
{
|
||||||
|
return "Manage tasks";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLongDesc()
|
||||||
|
{
|
||||||
|
return Arrays.asList(
|
||||||
|
"Manage tasks.",
|
||||||
|
"",
|
||||||
|
"Usage:",
|
||||||
|
"> task "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ package org.hydev.hyritone.task;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import static org.hydev.hyritone.utils.MiscUtils.debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to manage tasks.
|
* This class is used to manage tasks.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -26,17 +28,35 @@ public class TaskManager
|
|||||||
public boolean run(TaskList list)
|
public boolean run(TaskList list)
|
||||||
{
|
{
|
||||||
// Check already started
|
// Check already started
|
||||||
if (runState != null) return false;
|
if (runState != null)
|
||||||
|
{
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
// Reset values
|
// Reset values
|
||||||
runState = new TaskRunState(null, list, 0);
|
runState = new TaskRunState(null, list, 0);
|
||||||
|
|
||||||
|
/* // Execute task
|
||||||
|
Baritone.getExecutor().execute(() ->
|
||||||
|
{
|
||||||
|
// Execute step by step
|
||||||
|
while (runState.step < list.size())
|
||||||
|
{
|
||||||
|
list.get(runState.step).execute(runState);
|
||||||
|
runState.step++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finished
|
||||||
|
stop();
|
||||||
|
});*/
|
||||||
|
|
||||||
// Create thread
|
// Create thread
|
||||||
runState.thread = new Thread(() ->
|
runState.thread = new Thread(() ->
|
||||||
{
|
{
|
||||||
// Execute step by step
|
// Execute step by step
|
||||||
while (runState.step < list.size())
|
while (runState.step < list.size())
|
||||||
{
|
{
|
||||||
|
debug("Running step " + runState);
|
||||||
list.get(runState.step).execute(runState);
|
list.get(runState.step).execute(runState);
|
||||||
runState.step++;
|
runState.step++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public class TaskPresets
|
|||||||
}
|
}
|
||||||
catch (IOException | UncheckedIOException e)
|
catch (IOException | UncheckedIOException e)
|
||||||
{
|
{
|
||||||
System.err.println("Error when loading hyritone json.");
|
System.err.println("Error when loading org.hydev.hyritone json.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.hydev.hyritone.task;
|
||||||
|
|
||||||
|
import baritone.api.IBaritone;
|
||||||
|
import baritone.api.command.Command;
|
||||||
|
import baritone.api.command.argument.IArgConsumer;
|
||||||
|
import baritone.api.command.exception.CommandException;
|
||||||
|
import baritone.api.utils.Rotation;
|
||||||
|
import net.minecraft.inventory.container.ChestContainer;
|
||||||
|
import net.minecraft.inventory.container.MerchantContainer;
|
||||||
|
import org.hydev.hyritone.task.defaults.*;
|
||||||
|
import org.hydev.hyritone.utils.PlayerUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static java.lang.Long.MAX_VALUE;
|
||||||
|
import static net.minecraft.inventory.container.ClickType.*;
|
||||||
|
import static net.minecraft.item.Items.BOOK;
|
||||||
|
import static net.minecraft.item.Items.BOOKSHELF;
|
||||||
|
import static org.hydev.hyritone.utils.PlayerUtils.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write a description for this class!
|
||||||
|
* <p>
|
||||||
|
* Class created by the HyDEV Team on 2020-02-21!
|
||||||
|
*
|
||||||
|
* @author HyDEV Team (https://github.com/HyDevelop)
|
||||||
|
* @author Hykilpikonna (https://github.com/hykilpikonna)
|
||||||
|
* @author Vanilla (https://github.com/VergeDX)
|
||||||
|
* @since 2020-02-21 19:48
|
||||||
|
*/
|
||||||
|
public class TaskTestCommand extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Creates a new Baritone control command.
|
||||||
|
*
|
||||||
|
* @param baritone
|
||||||
|
* @param names The names of this command. This is what you put after the command prefix.
|
||||||
|
*/
|
||||||
|
public TaskTestCommand(IBaritone baritone, String... names)
|
||||||
|
{
|
||||||
|
super(baritone, "tasktest");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(String label, IArgConsumer args) throws CommandException
|
||||||
|
{
|
||||||
|
TaskList test = new TaskList("AutoEmeralds",
|
||||||
|
// 等待时间在 2000 (8:00) 和 9000 (15:00) 之间w
|
||||||
|
new TaskWaitFor(s -> ticks() > 2000 && ticks() < 9000).timeout(MAX_VALUE),
|
||||||
|
|
||||||
|
// 转向村民
|
||||||
|
s -> PlayerUtils.rotate(new Rotation(-90, 0)), // 转向村民w
|
||||||
|
new TaskDelay(10), // 等w
|
||||||
|
|
||||||
|
// 打开村民交易w
|
||||||
|
s -> mouse().rightClick(), // 点击村民w
|
||||||
|
new TaskWaitFor(s -> player().openContainer instanceof MerchantContainer) // 等点击完成w
|
||||||
|
.onTimeout(new TaskReplayRelative(1)), // 如果失败就重来w
|
||||||
|
|
||||||
|
// 和村民交易w (绿宝石 -> 书架)
|
||||||
|
s -> controller().windowClick(containerId(), 36, 0, PICKUP, player()), // 拿起绿宝石w
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> controller().windowClick(containerId(), 0, 0, PICKUP, player()), // 把书放到交易框w
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> controller().windowClick(containerId(), 2, 0, QUICK_MOVE, player()), // 把书架移到 8
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> player().closeScreen(), // 关掉界面w
|
||||||
|
|
||||||
|
// 把书架转换回书w
|
||||||
|
s -> PlayerUtils.rotate(new Rotation(90, 0)), // 转到后面面向黑曜石w
|
||||||
|
s -> player().inventory.currentItem = 8, // 选择 1: 书架w
|
||||||
|
s -> mouse().rightClick(), // 放书架w
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> player().inventory.currentItem = 0, // 选择 0: 斧子w
|
||||||
|
s -> PlayerUtils.dig(getLookingAtBlock()), // 挖掉w
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
new TaskCondition(s -> !player().inventory.hasAny(new HashSet<>(Collections.singletonList(BOOKSHELF))))
|
||||||
|
.taskElse(new TaskReplayRelative(5 + 2)), // 如果没有书架了就继续, 有的话就回到 5 步之前w
|
||||||
|
|
||||||
|
// 转向村民
|
||||||
|
s -> PlayerUtils.rotate(new Rotation(-90, 0)), // 转向村民w
|
||||||
|
new TaskDelay(10), // 等w
|
||||||
|
|
||||||
|
// 打开村民交易w
|
||||||
|
s -> mouse().rightClick(), // 点击村民w
|
||||||
|
new TaskWaitFor(s -> player().openContainer instanceof MerchantContainer) // 等点击完成w
|
||||||
|
.onTimeout(new TaskReplayRelative(1)), // 如果失败就重来w
|
||||||
|
|
||||||
|
// 和村民交易w (书 -> 绿宝石)
|
||||||
|
s -> controller().windowClick(containerId(), 31, 0, PICKUP, player()), // 拿起书
|
||||||
|
s -> controller().windowClick(containerId(), 0, 0, PICKUP, player()), // 把书放到交易框w
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> controller().windowClick(containerId(), 2, 0, QUICK_MOVE, player()), // 把绿宝石移到 8
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> controller().windowClick(containerId(), 0, 0, PICKUP, player()), // 拿起剩下的书
|
||||||
|
s -> controller().windowClick(containerId(), 31, 0, PICKUP, player()), // 在 1 放下书
|
||||||
|
new TaskDelay(1000), // 等w
|
||||||
|
s -> player().closeScreen(), // 关掉界面w
|
||||||
|
new TaskDelay(5000), // 等村民补充w
|
||||||
|
new TaskCondition(s -> player().inventory.hasAny(new HashSet<>(Collections.singletonList(BOOK))))
|
||||||
|
.taskElse(new TaskReplayRelative(9 + 3)), // 如果没有书了就继续, 有的话就回到 10 步之前w
|
||||||
|
|
||||||
|
// 转向箱子w
|
||||||
|
s -> PlayerUtils.rotate(new Rotation(180, 0)), // 转向箱子w
|
||||||
|
new TaskDelay(10), // 等w
|
||||||
|
|
||||||
|
// 打开箱子w
|
||||||
|
s -> mouse().rightClick(), // 点击箱子w
|
||||||
|
new TaskWaitFor(s -> player().openContainer instanceof ChestContainer) // 等点击完成w
|
||||||
|
.onTimeout(new TaskReplayRelative(1)), // 如果失败就重来w
|
||||||
|
|
||||||
|
// 把多余的绿宝石放到箱子里w
|
||||||
|
s -> controller().windowClick(containerId(), 89, 0, PICKUP, player()), // 拿起 36 个绿宝石w
|
||||||
|
s -> controller().windowClick(containerId(), -999, 0, QUICK_CRAFT, player()), // 开始快速合成w
|
||||||
|
s -> controller().windowClick(containerId(), 89, 1, QUICK_CRAFT, player()), // 在 8 放 1/3
|
||||||
|
s -> controller().windowClick(containerId(), 88, 1, QUICK_CRAFT, player()), // 在 7 放 1/3
|
||||||
|
s -> controller().windowClick(containerId(), 87, 1, QUICK_CRAFT, player()), // 在 6 放 1/3
|
||||||
|
s -> controller().windowClick(containerId(), -999, 2, QUICK_CRAFT, player()), // 结束快速合成w
|
||||||
|
s -> controller().windowClick(containerId(), 88, 0, QUICK_MOVE, player()), // 把 7 的绿宝石移到箱子里w
|
||||||
|
s -> controller().windowClick(containerId(), 89, 0, QUICK_MOVE, player()), // 把 8 的绿宝石移到箱子里w
|
||||||
|
s -> player().closeScreen(), // 关闭箱子w
|
||||||
|
|
||||||
|
// 从头开始w
|
||||||
|
new TaskReplay(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
TaskPresets.presets.clear();
|
||||||
|
TaskPresets.presets.put("AutoEmeralds", test);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<String> tabComplete(String label, IArgConsumer args) throws CommandException
|
||||||
|
{
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getShortDesc()
|
||||||
|
{
|
||||||
|
return "Add testing task";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLongDesc()
|
||||||
|
{
|
||||||
|
return Arrays.asList(
|
||||||
|
"Add testing task.",
|
||||||
|
"",
|
||||||
|
"Usage:",
|
||||||
|
"> tasktest "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package org.hydev.hyritone.task.defaults;
|
package org.hydev.hyritone.task.defaults;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.hydev.hyritone.task.Task;
|
import org.hydev.hyritone.task.Task;
|
||||||
import org.hydev.hyritone.task.TaskRunState;
|
import org.hydev.hyritone.task.TaskRunState;
|
||||||
|
|
||||||
@@ -14,23 +17,26 @@ import java.util.function.Function;
|
|||||||
* @author HyDEV Team (https://github.com/HyDevelop)
|
* @author HyDEV Team (https://github.com/HyDevelop)
|
||||||
* @author Hykilpikonna (https://github.com/hykilpikonna)
|
* @author Hykilpikonna (https://github.com/hykilpikonna)
|
||||||
* @author Vanilla (https://github.com/VergeDX)
|
* @author Vanilla (https://github.com/VergeDX)
|
||||||
* @since 2020-01-25 17:44
|
* o@since 2020-01-25 17:44
|
||||||
*/
|
*/
|
||||||
|
@Setter
|
||||||
|
@Accessors(fluent = true)
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class TaskCondition implements Task
|
public class TaskCondition implements Task
|
||||||
{
|
{
|
||||||
private final Function<TaskRunState, Boolean> condition;
|
private final Function<TaskRunState, Boolean> condition;
|
||||||
private final Task taskIf;
|
private Task taskThen;
|
||||||
private final Task taskElse;
|
private Task taskElse;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(TaskRunState state)
|
public void execute(TaskRunState state)
|
||||||
{
|
{
|
||||||
if (condition.apply(state))
|
if (condition.apply(state))
|
||||||
{
|
{
|
||||||
if (taskIf != null)
|
if (taskThen != null)
|
||||||
{
|
{
|
||||||
taskIf.execute(state);
|
taskThen.execute(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (taskElse != null)
|
else if (taskElse != null)
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.hydev.hyritone.task.defaults;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.hydev.hyritone.task.Task;
|
||||||
|
import org.hydev.hyritone.task.TaskRunState;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replay from some index
|
||||||
|
* <p>
|
||||||
|
* Class created by the HyDEV Team on 2020-01-24!
|
||||||
|
*
|
||||||
|
* @author HyDEV Team (https://github.com/HyDevelop)
|
||||||
|
* @author Hykilpikonna (https://github.com/hykilpikonna)
|
||||||
|
* @author Vanilla (https://github.com/VergeDX)
|
||||||
|
* @since 2020-01-24 20:37
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TaskReplayRelative implements Task
|
||||||
|
{
|
||||||
|
private final int stepOffset;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(TaskRunState state)
|
||||||
|
{
|
||||||
|
state.step -= stepOffset + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ package org.hydev.hyritone.task.defaults;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
import org.hydev.hyritone.task.Task;
|
import org.hydev.hyritone.task.Task;
|
||||||
import org.hydev.hyritone.task.TaskRunState;
|
import org.hydev.hyritone.task.TaskRunState;
|
||||||
|
|
||||||
@@ -19,11 +21,14 @@ import static org.hydev.hyritone.utils.MiscUtils.sleep;
|
|||||||
* @author Vanilla (https://github.com/VergeDX)
|
* @author Vanilla (https://github.com/VergeDX)
|
||||||
* @since 2020-01-25 12:29
|
* @since 2020-01-25 12:29
|
||||||
*/
|
*/
|
||||||
|
@Accessors(fluent = true)
|
||||||
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TaskWaitFor implements Task
|
public class TaskWaitFor implements Task
|
||||||
{
|
{
|
||||||
private final Function<TaskRunState, Boolean> condition;
|
private final Function<TaskRunState, Boolean> condition;
|
||||||
|
private Task onTimeout;
|
||||||
private long timeout = 10 * 60 * 1000;
|
private long timeout = 10 * 60 * 1000;
|
||||||
private long interval = 100;
|
private long interval = 100;
|
||||||
|
|
||||||
@@ -39,7 +44,15 @@ public class TaskWaitFor implements Task
|
|||||||
if (condition.apply(state)) return;
|
if (condition.apply(state)) return;
|
||||||
sleep(interval);
|
sleep(interval);
|
||||||
|
|
||||||
if (System.currentTimeMillis() - startTime > timeout) return;
|
if (System.currentTimeMillis() - startTime > timeout)
|
||||||
|
{
|
||||||
|
// Timeout callback
|
||||||
|
if (onTimeout != null)
|
||||||
|
{
|
||||||
|
onTimeout.execute(state);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.hydev.hyritone.utils;
|
package org.hydev.hyritone.utils;
|
||||||
|
|
||||||
import baritone.api.utils.Helper;
|
|
||||||
import baritone.api.utils.Rotation;
|
import baritone.api.utils.Rotation;
|
||||||
import baritone.utils.accessor.IMouse;
|
import baritone.utils.accessor.IMouse;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
@@ -10,9 +9,12 @@ import net.minecraft.client.world.ClientWorld;
|
|||||||
import net.minecraft.network.play.client.CAnimateHandPacket;
|
import net.minecraft.network.play.client.CAnimateHandPacket;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.util.math.Vec3i;
|
import static baritone.api.utils.Helper.mc;
|
||||||
|
import static net.minecraft.util.math.RayTraceContext.BlockMode.OUTLINE;
|
||||||
|
import static net.minecraft.util.math.RayTraceContext.FluidMode.NONE;
|
||||||
|
import static net.minecraft.util.math.RayTraceResult.Type.BLOCK;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utils for controlling the player.
|
* Utils for controlling the player.
|
||||||
@@ -26,10 +28,11 @@ import net.minecraft.util.math.Vec3i;
|
|||||||
*/
|
*/
|
||||||
public class PlayerUtils
|
public class PlayerUtils
|
||||||
{
|
{
|
||||||
public static ClientPlayerEntity player() { return Helper.mc.player; }
|
public static ClientPlayerEntity player() { return mc.player; }
|
||||||
public static ClientWorld world() { return Helper.mc.world; }
|
public static ClientWorld world() { return mc.world; }
|
||||||
public static IMouse mouse() { return (IMouse) Helper.mc.mouseHelper; }
|
public static IMouse mouse() { return (IMouse) mc.mouseHelper; }
|
||||||
public static PlayerController controller() { return Helper.mc.playerController; }
|
public static PlayerController controller() { return mc.playerController; }
|
||||||
|
public static int containerId() { return player().openContainer.windowId; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get player's eye vector
|
* Get player's eye vector
|
||||||
@@ -41,9 +44,9 @@ public class PlayerUtils
|
|||||||
{
|
{
|
||||||
assert player() != null;
|
assert player() != null;
|
||||||
|
|
||||||
return new Vec3d(player().getPosX(),
|
return new Vec3d(player().getPositionVec().x,
|
||||||
player().getPosY() + player().getEyeHeight(player().getPose()),
|
player().getPositionVec().y + player().getEyeHeight(player().getPose()),
|
||||||
player().getPosZ());
|
player().getPositionVec().z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,11 +111,11 @@ public class PlayerUtils
|
|||||||
BlockState state = world().getBlockState(pos);
|
BlockState state = world().getBlockState(pos);
|
||||||
for (int i = 0; i < sides.length; i++)
|
for (int i = 0; i < sides.length; i++)
|
||||||
{
|
{
|
||||||
// check line of sight
|
// check line of sight TODO
|
||||||
if (world().rayTraceBlocks(eyesPos, hitVecs[i], pos, state.getShape(world(), pos), state) != null)
|
/*if (world().rayTraceBlocks(new RayTraceContext(eyesPos, hitVecs[i], pos, state.getShape(world(), pos), state)) != null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
side = sides[i];
|
side = sides[i];
|
||||||
break;
|
break;
|
||||||
@@ -146,6 +149,21 @@ public class PlayerUtils
|
|||||||
return side;
|
return side;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BlockPos getLookingAtBlock()
|
||||||
|
{
|
||||||
|
Vec3d cameraPos = player().getEyePosition(1);
|
||||||
|
Vec3d rotation = player().getLook(1);
|
||||||
|
Vec3d combined = cameraPos.add(rotation.x * 5, rotation.y * 5, rotation.z * 5);
|
||||||
|
|
||||||
|
BlockRayTraceResult result = mc.world.rayTraceBlocks(new RayTraceContext(cameraPos, combined, OUTLINE, NONE, player()));
|
||||||
|
|
||||||
|
if (result.getType() == BLOCK)
|
||||||
|
{
|
||||||
|
return result.getPos();
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interact
|
* Interact
|
||||||
*
|
*
|
||||||
@@ -199,4 +217,14 @@ public class PlayerUtils
|
|||||||
{
|
{
|
||||||
return (int) (80 + Math.random() * 40);
|
return (int) (80 + Math.random() * 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return ticks of day
|
||||||
|
*
|
||||||
|
* @return Ticks of day
|
||||||
|
*/
|
||||||
|
public static long ticks()
|
||||||
|
{
|
||||||
|
return world().getDayTime() % 24000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user