Merge branch '1.14.4' into 1.15.2
This commit is contained in:
@@ -10,7 +10,6 @@ install:
|
||||
|
||||
script:
|
||||
- docker run --name baritone cabaletta/baritone ./gradlew javadoc
|
||||
#- docker run --name baritone cabaletta/baritone /bin/sh -c "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 128x128x24 -ac +extension GLX +render; DISPLAY=:99 BARITONE_AUTO_TEST=true ./gradlew runAutoTest; cat /code/autotest/success"
|
||||
- docker cp baritone:/code/dist dist
|
||||
- ls dist
|
||||
- cat dist/checksums.txt
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
FROM debian:stretch
|
||||
|
||||
RUN echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
RUN apt update -y
|
||||
@@ -10,16 +8,10 @@ RUN apt install \
|
||||
openjdk-8-jdk \
|
||||
--assume-yes
|
||||
|
||||
RUN apt install -qq --assume-yes mesa-utils libgl1-mesa-glx libxcursor1 libxrandr2 libxxf86vm1 x11-xserver-utils xfonts-base xserver-common
|
||||
|
||||
COPY . /code
|
||||
|
||||
WORKDIR /code
|
||||
|
||||
# this .deb is specially patched to support lwjgl
|
||||
# source: https://github.com/tectonicus/tectonicus/issues/60#issuecomment-154239173
|
||||
RUN dpkg -i scripts/xvfb_1.16.4-1_amd64.deb
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build -Pbaritone.forge_build
|
||||
RUN ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
Binary file not shown.
@@ -22,7 +22,6 @@ import baritone.api.IBaritone;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.api.event.events.WorldEvent;
|
||||
import baritone.api.event.events.type.EventState;
|
||||
import baritone.utils.BaritoneAutoTest;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
@@ -57,14 +56,6 @@ public class MixinMinecraft {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "startTimerHackThread",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void preInit(CallbackInfo ci) {
|
||||
BaritoneAutoTest.INSTANCE.onPreInit();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "runTick",
|
||||
at = @At(
|
||||
|
||||
@@ -29,7 +29,10 @@ import baritone.command.manager.CommandManager;
|
||||
import baritone.event.GameEventHandler;
|
||||
import baritone.process.*;
|
||||
import baritone.selection.SelectionManager;
|
||||
import baritone.utils.*;
|
||||
import baritone.utils.BlockStateInterface;
|
||||
import baritone.utils.GuiClick;
|
||||
import baritone.utils.InputOverrideHandler;
|
||||
import baritone.utils.PathingControlManager;
|
||||
import baritone.utils.player.PrimaryPlayerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -117,10 +120,6 @@ public class Baritone implements IBaritone {
|
||||
this.worldProvider = new WorldProvider();
|
||||
this.selectionManager = new SelectionManager(this);
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
||||
if (BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
this.gameEventHandler.registerEventListener(BaritoneAutoTest.INSTANCE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,183 +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;
|
||||
|
||||
import baritone.api.BaritoneAPI;
|
||||
import baritone.api.event.events.TickEvent;
|
||||
import baritone.api.event.listener.AbstractGameEventListener;
|
||||
import baritone.api.pathing.goals.Goal;
|
||||
import baritone.api.pathing.goals.GoalBlock;
|
||||
import baritone.api.utils.Helper;
|
||||
import baritone.api.utils.IPlayerContext;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.settings.AmbientOcclusionStatus;
|
||||
import net.minecraft.client.settings.CloudOption;
|
||||
import net.minecraft.client.settings.ParticleStatus;
|
||||
import net.minecraft.client.tutorial.TutorialSteps;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.HTTPUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
/**
|
||||
* Responsible for automatically testing Baritone's pathing algorithm by automatically creating a world with a specific
|
||||
* seed, setting a specified goal, and only allowing a certain amount of ticks to pass before the pathing test is
|
||||
* considered a failure. In order to test locally, docker may be used, or through an IDE: Create a run config which runs
|
||||
* in a separate directory from the primary one (./run), and set the enrivonmental variable {@code BARITONE_AUTO_TEST}
|
||||
* to {@code true}.
|
||||
*
|
||||
* @author leijurv, Brady
|
||||
*/
|
||||
public class BaritoneAutoTest implements AbstractGameEventListener, Helper {
|
||||
|
||||
public static final BaritoneAutoTest INSTANCE = new BaritoneAutoTest();
|
||||
|
||||
public static final boolean ENABLE_AUTO_TEST = "true".equals(System.getenv("BARITONE_AUTO_TEST"));
|
||||
private static final long TEST_SEED = -928872506371745L;
|
||||
private static final BlockPos STARTING_POSITION = new BlockPos(0, 65, 0);
|
||||
private static final Goal GOAL = new GoalBlock(69, 69, 420);
|
||||
private static final int MAX_TICKS = 3300;
|
||||
|
||||
/**
|
||||
* Called right after the {@link GameSettings} object is created in the {@link Minecraft} instance.
|
||||
*/
|
||||
public void onPreInit() {
|
||||
if (!BaritoneAutoTest.ENABLE_AUTO_TEST) {
|
||||
return;
|
||||
}
|
||||
System.out.println("Optimizing Game Settings");
|
||||
|
||||
GameSettings s = mc.gameSettings;
|
||||
s.framerateLimit = 20;
|
||||
s.mipmapLevels = 0;
|
||||
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.cloudOption = CloudOption.OFF;
|
||||
s.fancyGraphics = false;
|
||||
s.tutorialStep = TutorialSteps.NONE;
|
||||
s.hideGUI = true;
|
||||
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.currentScreen instanceof MainMenuScreen) {
|
||||
System.out.println("Beginning Baritone automatic test routine");
|
||||
mc.displayGuiScreen(null);
|
||||
WorldSettings worldsettings = new WorldSettings(TEST_SEED, GameType.SURVIVAL, true, false, WorldType.DEFAULT);
|
||||
mc.launchIntegratedServer("BaritoneAutoTest", "BaritoneAutoTest", worldsettings);
|
||||
}
|
||||
|
||||
IntegratedServer server = mc.getIntegratedServer();
|
||||
|
||||
// If the integrated server is launched and the world has initialized, set the spawn point
|
||||
// to our defined starting position
|
||||
if (server != null && server.getWorld(DimensionType.OVERWORLD) != null) {
|
||||
server.setDifficultyForAllWorlds(Difficulty.PEACEFUL, true);
|
||||
if (mc.player == null) {
|
||||
server.execute(() -> {
|
||||
server.getWorld(DimensionType.OVERWORLD).setSpawnPoint(STARTING_POSITION);
|
||||
server.getCommandManager().handleCommand(server.getCommandSource(), "/difficulty peaceful");
|
||||
int result = server.getCommandManager().handleCommand(server.getCommandSource(), "/gamerule spawnRadius 0");
|
||||
if (result != 0) {
|
||||
throw new IllegalStateException(result + "");
|
||||
}
|
||||
});
|
||||
for (final ServerWorld world : mc.getIntegratedServer().getWorlds()) {
|
||||
// If the world has initialized, set the spawn point to our defined starting position
|
||||
if (world != null) {
|
||||
// I would rather do this than try to mess with poz
|
||||
CompoundNBT nbt = world.getGameRules().write();
|
||||
nbt.putString("spawnRadius", "0");
|
||||
world.getGameRules().read(nbt);
|
||||
|
||||
world.setSpawnPoint(STARTING_POSITION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getType() == TickEvent.Type.IN) { // If we're in-game
|
||||
|
||||
// Force the integrated server to share the world to LAN so that
|
||||
// the ingame pause menu gui doesn't actually pause our game
|
||||
if (mc.isSingleplayer() && !mc.getIntegratedServer().getPublic()) {
|
||||
mc.getIntegratedServer().shareToLAN(GameType.SURVIVAL, false, HTTPUtil.getSuitableLanPort());
|
||||
}
|
||||
|
||||
// For the first 200 ticks, wait for the world to generate
|
||||
if (event.getCount() < 200) {
|
||||
System.out.println("Waiting for world to generate... " + event.getCount());
|
||||
return;
|
||||
}
|
||||
|
||||
// Print out an update of our position every 5 seconds
|
||||
if (event.getCount() % 100 == 0) {
|
||||
System.out.println(ctx.playerFeet() + " " + event.getCount());
|
||||
}
|
||||
|
||||
// Setup Baritone's pathing goal and (if needed) begin pathing
|
||||
if (!BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().isActive()) {
|
||||
BaritoneAPI.getProvider().getPrimaryBaritone().getCustomGoalProcess().setGoalAndPath(GOAL);
|
||||
}
|
||||
|
||||
// If we have reached our goal, print a message and safely close the game
|
||||
if (GOAL.isInGoal(ctx.playerFeet())) {
|
||||
System.out.println("Successfully pathed to " + ctx.playerFeet() + " in " + event.getCount() + " ticks");
|
||||
try {
|
||||
File file = new File("success");
|
||||
System.out.println("Writing success to " + file.getAbsolutePath());
|
||||
Files.write(file.getAbsoluteFile().toPath(), "Success!".getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mc.shutdown();
|
||||
mc.shutdownMinecraftApplet();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// If we have exceeded the expected number of ticks to complete the pathing
|
||||
// task, then throw an IllegalStateException to cause the build to fail
|
||||
if (event.getCount() > MAX_TICKS) {
|
||||
throw new IllegalStateException("took too long");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BaritoneAutoTest() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user