it launches

This commit is contained in:
Leijurv 2019-07-23 14:12:44 -07:00
parent 223791cea7
commit 4c8907c629
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
32 changed files with 122 additions and 199 deletions

View File

@ -16,7 +16,7 @@
*/
group 'baritone'
version '1.3.3'
version '1.4.0'
buildscript {
repositories {
@ -82,7 +82,7 @@ task sourceJar(type: Jar, dependsOn: classes) {
}
minecraft {
mappings channel: 'snapshot', version: '20190608-1.14.2'
mappings channel: 'snapshot', version: '20190723-1.14.3'
reobfMappings 'notch'
runs {
@ -138,7 +138,7 @@ repositories {
}
dependencies {
minecraft 'com.github.ImpactDevelopment:Vanilla:1.14.2'
minecraft 'com.github.ImpactDevelopment:Vanilla:1.14.4'
runtime launchCompile('net.minecraft:launchwrapper:1.12') {
exclude module: 'lwjgl'

View File

@ -812,7 +812,7 @@ public final class Settings {
* via {@link Consumer#andThen(Consumer)} or it can completely be overriden via setting
* {@link Setting#value};
*/
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().field_71456_v.getChatGUI()::printChatMessage);
public final Setting<Consumer<ITextComponent>> logger = new Setting<>(Minecraft.getInstance().ingameGUI.getChatGUI()::printChatMessage);
/**
* The size of the box that is rendered when the current goal is a GoalYLevel

View File

@ -29,7 +29,7 @@ public class BlockUtils {
private static transient Map<String, Block> resourceCache = new HashMap<>();
public static String blockToString(Block block) {
ResourceLocation loc = Registry.field_212618_g.getKey(block);
ResourceLocation loc = Registry.BLOCK.getKey(block);
String name = loc.getPath(); // normally, only write the part after the minecraft:
if (!loc.getNamespace().equals("minecraft")) {
// Baritone is running on top of forge with mods installed, perhaps?
@ -53,7 +53,7 @@ public class BlockUtils {
if (resourceCache.containsKey(name)) {
return null; // cached as null
}
block = Registry.field_212618_g.getOrDefault(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name));
block = Registry.BLOCK.getOrDefault(ResourceLocation.tryCreate(name.contains(":") ? name : "minecraft:" + name));
// TODO this again returns air instead of null!
Map<String, Block> copy = new HashMap<>(resourceCache); // read only copy is safe, wont throw concurrentmodification
copy.put(name, block);

View File

@ -35,7 +35,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientChunkProvider;
import net.minecraft.crash.CrashReport;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
@ -419,7 +418,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
logDirect("Following any players");
return true;
}
if (msg.startsWith("followentity")) {
/*if (msg.startsWith("followentity")) {
String name = msg.substring(12).trim();
Optional<Entity> toFollow = Optional.empty();
for (Entity entity : ctx.world().loadedEntityList) {
@ -436,7 +435,7 @@ public class ExampleBaritoneControl implements Helper, AbstractGameEventListener
baritone.getFollowProcess().follow(effectivelyFinal::equals);
logDirect("Following entity " + toFollow.get());
return true;
}
}*/
if (msg.startsWith("follow")) {
String name = msg.substring(6).trim();
Optional<Entity> toFollow = Optional.empty();

View File

@ -20,11 +20,14 @@ package baritone.api.utils;
import baritone.api.cache.IWorldData;
import net.minecraft.block.SlabBlock;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.*;
import net.minecraft.world.World;
import java.util.Optional;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
/**
* @author Brady
@ -38,6 +41,15 @@ public interface IPlayerContext {
World world();
default Iterable<Entity> entities() {
return ((ClientWorld) world()).getAllEntities();
}
default Stream<Entity> entitiesStream() {
return StreamSupport.stream(entities().spliterator(), false);
}
IWorldData worldData();
RayTraceResult objectMouseOver();

View File

@ -48,6 +48,6 @@ public final class RayTraceUtils {
direction.y * blockReachDistance,
direction.z * blockReachDistance
);
return entity.world.func_217299_a(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, entity));
return entity.world.rayTraceBlocks(new RayTraceContext(start, end, RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, entity));
}
}

View File

@ -194,8 +194,8 @@ public class SettingsUtil {
),
ITEM(
Item.class,
str -> Registry.field_212630_s.getOrDefault(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> Registry.field_212630_s.getKey(item).toString()
str -> Registry.ITEM.getOrDefault(new ResourceLocation(str.trim())), // TODO this now returns AIR on failure instead of null, is that an issue?
item -> Registry.ITEM.getKey(item).toString()
),
LIST() {
@Override

View File

@ -66,7 +66,7 @@ public class MixinClientPlayNetHandler {
)
private void postHandleChunkData(SChunkDataPacket packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(
EventState.POST,
@ -85,7 +85,7 @@ public class MixinClientPlayNetHandler {
)
private void preChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.PRE, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
);
@ -99,7 +99,7 @@ public class MixinClientPlayNetHandler {
)
private void postChunkUnload(SUnloadChunkPacket packet, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onChunkEvent(
new ChunkEvent(EventState.POST, ChunkEvent.Type.UNLOAD, packet.getX(), packet.getZ())
);
@ -116,7 +116,7 @@ public class MixinClientPlayNetHandler {
)
private void onPlayerDeath(SCombatPacket packetIn, CallbackInfo ci) {
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player().field_71174_a == (ClientPlayNetHandler) (Object) this) {
if (ibaritone.getPlayerContext().player().connection == (ClientPlayNetHandler) (Object) this) {
ibaritone.getGameEventHandler().onPlayerDeath();
}
}

View File

@ -17,27 +17,32 @@
package baritone.launch.mixins;
import baritone.utils.accessor.IAnvilChunkLoader;
import net.minecraft.world.chunk.storage.RegionFileCache;
import org.spongepowered.asm.mixin.Final;
import baritone.utils.accessor.IEntityRenderManager;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.io.File;
/**
* @author Brady
* @since 9/4/2018
*/
@Mixin(RegionFileCache.class)
public class MixinRegionFileCache implements IAnvilChunkLoader {
@Mixin(EntityRendererManager.class)
public class MixinEntityRenderManager implements IEntityRenderManager {
@Shadow
@Final
private File folder;
private double renderPosX;
@Shadow
private double renderPosY;
@Shadow
private double renderPosZ;
@Override
public File getChunkSaveLocation() {
return this.folder;
public double renderPosX() {
return renderPosX;
}
@Override
public double renderPosY() {
return renderPosY;
}
@Override
public double renderPosZ() {
return renderPosZ;
}
}

View File

@ -33,6 +33,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -78,7 +79,7 @@ public class MixinMinecraft {
at = @At(
value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "net/minecraft/client/Minecraft.field_71462_r:Lnet/minecraft/client/gui/screen/Screen;",
target = "net/minecraft/client/Minecraft.currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
ordinal = 5,
shift = At.Shift.BY,
by = -3
@ -145,19 +146,6 @@ public class MixinMinecraft {
return (BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().getCurrent() != null && player != null) || screen.passEvents;
}
@Inject(
method = "clickMouse",
at = @At(
value = "INVOKE",
target = "net/minecraft/client/multiplayer/PlayerController.clickBlock(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/Direction;)Z"
),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void onBlockBreak(CallbackInfo ci, BlockPos pos) {
// clickMouse is only for the main player
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(pos, BlockInteractEvent.Type.START_BREAK));
}
@Inject(
method = "rightClickMouse",
at = @At(
@ -166,8 +154,8 @@ public class MixinMinecraft {
),
locals = LocalCapture.CAPTURE_FAILHARD
)
private void onBlockUse(CallbackInfo ci, Hand var1[], int var2, int var3, Hand enumhand, ItemStack itemstack, BlockPos blockpos, 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
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(blockpos, BlockInteractEvent.Type.USE));
BaritoneAPI.getProvider().getPrimaryBaritone().getGameEventHandler().onBlockInteract(new BlockInteractEvent(raytrace.getPos(), BlockInteractEvent.Type.USE));
}
}

View File

@ -47,19 +47,19 @@ public class MixinNetworkManager {
@Shadow
@Final
private PacketDirection field_179294_g;
private PacketDirection direction;
@Inject(
method = "dispatchPacket",
at = @At("HEAD")
)
private void preDispatchPacket(IPacket<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
if (this.field_179294_g != PacketDirection.CLIENTBOUND) {
if (this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, inPacket));
}
}
@ -70,12 +70,12 @@ public class MixinNetworkManager {
at = @At("RETURN")
)
private void postDispatchPacket(IPacket<?> inPacket, final GenericFutureListener<? extends Future<? super Void>> futureListeners, CallbackInfo ci) {
if (this.field_179294_g != PacketDirection.CLIENTBOUND) {
if (this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onSendPacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, inPacket));
}
}
@ -89,11 +89,11 @@ public class MixinNetworkManager {
)
)
private void preProcessPacket(ChannelHandlerContext context, IPacket<?> packet, CallbackInfo ci) {
if (this.field_179294_g != PacketDirection.CLIENTBOUND) {
if (this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.PRE, packet));
}
}
@ -104,11 +104,11 @@ public class MixinNetworkManager {
at = @At("RETURN")
)
private void postProcessPacket(ChannelHandlerContext context, IPacket<?> packet, CallbackInfo ci) {
if (!this.channel.isOpen() || this.field_179294_g != PacketDirection.CLIENTBOUND) {
if (!this.channel.isOpen() || this.direction != PacketDirection.CLIENTBOUND) {
return;
}
for (IBaritone ibaritone : BaritoneAPI.getProvider().getAllBaritones()) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().field_71174_a.getNetworkManager() == (NetworkManager) (Object) this) {
if (ibaritone.getPlayerContext().player() != null && ibaritone.getPlayerContext().player().connection.getNetworkManager() == (NetworkManager) (Object) this) {
ibaritone.getGameEventHandler().onReceivePacket(new PacketEvent((NetworkManager) (Object) this, EventState.POST, packet));
}
}

View File

@ -1,42 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.launch.mixins;
import baritone.utils.accessor.IChunkProviderServer;
import net.minecraft.world.chunk.ServerChunkProvider;
import net.minecraft.world.chunk.storage.ChunkLoader;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
/**
* @author Brady
* @since 9/4/2018
*/
@Mixin(ServerChunkProvider.class)
public class MixinServerChunkProvider implements IChunkProviderServer {
@Shadow
@Final
private ChunkLoader chunkLoader;
@Override
public ChunkLoader getChunkLoader() {
return this.chunkLoader;
}
}

View File

@ -15,8 +15,6 @@
"MixinGameRenderer",
"MixinLivingEntity",
"MixinMinecraft",
"MixinNetworkManager",
"MixinRegionFileCache",
"MixinServerChunkProvider"
"MixinNetworkManager"
]
}

View File

@ -20,11 +20,9 @@ package baritone.cache;
import baritone.Baritone;
import baritone.api.cache.IWorldProvider;
import baritone.api.utils.Helper;
import baritone.utils.accessor.IAnvilChunkLoader;
import baritone.utils.accessor.IChunkProviderServer;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.world.ServerWorld;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld;
import org.apache.commons.lang3.SystemUtils;
import java.io.File;
@ -65,9 +63,7 @@ public class WorldProvider implements IWorldProvider, Helper {
// If there is an integrated server running (Aka Singleplayer) then do magic to find the world save file
if (mc.isSingleplayer()) {
ServerWorld localServerWorld = integratedServer.getWorld(dimension);
IChunkProviderServer provider = (IChunkProviderServer) localServerWorld.getChunkProvider();
IAnvilChunkLoader loader = (IAnvilChunkLoader) provider.getChunkLoader();
directory = loader.getChunkSaveLocation();
directory = dimension.getDirectory(localServerWorld.getSaveHandler().getWorldDirectory());
// Gets the "depth" of this directory relative the the game's run directory, 2 is the location of the world
if (directory.toPath().relativize(mc.gameDir.toPath()).getNameCount() != 2) {

View File

@ -122,7 +122,7 @@ public abstract class Movement implements IMovement, MovementHelper {
*/
@Override
public MovementStatus update() {
ctx.player().playerAbilities.isFlying = false;
ctx.player().abilities.isFlying = false;
currentState = updateState(currentState);
if (MovementHelper.isLiquid(ctx, ctx.playerFeet())) {
currentState.setInput(Input.JUMP, true);

View File

@ -360,7 +360,7 @@ public interface MovementHelper extends ActionCosts, Helper {
// can we look at the center of a side face of this block and likely be able to place?
// (thats how this check is used)
// therefore dont include weird things that we technically could place against (like carpet) but practically can't
return isBlockNormalCube(state) || isFullCube(state) || state.getBlock() == Blocks.GLASS || state.getBlock() instanceof StainedGlassBlock;
return isBlockNormalCube(state) || state.getBlock() == Blocks.GLASS || state.getBlock() instanceof StainedGlassBlock;
}
static double getMiningDurationTicks(CalculationContext context, int x, int y, int z, boolean includeFalling) {
@ -498,11 +498,7 @@ public interface MovementHelper extends ActionCosts, Helper {
}
static boolean isBlockNormalCube(BlockState state) {
return state.isBlockNormalCube();
}
static boolean isFullCube(BlockState state){
return state.isFullCube();
return state.isNormalCube(null, null);
}
static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone, BlockPos placeAt, boolean preferDown) {

View File

@ -20,6 +20,8 @@ package baritone.pathing.movement;
import baritone.api.pathing.movement.MovementStatus;
import baritone.api.utils.Rotation;
import baritone.api.utils.input.Input;
import net.minecraft.client.Minecraft;
import net.minecraft.util.registry.Registry;
import java.util.HashMap;
import java.util.Map;

View File

@ -188,7 +188,7 @@ public class MovementTraverse extends Movement {
// it's safe to do this since the two blocks we break (in a traverse) are right on top of each other and so will have the same yaw
float yawToDest = RotationUtils.calcRotationFromVec3d(ctx.playerHead(), VecUtils.calculateBlockCenter(ctx.world(), dest), ctx.playerRotations()).getYaw();
float pitchToBreak = state.getTarget().getRotation().get().getPitch();
if ((MovementHelper.isFullCube(pb0) || pb0.getBlock() instanceof AirBlock && (MovementHelper.isFullCube(pb1) || pb1.getBlock() instanceof AirBlock))) {
if ((MovementHelper.isBlockNormalCube(pb0) || pb0.getBlock() instanceof AirBlock && (MovementHelper.isBlockNormalCube(pb1) || pb1.getBlock() instanceof AirBlock))) {
// in the meantime, before we're right up against the block, we can break efficiently at this angle
pitchToBreak = 26;
}

View File

@ -268,7 +268,7 @@ public final class FarmProcess extends BaritoneProcessHelper implements IFarmPro
goalz.add(new GoalBlock(pos));
}
}
for (Entity entity : ctx.world().loadedEntityList) {
for (Entity entity : ctx.entities()) {
if (entity instanceof ItemEntity && entity.onGround) {
ItemEntity ei = (ItemEntity) entity;
if (PICKUP_DROPPED.contains(ei.getItem().getItem())) {

View File

@ -33,7 +33,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Follow an entity
@ -78,12 +77,11 @@ public final class FollowProcess extends BaritoneProcessHelper implements IFollo
if (entity.equals(ctx.player())) {
return false;
}
return ctx.world().loadedEntityList.contains(entity);
return ctx.entitiesStream().anyMatch(entity::equals);
}
private void scanWorld() {
cache = Stream.of(ctx.world().loadedEntityList, ctx.world().getPlayers())
.flatMap(List::stream)
cache = ctx.entitiesStream()
.filter(this::followable)
.filter(this.filter)
.distinct()

View File

@ -34,12 +34,15 @@ import baritone.pathing.movement.MovementHelper;
import baritone.utils.BaritoneProcessHelper;
import baritone.utils.BlockStateInterface;
import net.minecraft.block.*;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import java.util.*;
import java.util.stream.Collectors;
@ -75,11 +78,11 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
@Override
public PathingCommand onTick(boolean calcFailed, boolean isSafeToCancel) {
if (desiredQuantity > 0) {
Item item = mining.get(0).getItemDropped(mining.get(0).getDefaultState(), ctx.world(), null, 0).asItem();
int curr = ctx.player().inventory.mainInventory.stream().filter(stack -> item.equals(stack.getItem())).mapToInt(ItemStack::getCount).sum();
List<Item> item = drops(mining.get(0));
int curr = ctx.player().inventory.mainInventory.stream().filter(stack -> item.contains(stack.getItem())).mapToInt(ItemStack::getCount).sum();
System.out.println("Currently have " + curr + " " + item);
if (curr >= desiredQuantity) {
logDirect("Have " + curr + " " + item.getDisplayName(new ItemStack(item, 1)));
logDirect("Have " + curr);
cancel();
return null;
}
@ -280,19 +283,21 @@ public final class MineProcess extends BaritoneProcessHelper implements IMinePro
}
}
public static List<Item> drops(Block block) {
return block.getDefaultState().getDrops(new LootContext.Builder(null).withRandom(new Random()).withParameter(LootParameters.POSITION, BlockPos.ZERO).withParameter(LootParameters.TOOL, ItemStack.EMPTY).withNullableParameter(LootParameters.BLOCK_ENTITY, null)).stream().map(ItemStack::getItem).collect(Collectors.toList());
}
public static List<BlockPos> droppedItemsScan(List<Block> mining, World world) {
if (!Baritone.settings().mineScanDroppedItems.value) {
return Collections.emptyList();
}
Set<Item> searchingFor = new HashSet<>();
for (Block block : mining) {
Item drop = block.getItemDropped(block.getDefaultState(), world, null, 0).asItem();
Item ore = block.asItem();
searchingFor.add(drop);
searchingFor.add(ore);
searchingFor.addAll(drops(block));
searchingFor.add(block.asItem());
}
List<BlockPos> ret = new ArrayList<>();
for (Entity entity : world.loadedEntityList) {
for (Entity entity : ((ClientWorld) world).getAllEntities()) {
if (entity instanceof ItemEntity) {
ItemEntity ei = (ItemEntity) entity;
if (searchingFor.contains(ei.getItem().getItem())) {

View File

@ -72,27 +72,27 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
System.out.println("Optimizing Game Settings");
GameSettings s = mc.gameSettings;
s.limitFramerate = 20;
s.framerateLimit = 20;
s.mipmapLevels = 0;
s.field_74362_aa = ParticleStatus.MINIMAL;
s.particles = ParticleStatus.MINIMAL;
s.overrideWidth = 128;
s.overrideHeight = 128;
s.heldItemTooltips = false;
s.entityShadows = false;
s.chatScale = 0.0F;
s.ambientOcclusionStatus = AmbientOcclusionStatus.OFF;
s.field_74345_l = CloudOption.OFF;
s.cloudOption = CloudOption.OFF;
s.fancyGraphics = false;
s.tutorialStep = TutorialSteps.NONE;
s.hideGUI = true;
s.fovSetting = 30.0F;
s.fov = 30.0F;
}
@Override
public void onTick(TickEvent event) {
IPlayerContext ctx = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext();
// If we're on the main menu then create the test world and launch the integrated server
if (mc.field_71462_r instanceof MainMenuScreen) {
if (mc.currentScreen instanceof MainMenuScreen) {
System.out.println("Beginning Baritone automatic test routine");
mc.displayGuiScreen(null);
WorldSettings worldsettings = new WorldSettings(TEST_SEED, GameType.getByName("survival"), true, false, WorldType.DEFAULT);
@ -105,7 +105,8 @@ public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
// to our defined starting position
if (server != null && server.getWorld(DimensionType.OVERWORLD) != null) {
server.getWorld(DimensionType.OVERWORLD).setSpawnPoint(STARTING_POSITION);
server.getWorld(DimensionType.OVERWORLD).getGameRules().setOrCreateGameRule("spawnRadius", "0", server);
throw new UnsupportedOperationException("TODO figure out how to set SPAWN_RADIUS");
//server.getWorld(DimensionType.OVERWORLD).getGameRules().get(GameRules.SPAWN_RADIUS).func_223554_b(null, "0"); // TODO I HAVE NO IDEA
}
if (event.getType() == TickEvent.Type.IN) { // If we're in-game

View File

@ -168,6 +168,6 @@ public class BlockStateInterface {
if (ChunkSection.isEmpty(section)) {
return AIR;
}
return section.get(x & 15, y & 15, z & 15);
return section.getBlockState(x & 15, y & 15, z & 15);
}
}

View File

@ -72,7 +72,7 @@ public class GuiClick extends Screen implements Helper {
///
Vec3d viewerPos = new Vec3d(PathRenderer.posX(), PathRenderer.posY(), PathRenderer.posZ());
ClientPlayerEntity player = BaritoneAPI.getProvider().getPrimaryBaritone().getPlayerContext().player();
RayTraceResult result = player.world.func_217299_a(new RayTraceContext(near.add(viewerPos), far.add(viewerPos), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player));
RayTraceResult result = player.world.rayTraceBlocks(new RayTraceContext(near.add(viewerPos), far.add(viewerPos), RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.NONE, player));
if (result != null && result.getType() == RayTraceResult.Type.BLOCK) {
currentMouseOver = ((BlockRayTraceResult) result).getPos();
}

View File

@ -27,6 +27,7 @@ import baritone.api.utils.Helper;
import baritone.api.utils.interfaces.IGoalRenderPos;
import baritone.behavior.PathingBehavior;
import baritone.pathing.path.PathExecutor;
import baritone.utils.accessor.IEntityRenderManager;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.BufferBuilder;
@ -61,22 +62,22 @@ public final class PathRenderer implements Helper {
private PathRenderer() {}
public static double posX() {
return mc.getRenderManager().viewerPosX;
return ((IEntityRenderManager) mc.getRenderManager()).renderPosX();
}
public static double posY() {
return mc.getRenderManager().viewerPosY;
return ((IEntityRenderManager) mc.getRenderManager()).renderPosY();
}
public static double posZ() {
return mc.getRenderManager().viewerPosZ;
return ((IEntityRenderManager) mc.getRenderManager()).renderPosZ();
}
public static void render(RenderEvent event, PathingBehavior behavior) {
float partialTicks = event.getPartialTicks();
Goal goal = behavior.getGoal();
if (mc.field_71462_r instanceof GuiClick) {
((GuiClick) mc.field_71462_r).onRender();
if (mc.currentScreen instanceof GuiClick) {
((GuiClick) mc.currentScreen).onRender();
}
int thisPlayerDimension = behavior.baritone.getPlayerContext().world().getDimension().getType().getId();

View File

@ -165,11 +165,11 @@ public class ToolSet {
*/
private double potionAmplifier() {
double speed = 1;
if (player.isPotionActive(Effects.field_76422_e)) {
speed *= 1 + (player.getActivePotionEffect(Effects.field_76422_e).getAmplifier() + 1) * 0.2;
if (player.isPotionActive(Effects.HASTE)) {
speed *= 1 + (player.getActivePotionEffect(Effects.HASTE).getAmplifier() + 1) * 0.2;
}
if (player.isPotionActive(Effects.field_76419_f)) {
switch (player.getActivePotionEffect(Effects.field_76419_f).getAmplifier()) {
if (player.isPotionActive(Effects.MINING_FATIGUE)) {
switch (player.getActivePotionEffect(Effects.MINING_FATIGUE).getAmplifier()) {
case 0:
speed *= 0.3;
break;

View File

@ -1,32 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.utils.accessor;
import baritone.cache.WorldProvider;
import java.io.File;
/**
* @author Brady
* @see WorldProvider
* @since 8/4/2018
*/
public interface IAnvilChunkLoader {
File getChunkSaveLocation();
}

View File

@ -17,13 +17,10 @@
package baritone.utils.accessor;
import net.minecraft.world.chunk.storage.ChunkLoader;
public interface IEntityRenderManager {
double renderPosX();
/**
* @author Brady
* @since 8/4/2018
*/
public interface IChunkProviderServer {
double renderPosY();
ChunkLoader getChunkLoader();
double renderPosZ();
}

View File

@ -71,10 +71,10 @@ public class Avoidance {
.forEach(mobspawner -> res.add(new Avoidance(mobspawner, mobSpawnerCoeff, Baritone.settings().mobSpawnerAvoidanceRadius.value)));
}
if (mobCoeff != 1.0D) {
ctx.world().loadedEntityList.stream()
ctx.entitiesStream()
.filter(entity -> entity instanceof MobEntity)
.filter(entity -> (!(entity instanceof SpiderEntity)) || ctx.player().getBrightness() < 0.5)
.filter(entity -> !(entity instanceof ZombiePigmanEntity) || ((ZombiePigmanEntity) entity).isAngry())
.filter(entity -> !(entity instanceof ZombiePigmanEntity) || ((ZombiePigmanEntity) entity).getRevengeTarget() != null)
.filter(entity -> !(entity instanceof EndermanEntity) || ((EndermanEntity) entity).isScreaming())
.forEach(entity -> res.add(new Avoidance(new BlockPos(entity), mobCoeff, Baritone.settings().mobAvoidanceRadius.value)));
}

View File

@ -44,38 +44,37 @@ public enum PrimaryPlayerController implements IPlayerController, Helper {
@Override
public boolean onPlayerDamageBlock(BlockPos pos, Direction side) {
return mc.field_71442_b.onPlayerDamageBlock(pos, side);
return mc.playerController.onPlayerDamageBlock(pos, side);
}
@Override
public void resetBlockRemoving() {
mc.field_71442_b.resetBlockRemoving();
mc.playerController.resetBlockRemoving();
}
@Override
public ItemStack windowClick(int windowId, int slotId, int mouseButton, ClickType type, PlayerEntity player) {
return mc.field_71442_b.windowClick(windowId, slotId, mouseButton, type, player);
return mc.playerController.windowClick(windowId, slotId, mouseButton, type, player);
}
@Override
public void setGameType(GameType type) {
mc.field_71442_b.setGameType(type);
mc.playerController.setGameType(type);
}
@Override
public GameType getGameType() {
return mc.field_71442_b.getCurrentGameType();
return mc.playerController.getCurrentGameType();
}
@Override
public ActionResultType processRightClickBlock(ClientPlayerEntity player, World world, Hand hand, BlockRayTraceResult result) {
// primaryplayercontroller is always in a ClientWorld so this is ok
return mc.field_71442_b.func_217292_a(player, (ClientWorld) world, hand, result);
return mc.playerController.func_217292_a(player, (ClientWorld) world, hand, result);
}
@Override
public ActionResultType processRightClick(ClientPlayerEntity player, World world, Hand hand) {
return mc.field_71442_b.processRightClick(player, world, hand);
return mc.playerController.processRightClick(player, world, hand);
}
}

View File

@ -20,7 +20,7 @@ package baritone.utils.schematic.schematica;
import baritone.api.utils.ISchematic;
import com.github.lunatrius.schematica.client.world.SchematicWorld;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
public final class SchematicAdapter implements ISchematic {
@ -31,7 +31,7 @@ public final class SchematicAdapter implements ISchematic {
}
@Override
public IBlockState desiredState(int x, int y, int z) {
public BlockState desiredState(int x, int y, int z) {
return schematic.getSchematic().getBlockState(new BlockPos(x, y, z));
}

View File

@ -17,11 +17,11 @@
package com.github.lunatrius.schematica.api;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
public interface ISchematic {
IBlockState getBlockState(BlockPos var1);
BlockState getBlockState(BlockPos var1);
int getWidth();