From 04aae206550e630d187dfacf81ad38ec3454a3a5 Mon Sep 17 00:00:00 2001 From: Brandon Houghton Date: Thu, 4 Feb 2021 00:24:57 -0800 Subject: [PATCH] Revert "human action space + enabled GUI (#449)" This reverts commit c70f6ccc3b28e170db405f81d7c743034a3e1fa4. --- minerl/Malmo/Minecraft/build.gradle | 5 +- .../Malmo/Client/ClientStateMachine.java | 12 +- .../microsoft/Malmo/Client/FakeKeyboard.java | 104 ------- .../com/microsoft/Malmo/Client/FakeMouse.java | 266 ------------------ .../Malmo/Client/FakeMouseCursor.java | 71 ----- .../Malmo/Client/MalmoModClient.java | 26 +- .../Malmo/Client/PostRenderEvent.java | 15 - .../com/microsoft/Malmo/Client/VideoHook.java | 34 +-- .../Launcher/tweakers/CoremodTweaker.java | 6 - .../java/com/microsoft/Malmo/MalmoMod.java | 4 - .../CameraCommandsImplementation.java | 45 ++- .../Malmo/MissionHandlers/CommandForKey.java | 107 +++---- .../MissionHandlers/MissionBehaviour.java | 4 - .../microsoft/Malmo/Mixins/MixinDisplay.java | 14 - .../microsoft/Malmo/Mixins/MixinKeyboard.java | 58 ---- .../Malmo/Mixins/MixinMinecraftGameloop.java | 59 ++-- .../microsoft/Malmo/Mixins/MixinMouse.java | 108 ------- .../Malmo/Mixins/MixinNoGuiInteract.java | 13 +- .../malmopack/mouse_cursor_white_16x16.png | Bin 1859 -> 0 bytes .../mixins.overclocking.malmomod.json | 6 +- minerl/Malmo/Schemas/Mission.xsd | 7 - .../env_specs/equip_weapon_specs.py | 74 ----- minerl/herobraine/env_specs/human_controls.py | 57 ---- .../env_specs/human_survival_specs.py | 54 ---- .../herobraine/env_specs/simple_embodiment.py | 4 +- minerl/herobraine/envs.py | 4 - .../hero/handlers/agent/actions/keyboard.py | 4 +- .../hero/handlers/agent/observations/pov.py | 4 +- .../herobraine/hero/handlers/agent/start.py | 32 --- 29 files changed, 120 insertions(+), 1077 deletions(-) delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeKeyboard.java delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouse.java delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouseCursor.java delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/PostRenderEvent.java delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinDisplay.java delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinKeyboard.java delete mode 100644 minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMouse.java delete mode 100644 minerl/Malmo/Minecraft/src/main/resources/assets/malmopack/mouse_cursor_white_16x16.png delete mode 100644 minerl/herobraine/env_specs/equip_weapon_specs.py delete mode 100644 minerl/herobraine/env_specs/human_controls.py delete mode 100644 minerl/herobraine/env_specs/human_survival_specs.py diff --git a/minerl/Malmo/Minecraft/build.gradle b/minerl/Malmo/Minecraft/build.gradle index de0fb0ff0..d8615b4f3 100755 --- a/minerl/Malmo/Minecraft/build.gradle +++ b/minerl/Malmo/Minecraft/build.gradle @@ -105,9 +105,8 @@ jar { // And add to the jvm args so that it is also loaded when running using gradle runClient: JavaExec exec = project.getTasks().getByName("runClient") -exec.jvmArgs(["-Dfml.coreMods.load=com.microsoft.Malmo.OverclockingPlugin","-Xmx2G", "-Xdebug", "-Dmixin.debug=true"]) -exec.args(["--tweakClass", "com.microsoft.Malmo.Launcher.tweakers.CoremodTweaker"]) -// exec.jvmArgs(["-Dfml.coreMods.load=com.microsoft.Malmo.OverclockingPlugin","-Xmx2G"]) +// exec.jvmArgs(["-Dfml.coreMods.load=com.microsoft.Malmo.OverclockingPlugin","-Xmx2G", "-Xdebug", "-Xrunjdwp:transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n"]) +exec.jvmArgs(["-Dfml.coreMods.load=com.microsoft.Malmo.OverclockingPlugin","-Xmx2G"]) // ForgeGradle automatically sets the runClient task's outputs to be the runDir above (eg "run"). This // means that gradle will helpfully try to take a snapshot of the complete contents of the run folder in order // to carry out up-to-date checks for any tasks that depend on runClient. diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java index 3710a5723..3460e0778 100755 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java @@ -1874,15 +1874,9 @@ protected void onMissionStarted() // Force brightness setting Minecraft.getMinecraft().gameSettings.gammaSetting = (float) 2.0; - - if (missionBehaviour.lowLevelInputs) { - Minecraft.getMinecraft().gameSettings.hideGUI = false; - Minecraft.getMinecraft().gameSettings.guiScale = 2; - Minecraft.getMinecraft().gameSettings.fancyGraphics = true; - } else { - // Disable the gui for the episode! - Minecraft.getMinecraft().gameSettings.hideGUI = true; - } + + // Disable the gui for the episode! + Minecraft.getMinecraft().gameSettings.hideGUI = true; for (IVideoProducer videoProducer : currentMissionBehaviour().videoProducers) { diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeKeyboard.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeKeyboard.java deleted file mode 100644 index 9738339ed..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeKeyboard.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.microsoft.Malmo.Client; - -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.HashSet; -import java.util.Set; - -public class FakeKeyboard { - - private static Deque eventQueue = new ArrayDeque(); - private static FakeKeyEvent currentEvent; - private static Set keysDown = new HashSet(); - - public static boolean next() { - currentEvent = eventQueue.poll(); - return currentEvent != null; - } - - public static int getEventKey() { - return currentEvent.key; - } - - public static char getEventCharacter() { - System.out.println("FakeKeyboard - getEventChar is called "); - return currentEvent.character; - } - - public static boolean getEventKeyState() { - return currentEvent.state; - } - - public static long getEventNanoseconds() { - return currentEvent.nanos; - } - - public static boolean isRepeatEvent() { - return currentEvent.repeat; - } - - public static final class FakeKeyEvent { - /** The current keyboard character being examined */ - private final char character; - - /** The current keyboard event key being examined */ - private final int key; - - /** The current state of the key being examined in the event queue */ - private final boolean state; - - /** The current event time */ - private long nanos; - - /** Is the current event a repeated event? */ - private boolean repeat; - - public FakeKeyEvent(char character, int key, boolean state, long nanos, boolean repeat) { - this.character = character; - this.key = key; - this.state = state; - this.nanos = nanos; - this.repeat = repeat; - } - - public FakeKeyEvent(char character, int key, boolean state) { - this(character, key, state, System.nanoTime(), false); - } - - public FakeKeyEvent(char character, int key) { - this(character, key, true); - } - - public FakeKeyEvent(int key) { - this((char) 0, key); - } - - } - - public static void press(int key) { - if (!keysDown.contains(key)) { - System.out.println("Pressed " + String.valueOf(key)); - add(new FakeKeyEvent(' ', key, true)); - } - } - - public static void release(int key) { - if (keysDown.contains(key)) { - System.out.println("Released " + String.valueOf(key)); - add(new FakeKeyEvent(' ', key, false)); - } - } - - public static void add(FakeKeyEvent event) { - eventQueue.add(event); - if (event.state) { - keysDown.add(event.key); - } else { - keysDown.remove(event.key); - } - } - - public static boolean isKeyDown(int key) { - return keysDown.contains(key); - } -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouse.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouse.java deleted file mode 100644 index a1d22c6e9..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouse.java +++ /dev/null @@ -1,266 +0,0 @@ -package com.microsoft.Malmo.Client; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.FolderResourcePack; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.client.resources.SimpleReloadableResourceManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.model.ModelLoader; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.HashSet; -import java.util.Set; - -public class FakeMouse { - private static int x; - private static int y; - private static int dx; - private static int dy; - private static int dwheel; - - private static int accumDx; - private static int accumDy; - private static int accumDwheel; - - private static Deque eventQueue = new ArrayDeque(); - private static FakeMouseEvent currentEvent; - private static Set pressedButtons = new HashSet(); - private static Set accumPressedButtons = new HashSet(); - - private static boolean grabbed = false; - private static boolean humanInput = true; - - // private static FakeMouseCursor cursor = new FakeMouseCursor(); - - - public static void setHumanInput(boolean humanInput) { - FakeMouse.humanInput = humanInput; - } - - public static boolean isHumanInput() { - return humanInput; - } - - public static JsonElement getState() { - JsonObject retVal = new JsonObject(); - retVal.addProperty("x", x); - retVal.addProperty("y", y); - retVal.addProperty("dx", accumDx); - retVal.addProperty("dy", accumDy); - retVal.addProperty("dwheel", accumDwheel); - retVal.add("buttons", new Gson().toJsonTree(FakeMouse.accumPressedButtons.toArray())); - accumPressedButtons.retainAll(pressedButtons); - accumDx = 0; - accumDy = 0; - accumDwheel = 0; - return retVal; - } - - public static class FakeMouseEvent { - private int button; - - private boolean state; - - private int dx; - private int dy; - private int dwheel; - - private int x; - private int y; - private long nanos; - - public FakeMouseEvent(int x, int y, int dx, int dy, int dwheel, int button, boolean state, long nanos) { - this.x = x; - this.y = y; - this.dx = dx; - this.dy = dy; - this.button = button; - this.dwheel = dwheel; - this.state = state; - this.nanos = nanos; - } - - public static FakeMouseEvent move(int dx, int dy) { - return new FakeMouseEvent((int) FakeMouse.x + dx, (int) FakeMouse.y + dy, dx, dy, 0, -1, false, System.nanoTime()); - } - } - - public static boolean next() { - currentEvent = eventQueue.poll(); - return currentEvent != null; - - } - - public static int getX() { - return (int) x; - } - - public static int getY() { - return (int) y; - } - - public static int getDX() { - int retval = dx; - dx = 0; - return retval; - } - - public static int getDY() { - int retval = dy; - dy = 0; - return retval; - } - - public static int getDWheel() { - int retval = dwheel; - dwheel = 0; - return retval; - } - - public static int getEventButton() { - if (currentEvent != null) { - return currentEvent.button; - } else { - return -1; - } - } - - public static boolean getEventButtonState() { - if (currentEvent != null) { - return currentEvent.state; - } else { - return false; - } - } - - public static int getEventX() { - return currentEvent.x; - } - - public static int getEventY() { - if (currentEvent != null) { - return currentEvent.y; - } else { - return 0; - } - } - - public static int getEventDX() { - if (currentEvent != null) { - return currentEvent.dx; - } else { - return 0; - } - } - - public static int getEventDY() { - if (currentEvent != null) { - return currentEvent.dy; - } else { - return 0; - } - } - - public static int getEventDWheel() { - if (currentEvent != null) { - return currentEvent.dwheel; - } else { - return 0; - } - } - - public static long getEventNanoseconds() { - if (currentEvent != null) { - return currentEvent.nanos; - } else { - return 0; - } - } - - public static void addEvent(FakeMouseEvent event) { - if (event.state) { - pressedButtons.add(event.button); - accumPressedButtons.add(event.button); - } else { - pressedButtons.remove(event.button); - } - dx += event.dx; - dy += event.dy; - accumDx += event.dx; - accumDy += event.dy; - x = event.x; - y = event.y; - eventQueue.add(event); - } - - public static void pressButton(int button) { - if (!pressedButtons.contains(button)) { - System.out.println("Button " + String.valueOf(button) + " is pressed"); - addEvent(new FakeMouseEvent(x, y, 0, 0, 0, button, true, System.nanoTime())); - } - } - - public static void releaseButton(int button) { - // TODO - match the press event and add dx, dy? Is that necessary? - if (pressedButtons.contains(button)) { - System.out.println("Button " + String.valueOf(button) + " is released"); - addEvent(new FakeMouseEvent(x, y, 0, 0, 0, button, false, System.nanoTime())); - } - } - - public static void addMovement(int dx, int dy) { - // split the movement into smaller, one-pixel movements - // to help drag-splitting calculator find the start of the trajectory - int stepX = (int) Math.signum(dx); - int stepY = (int) Math.signum(dy); - int curDx = 0; - int curDy = 0; - - while (curDx != dx || curDy != dy) { - if (curDx != dx) { - addEvent(FakeMouseEvent.move(stepX, 0)); - curDx += stepX; - } - if (curDy != dy) { - addEvent(FakeMouseEvent.move(0, stepY)); - curDy += stepY; - } - } - } - - public static boolean isButtonDown(int button) { - return pressedButtons.contains(button); - } - - - public static boolean isInsideWindow() { - return true; - } - - public static void setCursorPosition(int newX, int newY) { - x = newX; - y = newY; - } - - public static void setGrabbed(boolean grabbed) { - FakeMouse.grabbed = grabbed; - } - - public static boolean isGrabbed() { - return grabbed; - } -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouseCursor.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouseCursor.java deleted file mode 100644 index 741f1d761..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/FakeMouseCursor.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.microsoft.Malmo.Client; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.resources.FolderResourcePack; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.client.resources.SimpleReloadableResourceManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.GuiScreenEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -import java.io.File; - -public class FakeMouseCursor { - FakeMouseCursor() { - System.out.println("*** creating fake mouse cursor ***"); - register(); - } - - private void register() { - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onScreenDraw(GuiScreenEvent.DrawScreenEvent.Post event) { - GlStateManager.enableTexture2D(); - GlStateManager.disableLighting(); - GlStateManager.disableDepth(); - GuiScreen screen = event.getGui(); - if (screen == null) { - return; - } - GlStateManager.pushMatrix(); - bindTexture(); - GlStateManager.enableRescaleNormal(); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(516, 0.1F); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - screen.drawTexturedModalRect(event.getMouseX(), event.getMouseY(), 0, 0, 16, 16); - GlStateManager.disableAlpha(); - GlStateManager.disableRescaleNormal(); - GlStateManager.disableLighting(); - GlStateManager.popMatrix(); - - } - - - private static void bindTexture () { - TextureManager tm = Minecraft.getMinecraft().getTextureManager(); - IResourceManager rm = Minecraft.getMinecraft().getResourceManager(); - ResourceLocation texLocation = new ResourceLocation("malmopack:mouse_cursor_white_16x16.png"); - if (tm.getTexture(texLocation) == null) { - IResourcePack resourcePack = new FolderResourcePack(new File("../src/main/resources")); - ((SimpleReloadableResourceManager)rm).reloadResourcePack(resourcePack); - SimpleTexture texture = new SimpleTexture(texLocation); - tm.loadTexture(texLocation, texture); - } - tm.bindTexture(texLocation); - tm.getTexture(texLocation).setBlurMipmap(false, false); - } -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java index 36dd868a2..8ed5ad65d 100755 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java @@ -140,9 +140,7 @@ public void init(FMLInitializationEvent event) this.originalMouseHelper = Minecraft.getMinecraft().mouseHelper; this.mouseHook = new MouseHook(); this.mouseHook.isOverriding = true; - // TODO MouseHook is disabled. It is currently used in ObservationFromHumanImplementation - // which is decprectated? way of passing human-level commands and (may?) have been used for recording - // Minecraft.getMinecraft().mouseHelper = this.mouseHook; + Minecraft.getMinecraft().mouseHelper = this.mouseHook; setInputType(InputType.AI); } @@ -223,8 +221,8 @@ public void onRightClickEvent(PlayerInteractEvent.RightClickBlock event){ if (mc.objectMouseOver.typeOfHit.equals(RayTraceResult.Type.BLOCK)) { BlockPos blockpos = mc.objectMouseOver.getBlockPos(); IBlockState blockState = mc.world.getBlockState(blockpos); - if ((!isLowLevelInput()) && (blockState.getBlock() instanceof BlockContainer - || blockState.getBlock() instanceof BlockWorkbench)){ + if (blockState.getBlock() instanceof BlockContainer + || blockState.getBlock() instanceof BlockWorkbench){ event.setUseBlock(Event.Result.DENY); logger.log(Level.INFO, "Denied usage of " + blockState.getBlock().getRegistryName().toString()); } @@ -245,8 +243,20 @@ public void onRightClickEvent(PlayerInteractEvent.RightClickBlock event){ } } - public boolean isLowLevelInput() { - return stateMachine.currentMissionBehaviour().lowLevelInputs; - } + /** + * Event listener that logs when agents open gui windows + * @param event the captured event + */ + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onGuiOpenEvent(GuiOpenEvent event){ + if(this.stateMachine.getStableState() == ClientState.RUNNING){ + Logger logger = Logger.getLogger("MalmoModClient.onGuiOpenEvent"); + if (event != null && event.getGui() != null && !(event.getGui() instanceof GuiGameOver)) { + logger.log(Level.WARNING, "GUI Window " + event.getGui().getClass().getSimpleName() + " opened!"); + throw new AssertionError("GUI Window " + event.getGui().getClass().getSimpleName() + " opened!"); + } + } + } } diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/PostRenderEvent.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/PostRenderEvent.java deleted file mode 100644 index 291dc4cf3..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/PostRenderEvent.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.microsoft.Malmo.Client; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PostRenderEvent extends Event { - private float partialTicks; - - public PostRenderEvent(float partialTicks) { - this.partialTicks = partialTicks; - } - - public float getPartialTicks() { - return partialTicks; - } -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java index eda2da43c..9246e30b9 100755 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java @@ -29,7 +29,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.launchwrapper.Launch; -import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.common.MinecraftForge; @@ -159,7 +158,6 @@ public void start(MissionInit missionInit, IVideoProducer videoProducer, VideoPr this.connection = new TCPSocketChannel(agentIPAddress, agentPort, "vid"); this.failedTCPSendCount = 0; - try { MinecraftForge.EVENT_BUS.register(this); @@ -265,19 +263,16 @@ public void onRender(RenderTickEvent event) * Contains information about the event (not used). */ @SubscribeEvent - public void postRender(PostRenderEvent event) { -// // WHG: HAND RENDER -// // To render with hand convert RenderWorldLastEvent to RenderGameOverlayEvent.Pre -// // Then include the following lines -// if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) -// return; - float partialTicks = event.getPartialTicks(); - getVideo(partialTicks); - } + public void postRender(RenderWorldLastEvent event) + { + // WHG: HAND RENDER + // To render with hand convert RenderWorldLastEvent to RenderGameOverlayEvent.Pre + // Then include the following lines + // $ if(event.getType() != RenderGameOverlayEvent.ElementType.ALL) + // $ return; - private void getVideo(float partialTicks) { - // Check that the video producer and frame type match - eg if this is a - // colourmap frame, then + + // Check that the video producer and frame type match - eg if this is a colourmap frame, then // only the colourmap videoproducer needs to do anything. boolean colourmapFrame = TextureHelper.colourmapFrame; boolean colourmapVideoProducer = this.videoProducer.getVideoType() == VideoType.COLOUR_MAP; @@ -285,12 +280,11 @@ private void getVideo(float partialTicks) { return; EntityPlayerSP player = Minecraft.getMinecraft().player; - - float x = (float) (player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks); - float y = (float) (player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks); - float z = (float) (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks); - float yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * partialTicks; - float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; + float x = (float) (player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks()); + float y = (float) (player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks()); + float z = (float) (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks()); + float yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * event.getPartialTicks(); + float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.getPartialTicks(); long time_before_ns = System.nanoTime(); diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Launcher/tweakers/CoremodTweaker.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Launcher/tweakers/CoremodTweaker.java index 0d257b509..a01d6611f 100644 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Launcher/tweakers/CoremodTweaker.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Launcher/tweakers/CoremodTweaker.java @@ -24,7 +24,6 @@ import java.lang.reflect.Field; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; @@ -91,11 +90,6 @@ public void injectIntoClassLoader(LaunchClassLoader classLoader) } } } - - Field cleField = classLoader.getClass().getDeclaredField("classLoaderExceptions"); - cleField.setAccessible(true); - Set exceptions = (Set) cleField.get(classLoader); - exceptions.remove("org.lwjgl."); } catch (Throwable t) { diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java index a1dac5a01..303699fee 100755 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java @@ -488,8 +488,4 @@ public static void safeSendToAll(MalmoMessageType malmoMessage, Map @@ -89,7 +86,6 @@ public void press() public void release() { this.isDown = false; - FakeKeyboard.add(new FakeKeyEvent(' ', this.getKeyCode(), false)); } /** @@ -277,7 +273,6 @@ public void install(MissionInit missionInit) // Attempt to find the keybinding that matches the description we were given, // and replace it with our own KeyHook object: GameSettings settings = Minecraft.getMinecraft().gameSettings; - boolean createdHook = false; // GameSettings contains both a field for each KeyBinding (eg keyBindAttack), and an array of KeyBindings with a pointer to // each field. We want to make sure we replace both pointers, otherwise Minecraft will end up using our object for some things, and @@ -298,7 +293,7 @@ public void install(MissionInit missionInit) this.originalBinding = kb; this.keyHook = create(this.originalBinding); createdHook = true; - // f.set(settings, this.keyHook); + f.set(settings, this.keyHook); } } catch (IllegalArgumentException e) @@ -321,10 +316,9 @@ public void install(MissionInit missionInit) { this.originalBinding = settings.keyBindings[i]; this.keyHook = create(this.originalBinding); - setOverriding(false); createdHook = true; } - // settings.keyBindings[i] = this.keyHook; + settings.keyBindings[i] = this.keyHook; } } // And possibly in the hotbar array too: @@ -337,42 +331,41 @@ public void install(MissionInit missionInit) { this.originalBinding = settings.keyBindsHotbar[i]; this.keyHook = create(this.originalBinding); - setOverriding(false); createdHook = true; } - // settings.keyBindsHotbar[i] = this.keyHook; + settings.keyBindsHotbar[i] = this.keyHook; } } // Newer versions of MC have changed the way they map from key value to KeyBinding, so we // *also* need to fiddle with the static KeyBinding HASH map:_ -// Field[] kbfields = KeyBinding.class.getDeclaredFields(); -// for (Field f : kbfields) -// { -// if (f.getType() == KeyBindingMap.class) -// { -// net.minecraftforge.client.settings.KeyBindingMap kbp; -// try -// { -// f.setAccessible(true); -// kbp = (KeyBindingMap) (f.get(null)); -// // Our new keybinding should already have been added; -// // just need to remove the original one. -// while (kbp.lookupAll(this.keyHook.getKeyCode()).size() > 1) -// // kbp.removeKey(this.originalBinding); -// return; -// } -// catch (IllegalArgumentException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// catch (IllegalAccessException e) -// { -// // TODO Auto-generated catch block -// e.printStackTrace(); -// } -// } -// } + Field[] kbfields = KeyBinding.class.getDeclaredFields(); + for (Field f : kbfields) + { + if (f.getType() == KeyBindingMap.class) + { + net.minecraftforge.client.settings.KeyBindingMap kbp; + try + { + f.setAccessible(true); + kbp = (KeyBindingMap) (f.get(null)); + // Our new keybinding should already have been added; + // just need to remove the original one. + while (kbp.lookupAll(this.keyHook.getKeyCode()).size() > 1) + kbp.removeKey(this.originalBinding); + return; + } + catch (IllegalArgumentException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IllegalAccessException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } @Override @@ -386,42 +379,8 @@ public void deinstall(MissionInit missionInit) @Override public boolean onExecute(String verb, String parameter, MissionInit missionInit) { - // The keyboard-related actions are now injected via FakeKeyboard class - // Rationale - injection can happen in any phase of the game (including the parts where normal minecraft - // bindings are bypassed, like in GUI - // TODO clean up unused code (e.g. currently the keyHooks are only used for storing the bindings) - // return (this.keyHook != null) ? this.keyHook.execute(verb, parameter) : false; - - if (verb != null && verb.equalsIgnoreCase(keyHook.getCommandString())) { - if (verb.equals("attack")) { - // imitate right mouse button click - if (parameter != null && parameter.equalsIgnoreCase(DOWN_COMMAND_STRING)) { - FakeMouse.pressButton(0); - } else if (parameter != null && parameter.equalsIgnoreCase(UP_COMMAND_STRING)) { - FakeMouse.releaseButton(0); - } else { - return false; - } - } else if (verb.equals("use")) { - // imitate right mouse button click - if (parameter != null && parameter.equalsIgnoreCase(DOWN_COMMAND_STRING)) { - FakeMouse.pressButton(1); - } else if (parameter != null && parameter.equalsIgnoreCase(UP_COMMAND_STRING)) { - FakeMouse.releaseButton(1); - } else { - return false; - } - } - if (parameter != null && parameter.equalsIgnoreCase(DOWN_COMMAND_STRING)) { - FakeKeyboard.press(keyHook.getKeyCode()); - } else if (parameter != null && parameter.equalsIgnoreCase(UP_COMMAND_STRING)) { - FakeKeyboard.release(keyHook.getKeyCode()); - } else { - return false; - } - return true; - } - return false; + // Our keyhook does all the work: + return (this.keyHook != null) ? this.keyHook.execute(verb, parameter) : false; } /** Return the KeyBinding object we are using.
diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionBehaviour.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionBehaviour.java index a3bf94fcf..92591c02b 100755 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionBehaviour.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionBehaviour.java @@ -52,7 +52,6 @@ public class MissionBehaviour public IWorldGenerator worldGenerator = null; public IPerformanceProducer performanceProducer = null; public IWantToQuit quitProducer = null; - public boolean lowLevelInputs = false; private String failedHandlers = ""; @@ -117,9 +116,6 @@ private void initAgent(MissionInit missionInit) List agents = missionInit.getMission().getAgentSection(); if (agents != null && agents.size() > 1) addHandler(new RewardFromTeamImplementation()); - // TODO hack - low level inputs are read from first agent. Ideally they should be either agent-specific, - // or mission-level - lowLevelInputs = agents.get(0).getAgentStart().isLowLevelInputs() != null && agents.get(0).getAgentStart().isLowLevelInputs(); } public boolean addExtraHandlers(List handlers) diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinDisplay.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinDisplay.java deleted file mode 100644 index 48500b8bf..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinDisplay.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.microsoft.Malmo.Mixins; - -import org.lwjgl.opengl.Display; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -@Mixin(Display.class) -public abstract class MixinDisplay { - - @Overwrite - public static boolean isActive() { - return true; - } -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinKeyboard.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinKeyboard.java deleted file mode 100644 index 4e2f8e428..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinKeyboard.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.microsoft.Malmo.Mixins; - -import org.lwjgl.input.Keyboard; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import com.microsoft.Malmo.Client.FakeKeyboard; - -@Mixin(Keyboard.class) -public abstract class MixinKeyboard { - - @Overwrite(remap = false) - public static boolean isCreated() { - return true; - } - - @Overwrite(remap = false) - public static void poll() { - - } - - @Overwrite(remap = false) - public static boolean isKeyDown(int key) { - return FakeKeyboard.isKeyDown(key); - } - - @Overwrite(remap = false) - public static boolean next() { - return FakeKeyboard.next(); - } - - @Overwrite(remap = false) - public static int getEventKey() { - return FakeKeyboard.getEventKey(); - } - - @Overwrite(remap = false) - public static char getEventCharacter() { - return FakeKeyboard.getEventCharacter(); - } - - @Overwrite(remap = false) - public static boolean getEventKeyState() { - return FakeKeyboard.getEventKeyState(); - } - - @Overwrite(remap = false) - public static long getEventNanoseconds() { - return FakeKeyboard.getEventNanoseconds(); - } - - @Overwrite(remap = false) - public static boolean isRepeatEvent() { - return FakeKeyboard.isRepeatEvent(); - } - - -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMinecraftGameloop.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMinecraftGameloop.java index 048c91659..981340b36 100644 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMinecraftGameloop.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMinecraftGameloop.java @@ -1,18 +1,18 @@ package com.microsoft.Malmo.Mixins; import java.io.IOException; +import java.util.List; import java.util.Queue; import java.util.concurrent.FutureTask; -import com.microsoft.Malmo.Client.FakeMouse; +import com.microsoft.Malmo.Utils.TimeHelper; + import org.lwjgl.opengl.Display; +import org.lwjgl.util.glu.GLU; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; -import com.microsoft.Malmo.Client.PostRenderEvent; -import com.microsoft.Malmo.Utils.TimeHelper; - +import akka.actor.FSM.TimeoutMarker; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.SoundHandler; import net.minecraft.client.entity.EntityPlayerSP; @@ -26,17 +26,15 @@ import net.minecraft.client.renderer.chunk.RenderChunk; import net.minecraft.client.settings.GameSettings; import net.minecraft.client.shader.Framebuffer; -import net.minecraft.network.NetworkManager; import net.minecraft.profiler.Profiler; +import net.minecraft.network.NetworkManager; import net.minecraft.profiler.Snooper; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.util.FrameTimer; import net.minecraft.util.Timer; import net.minecraft.util.Util; -import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.gameevent.TickEvent.Phase; -import scala.collection.parallel.ParIterableLike; @Mixin(Minecraft.class) public abstract class MixinMinecraftGameloop { @@ -78,12 +76,6 @@ public abstract class MixinMinecraftGameloop { @Shadow public Snooper usageSnooper; @Shadow public abstract int getLimitFramerate(); @Shadow public abstract boolean isFramerateLimitBelowMax(); - - @Shadow public boolean inGameHasFocus; - @Shadow private int leftClickCounter; - - @Shadow public abstract void displayGuiScreen(GuiScreen guiScreen); - private int numTicksPassed = 0; @@ -171,9 +163,11 @@ private void runGameLoop() throws IOException //Speeds up rendering; though it feels necessary. s + if(!TimeHelper.SyncManager.isSynchronous()){ GlStateManager.pushMatrix(); GlStateManager.clear(16640); this.framebufferMc.bindFramebuffer(true); + } this.mcProfiler.startSection("display"); GlStateManager.enableTexture2D(); @@ -185,8 +179,6 @@ private void runGameLoop() throws IOException net.minecraftforge.fml.common.FMLCommonHandler.instance().onRenderTickStart(this.timer.renderPartialTicks); this.mcProfiler.endStartSection("gameRenderer"); this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks, i); - Minecraft mc = Minecraft.getMinecraft(); - MinecraftForge.EVENT_BUS.post(new PostRenderEvent(this.timer.renderPartialTicks)); this.mcProfiler.endSection(); net.minecraftforge.fml.common.FMLCommonHandler.instance().onRenderTickEnd(this.timer.renderPartialTicks); } @@ -209,15 +201,19 @@ private void runGameLoop() throws IOException this.prevFrameTime = System.nanoTime(); } - this.guiAchievement.updateAchievementWindow(); - this.framebufferMc.unbindFramebuffer(); - GlStateManager.popMatrix(); - GlStateManager.pushMatrix(); - this.framebufferMc.framebufferRender(this.displayWidth, this.displayHeight); - GlStateManager.popMatrix(); - GlStateManager.pushMatrix(); - this.entityRenderer.renderStreamIndicator(this.timer.renderPartialTicks); - GlStateManager.popMatrix(); + // Speeds up rendering! + if(!TimeHelper.SyncManager.isSynchronous()){ + // TODO: IF WE WANT TO ENABLE AGENT GUI WE SHOULD LET THIS CODE RUN + this.guiAchievement.updateAchievementWindow(); + this.framebufferMc.unbindFramebuffer(); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + this.framebufferMc.framebufferRender(this.displayWidth, this.displayHeight); + GlStateManager.popMatrix(); + GlStateManager.pushMatrix(); + this.entityRenderer.renderStreamIndicator(this.timer.renderPartialTicks); + GlStateManager.popMatrix(); + } this.mcProfiler.startSection("root"); TimeHelper.updateDisplay(); @@ -268,15 +264,4 @@ private void runGameLoop() throws IOException this.mcProfiler.endSection(); //root } - - @Overwrite - public void setIngameFocus() - { - if (!this.inGameHasFocus) { - this.inGameHasFocus = true; - this.displayGuiScreen((GuiScreen) null); - this.leftClickCounter = 10000; - } - } - -} +} \ No newline at end of file diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMouse.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMouse.java deleted file mode 100644 index d6ad393cc..000000000 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinMouse.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.microsoft.Malmo.Mixins; - -import org.lwjgl.input.Mouse; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; - -import com.microsoft.Malmo.Client.FakeMouse; - -@Mixin(Mouse.class) -public abstract class MixinMouse { - @Overwrite(remap = false) - public static boolean isCreated() { - return true; - } - - @Overwrite(remap = false) - public static void poll() { - - } - - @Overwrite(remap = false) - public static void setGrabbed(boolean grabbed) { - FakeMouse.setGrabbed(grabbed); - } - - @Overwrite(remap = false) - public static boolean next() { - return FakeMouse.next(); - } - - @Overwrite(remap = false) - public static int getX() { - return FakeMouse.getX(); - } - - @Overwrite(remap = false) - public static int getY() { - return FakeMouse.getY(); - } - - @Overwrite(remap = false) - public static int getDX() { - return FakeMouse.getDX(); - } - - @Overwrite(remap = false) - public static int getDY() { - return FakeMouse.getDY(); - } - - @Overwrite(remap = false) - public static int getEventButton() { - return FakeMouse.getEventButton(); - } - - @Overwrite(remap = false) - public static boolean getEventButtonState() { - return FakeMouse.getEventButtonState(); - } - - @Overwrite(remap = false) - public static int getEventX() { - return FakeMouse.getEventX(); - } - - @Overwrite(remap = false) - public static int getEventY() { - return FakeMouse.getEventY(); - } - - @Overwrite(remap = false) - public static int getEventDX() { - return FakeMouse.getEventDX(); - } - - @Overwrite(remap = false) - public static int getEventDY() { - return FakeMouse.getEventDY(); - } - - @Overwrite(remap = false) - public static int getEventDWheel() { - return FakeMouse.getEventDWheel(); - } - - @Overwrite(remap = false) - public static long getEventNanoseconds() { - return FakeMouse.getEventNanoseconds(); - } - - @Overwrite(remap = false) - public static boolean isButtonDown(int button) { - return FakeMouse.isButtonDown(button); - } - - @Overwrite(remap = false) - public static boolean isInsideWindow() { - return FakeMouse.isInsideWindow(); - } - - @Overwrite(remap = false) - public static void setCursorPosition(int newX, int newY) { - FakeMouse.setCursorPosition(newX, newY); - } - - - -} diff --git a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinNoGuiInteract.java b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinNoGuiInteract.java index 62de05a80..9e2cea897 100644 --- a/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinNoGuiInteract.java +++ b/minerl/Malmo/Minecraft/src/main/java/com/microsoft/Malmo/Mixins/MixinNoGuiInteract.java @@ -1,7 +1,5 @@ package com.microsoft.Malmo.Mixins; -import com.microsoft.Malmo.Client.MalmoModClient; -import com.microsoft.Malmo.MalmoMod; import net.minecraft.block.*; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.multiplayer.PlayerControllerMP; @@ -36,9 +34,6 @@ @Mixin(PlayerControllerMP.class) public abstract class MixinNoGuiInteract { private void catchGuiEntity(Entity target, CallbackInfoReturnable cir) { - if (MalmoMod.isLowLevelInput()) { - return; - } if (target instanceof EntityVillager || target instanceof EntityMinecartContainer || target instanceof EntityMinecartFurnace @@ -49,9 +44,6 @@ private void catchGuiEntity(Entity target, CallbackInfoReturnable cir) { - if (MalmoMod.isLowLevelInput()) { - return; - } if (target instanceof ItemSign || target instanceof ItemBook) { cir.setReturnValue(EnumActionResult.PASS); @@ -80,9 +72,6 @@ private void onInteractWithEntity2(EntityPlayer player, Entity target, RayTraceR @Inject(method = "processRightClickBlock", at = @At("HEAD"), cancellable = true) private void onProcessRightClickBlock(EntityPlayerSP player, WorldClient worldIn, BlockPos stack, EnumFacing pos, Vec3d facing, EnumHand vec, CallbackInfoReturnable cir) { - if (MalmoMod.isLowLevelInput()) { - return; - } Block block = worldIn.getBlockState(stack).getBlock(); if (block instanceof BlockContainer || block instanceof BlockAnvil @@ -97,4 +86,6 @@ private void onProcessRightClickBlock(EntityPlayerSP player, WorldClient worldIn private void onProcessRightClick(EntityPlayer player, World worldIn, EnumHand stack, CallbackInfoReturnable cir) { catchGuiItem(player.getHeldItem(stack).getItem(), cir); } + + } diff --git a/minerl/Malmo/Minecraft/src/main/resources/assets/malmopack/mouse_cursor_white_16x16.png b/minerl/Malmo/Minecraft/src/main/resources/assets/malmopack/mouse_cursor_white_16x16.png deleted file mode 100644 index def065b872bdebf2f3342eb2e5041b8d3c4733e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1859 zcmd^9{X5eO8~=_B$uV;@Y}!P$hU17rv3Z>-%X_kkFmFe-4Z}e@6weMPFGJf(QG{n5 zN+y)Ij+B>4<~4aM7SX{}izsLPaIWk5AD+*B-Ph;7?)#_vzOT>ccMl?7b*Iiw002}8 zu1;P60Fsp;KnW}(GQBDs0OaF;_3@AMI+K8+($9xS#ZXXjNmL4ok{Bf$CXWAog_JXQ zXqWSLeU`Dk!M=QQ&J7$RPdwklXnM$x0CNqnpdJ^3IqB`}9>TKO_LtZUER|-AF8|Z7 zxsZiPqSt8oAH7>w$<2|{28LV5I&8x}rk{R}Elg_hJ=5P0vj~(*qt(XyL9fIM>b!m; zW6pNZNj69S^&oLHc6BKuptUgeYvVMfxOMtQfx{p9uTNO5{>V-gq`0s@oNN$Bs%rGp z*mS|iz_wKkh*=So5@vY9nuyQ6-*b(~xxRKSaM^5&tuE2!wS^1b{~&R1tIw>q>|cyN z0HPP&slub5DQUpx3TNxnNs?ZzCEAg5*_I3s`2PBgvDKL;9x0x;?2C5ym8}frhrH>| zy3tgJIHWe&Akx z(-h?TObkHv7%t`pD2NK7!oibQq-3MB?i2Q$-IxZ5^O8`N_uvrt%6{Eg>km;+ zC2|mLl2h8#+j4$x)|&4RcR=}i$B5SRY)g`qoL%TcM?3f0Rr0e8`vQE1hw88T-;e1W z5>D{zRB~z&&5aM6lB<;hyff}*ZD?jbbq|PcDyrza+Av<5^6O#~r)KiuXPd;Xc6Er0 zwoS}>Re|9Z(eZ=*=JDenPr*jU*+qV*Devx!?@SGu^6w5!b$`986F9UE)X%>w&=K<0 zV1nF&W?q_>ksNJu$Gy^|gV`=l4 zv&dr$-&E*l$~GOAk2D}X;Ge9{i2*@^o<*lJdh9|hp;DxU?9Eij)wE46Xe}S}sk2`kxW-2}_K5o$^O?;*^C^JnS?Si&ShO{kgQy|`bz;~f45w*5$S zr;w6G@0eeX6c0x7_uXnW=>%WPpQwt*#94$ya;TI$ppwN##q9^%R$u-%rfr~G81d`# zwZ-F7;*^S^OpTYK934Ffj*kBdP$s+L)O=gl4jiI0h;)0eW(EU7>+-n%Co5~A!gs$z zh6hHl7)*Z$vxsu_A|n(=(=Q^keHCF5fx2V``&IcT-2;RHXSb~&uSoUT$29EJWb#Cd z{MILP@4lR$al^*?MJyHGdp;z^St(U16kG;9_{rMy_+POplO4}SA8GZk*?pd0@T42c zr^rc+2UW8ZFD6D0imX>O@cy1&tp4BeyB?w>`lA%iv=s~?{UBuJ6Z9rT`tVW(?NT8h#pE~@ zq60g#?o98VJCK$i3ev2~LtxjDTgxND6MsA++_ZYJ5%LP@h@-+HhhjE2#~#3qa5LJC zqJVF1y4-IDEhC~^c-+b%Ds56UXFEezTwsd!Inv7kccz_MbIHJAO4_Q)izR>D-^b@BB-DSFuJFQ{*qK-K!3JUZcV7gD9K$=wScVP9M@$(hQ(aHR z0)VOh_XH*0#xi70#W;eyv*O$?=#Qpo<79ZB?2~N-Cwm{6XO90&?7%@3Uhr@prKLCD zASSkVA}BRxXjg+?TA_u-?B@f=mZG!Tn4>wY1^`wTym6av zcUd_Tj7yll^xJjh+atzasO3xT1Ki+5`Nr{`X?&=hSrh1Jq?}P%deWK*I0rMoyVQPK zr@h7S#iZhF`gIGy9bilVBkrYq3t;S}Zu^(O;Ji^IIXUiy9bLleKqPk$z}q1CVo4E9 z{q&btO1`v)N+N={0>7okH$(&S;xZ4a+V=zeA7K^y{89M%Vhyk@`uo-dXQES$LvZ>( DLE82} diff --git a/minerl/Malmo/Minecraft/src/main/resources/mixins.overclocking.malmomod.json b/minerl/Malmo/Minecraft/src/main/resources/mixins.overclocking.malmomod.json index 9e9564d38..48c059eed 100644 --- a/minerl/Malmo/Minecraft/src/main/resources/mixins.overclocking.malmomod.json +++ b/minerl/Malmo/Minecraft/src/main/resources/mixins.overclocking.malmomod.json @@ -8,10 +8,6 @@ "MixinMinecraftServerRun", "MixinNoGuiInteract", "MixinRandomSkinTexture", - "MixinWorldProviderSpawn", - "MixinKeyboard", - "MixinMouse", - "MixinDisplay", "MixinSyncClientStats", "MixinWorldProviderSpawn" ], @@ -22,4 +18,4 @@ "compatibilityLevel": "JAVA_8", "minVersion": "0.6.11", "refmap": "mixins.malmo.refmap.json" -} +} \ No newline at end of file diff --git a/minerl/Malmo/Schemas/Mission.xsd b/minerl/Malmo/Schemas/Mission.xsd index c5097e9f3..7dd0b2d80 100755 --- a/minerl/Malmo/Schemas/Mission.xsd +++ b/minerl/Malmo/Schemas/Mission.xsd @@ -235,13 +235,6 @@ - - - - If set to true, inputs to malmo are disabled and instead given via a virtual keyboard and mouse (instead of higher level commands) - - - diff --git a/minerl/herobraine/env_specs/equip_weapon_specs.py b/minerl/herobraine/env_specs/equip_weapon_specs.py deleted file mode 100644 index 6495a21af..000000000 --- a/minerl/herobraine/env_specs/equip_weapon_specs.py +++ /dev/null @@ -1,74 +0,0 @@ -from minerl.herobraine.env_specs.human_controls import HumanControlEnvSpec -from minerl.herobraine.hero.mc import MS_PER_STEP, STEPS_PER_MS, ALL_ITEMS -from minerl.herobraine.hero.handler import Handler -import minerl.herobraine.hero.handlers as handlers -from typing import List - -import minerl.herobraine -import minerl.herobraine.hero.handlers as handlers -from minerl.herobraine.env_spec import EnvSpec - -EPISODE_LENGTH = 1200 -WEAPON = "iron_axe" - - -class EquipWeapon(HumanControlEnvSpec): - def __init__(self, hotbar=True, *args, **kwargs): - self.hotbar = hotbar - if "name" not in kwargs: - kwargs["name"] = "MineRLEquipWeapon-v0" - - super().__init__( - *args, max_episode_steps=EPISODE_LENGTH, reward_threshold=64.0, **kwargs - ) - - def create_rewardables(self) -> List[Handler]: - return [ - # handlers.RewardForPickingItemInInventory([dict(type=WEAPON, reward=1.0)]) - # handlers.RewardForEquippingItem([dict(type=WEAPON, reward=5.0)]) - ] - - def create_agent_start(self) -> List[Handler]: - return super().create_agent_start() + \ - [handlers.RandomInventoryAgentStart({WEAPON: 1}, use_hotbar=self.hotbar)] - - def create_observables(self) -> List[Handler]: - return super().create_observables() + [ - handlers.EquippedItemObservation( - items=ALL_ITEMS, mainhand=True, _default="air", _other="air" - ), - ] - - def create_agent_handlers(self) -> List[Handler]: - return [ - # handlers.AgentQuitFromEquippingItem([ - # dict(type=WEAPON)] - # ) - ] - - def create_server_world_generators(self) -> List[Handler]: - return [handlers.DefaultWorldGenerator(force_reset=True)] - - def create_server_quit_producers(self) -> List[Handler]: - return [ - handlers.ServerQuitFromTimeUp((EPISODE_LENGTH * MS_PER_STEP)), - handlers.ServerQuitWhenAnyAgentFinishes(), - ] - - def create_server_decorators(self) -> List[Handler]: - return [] - - def create_server_initial_conditions(self) -> List[Handler]: - return [ - handlers.TimeInitialCondition(allow_passage_of_time=False), - handlers.SpawningInitialCondition(allow_spawning=True), - ] - - def determine_success_from_rewards(self, rewards: list) -> bool: - return sum(rewards) >= self.reward_threshold - - def is_from_folder(self, folder: str) -> bool: - return False - - def get_docstring(self): - return "" diff --git a/minerl/herobraine/env_specs/human_controls.py b/minerl/herobraine/env_specs/human_controls.py deleted file mode 100644 index 7ca489dfc..000000000 --- a/minerl/herobraine/env_specs/human_controls.py +++ /dev/null @@ -1,57 +0,0 @@ -import abc -from abc import ABC -from minerl.herobraine.hero.handlers.translation import TranslationHandler -from minerl.herobraine.hero.handler import Handler - -from minerl.herobraine.hero import handlers -from minerl.herobraine.hero.handlers import POVObservation, CameraAction, KeybasedCommandAction -from minerl.herobraine.hero.mc import INVERSE_KEYMAP -from minerl.herobraine.env_spec import EnvSpec - -from typing import List - -KEYBOARD_ACTIONS = [ - "forward", - "back", - "left", - "right", - "jump", - "sneak", - "sprint", - "attack", - "use", - "drop", - "inventory" -] - - -class HumanControlEnvSpec(EnvSpec, ABC): - """ - A simple base environment from which all other simple envs inherit. - """ - - def __init__(self, name, *args, resolution=(640, 480), **kwargs): - self.resolution = resolution - super().__init__(name, *args, **kwargs) - - def create_observables(self) -> List[TranslationHandler]: - return [ - POVObservation(self.resolution), - ] - - def create_actionables(self) -> List[TranslationHandler]: - """ - Simple envs have some basic keyboard control functionality, but - not all. - """ - return [ - KeybasedCommandAction(k, INVERSE_KEYMAP[k]) for k in KEYBOARD_ACTIONS - ] + [ - KeybasedCommandAction(f"hotbar.{i}", INVERSE_KEYMAP[str(i)]) for i in range(1, 10) - ] + [CameraAction()] - - def create_monitors(self) -> List[TranslationHandler]: - return [] # No monitors by default!o - - def create_agent_start(self) -> List[Handler]: - return [handlers.LowLevelInputsAgentStart()] diff --git a/minerl/herobraine/env_specs/human_survival_specs.py b/minerl/herobraine/env_specs/human_survival_specs.py deleted file mode 100644 index 7129a79da..000000000 --- a/minerl/herobraine/env_specs/human_survival_specs.py +++ /dev/null @@ -1,54 +0,0 @@ -from minerl.herobraine.env_specs.human_controls import HumanControlEnvSpec -from minerl.herobraine.hero.mc import MS_PER_STEP, STEPS_PER_MS, ALL_ITEMS -from minerl.herobraine.hero.handler import Handler -import minerl.herobraine.hero.handlers as handlers -from typing import List - -import minerl.herobraine -import minerl.herobraine.hero.handlers as handlers -from minerl.herobraine.env_spec import EnvSpec - - -class HumanSurvival(HumanControlEnvSpec): - def __init__(self, *args, **kwargs): - if "name" not in kwargs: - kwargs["name"] = "MineRLHumanSurvival-v0" - super().__init__( - *args, **kwargs - ) - - def create_rewardables(self) -> List[Handler]: - return [] - - def create_agent_start(self) -> List[Handler]: - return super().create_agent_start() - - def create_agent_handlers(self) -> List[Handler]: - return [] - - def create_server_world_generators(self) -> List[Handler]: - return [handlers.DefaultWorldGenerator(force_reset=True)] - - def create_server_quit_producers(self) -> List[Handler]: - return [ - # handlers.ServerQuitFromTimeUp((EPISODE_LENGTH * MS_PER_STEP)), - handlers.ServerQuitWhenAnyAgentFinishes(), - ] - - def create_server_decorators(self) -> List[Handler]: - return [] - - def create_server_initial_conditions(self) -> List[Handler]: - return [ - handlers.TimeInitialCondition(allow_passage_of_time=True), - handlers.SpawningInitialCondition(allow_spawning=True), - ] - - def determine_success_from_rewards(self, rewards: list) -> bool: - return True - - def is_from_folder(self, folder: str) -> bool: - return True - - def get_docstring(self): - return "" diff --git a/minerl/herobraine/env_specs/simple_embodiment.py b/minerl/herobraine/env_specs/simple_embodiment.py index 63b278706..33d1a17ff 100644 --- a/minerl/herobraine/env_specs/simple_embodiment.py +++ b/minerl/herobraine/env_specs/simple_embodiment.py @@ -12,7 +12,7 @@ from typing import List -SIMPLE_KEYBOARD_ACTION = [ +SIMPLE_KEYBOARD_ACITON = [ "forward", "back", "left", @@ -45,7 +45,7 @@ def create_actionables(self) -> List[TranslationHandler]: """ return [ handlers.KeybasedCommandAction(k, v) for k, v in INVERSE_KEYMAP.items() - if k in SIMPLE_KEYBOARD_ACTION + if k in SIMPLE_KEYBOARD_ACITON ] + [ handlers.CameraAction() ] diff --git a/minerl/herobraine/envs.py b/minerl/herobraine/envs.py index be24f7f86..6ccdde219 100644 --- a/minerl/herobraine/envs.py +++ b/minerl/herobraine/envs.py @@ -7,8 +7,6 @@ from minerl.herobraine.env_spec import EnvSpec from minerl.herobraine.env_specs.treechop_specs import Treechop -from minerl.herobraine.env_specs.equip_weapon_specs import EquipWeapon -from minerl.herobraine.env_specs.human_survival_specs import HumanSurvival from minerl.herobraine.env_specs.navigate_specs import Navigate from minerl.herobraine.env_specs.obtain_specs import ObtainDiamond, ObtainDiamondSurvival, ObtainIronPickaxe, Obtain, \ ObtainDiamondDebug @@ -31,8 +29,6 @@ MINERL_OBTAIN_IRON_PICKAXE_V0 = ObtainIronPickaxe(dense=False) MINERL_OBTAIN_IRON_PICKAXE_DENSE_V0 = ObtainIronPickaxe(dense=True) -MINERL_EQUIP_WEAPON_V0 = EquipWeapon() -MINERL_HUMAN_SURVIVAL_V0 = HumanSurvival() # # prototype envs # # TODO: Actually make these work and correct, it'll be good to release these. # MINERL_OBTAIN_MEAT_V0 = Obtain(target_item='meat', dense=False, reward_schedule={ diff --git a/minerl/herobraine/hero/handlers/agent/actions/keyboard.py b/minerl/herobraine/hero/handlers/agent/actions/keyboard.py index 8d8c7965f..80eff938c 100644 --- a/minerl/herobraine/hero/handlers/agent/actions/keyboard.py +++ b/minerl/herobraine/hero/handlers/agent/actions/keyboard.py @@ -61,7 +61,7 @@ def __init__(self, command, *keys): self.keys = keys def from_universal(self, x): - actions_mapped = set(str(k) for k in x['custom_action']['actions']['keys']) + actions_mapped = list(x['custom_action']['actions'].keys()) offset = self.space.begin if isinstance(self.space, spaces.DiscreteRange) else 0 default = 0 @@ -98,7 +98,7 @@ def from_universal(self, x): # return "keyboard" # def __init__(self, keymap : typing.Dict[str, str]): -# """Initializes the keyboard action object with a keymap +# """Initializes the keyboard action object with a keymap between # Anvil rendered keypress ID's and Malmo command actions corresponding to the human level commands object. # Args: diff --git a/minerl/herobraine/hero/handlers/agent/observations/pov.py b/minerl/herobraine/hero/handlers/agent/observations/pov.py index b19311837..29234fa54 100644 --- a/minerl/herobraine/hero/handlers/agent/observations/pov.py +++ b/minerl/herobraine/hero/handlers/agent/observations/pov.py @@ -40,8 +40,8 @@ def __init__(self, video_resolution: Tuple[int, int], include_depth: bool = Fals self.video_depth = 3 # TODO (R): FIGURE THIS THE FUCK OUT & Document it. - self.video_height = video_resolution[1] - self.video_width = video_resolution[0] + self.video_height = video_resolution[0] + self.video_width = video_resolution[1] super().__init__( hero_keys=["pov"], diff --git a/minerl/herobraine/hero/handlers/agent/start.py b/minerl/herobraine/hero/handlers/agent/start.py index 4d1ace19f..790e9a146 100644 --- a/minerl/herobraine/hero/handlers/agent/start.py +++ b/minerl/herobraine/hero/handlers/agent/start.py @@ -4,7 +4,6 @@ """Defines the agent start conditions""" from minerl.herobraine.hero.handler import Handler from typing import Dict, List, Union -import random import jinja2 @@ -80,29 +79,6 @@ def __init__(self, inventory : List[Dict[str, Union[str, int]]]): }) -class RandomInventoryAgentStart(InventoryAgentStart): - """ An inventory agentstart specification which - that fills - """ - def __init__(self, inventory: Dict[str, Union[str, int]], use_hotbar: bool = False): - """ Creates an inventory where items are placed in random positions - - For example: - - rias = RandomInventoryAgentStart({'dirt': 10, 'planks': 5}) - """ - self.inventory = inventory - self.slot_range = (0, 36) if use_hotbar else (10, 36) - - def xml_template(self) -> str: - lines = [''] - for item, quantity in self.inventory.items(): - slot = random.randint(*self.slot_range) - lines.append(f'') - lines.append('') - return '\n'.join(lines) - - class AgentStartBreakSpeedMultiplier(Handler): def to_string(self) -> str: return f"agent_start_break_speed_multiplier({self.multiplier})" @@ -210,11 +186,3 @@ def __init__(self, food: int = 20, food_saturation: float = None): """ self.food = food self.food_saturation = food_saturation - - -class LowLevelInputsAgentStart(Handler): - def to_string(self) -> str: - return "low_level_inputs" - - def xml_template(self) -> str: - return "true"