From 654f4828b171f7fc2e58e1a78fb3f24774ad2885 Mon Sep 17 00:00:00 2001 From: Brandon Houghton Date: Tue, 18 Aug 2020 01:03:30 -0700 Subject: [PATCH 1/2] Update shadowJar includes to ignore useless runtime test configs --- minerl/Malmo/Minecraft/build.gradle | 47 ++++++++----------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/minerl/Malmo/Minecraft/build.gradle b/minerl/Malmo/Minecraft/build.gradle index 88b281ba7..244d5e963 100755 --- a/minerl/Malmo/Minecraft/build.gradle +++ b/minerl/Malmo/Minecraft/build.gradle @@ -29,16 +29,9 @@ plugins { id 'com.github.johnrengelman.shadow' version '1.2.4' } -// For versions >= 1.8 apply plugin: 'net.minecraftforge.gradle.forge' apply plugin: 'org.spongepowered.mixin' -// For versions < 1.8 -// apply plugin: 'forge' -// ext { -// mixinSrg = new File(project.buildDir, 'tmp/mixins/mixins.srg') -// mixinRefMap = new File(project.buildDir, 'tmp/mixins/mixins.malmo.refmap.json') -// } // Read the version number from the Mod's version properties file. @@ -84,24 +77,24 @@ repositories { } // Add the overclocking plugin to the manifest so that it is loaded when running in a non-dev environment (eg from the launcher) -jar { - - manifest { - attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', - 'TweakOrder': '0', - 'FMLCorePluginContainsFMLMod': 'true', - 'FMLCorePlugin': 'com.microsoft.Malmo.OverclockingPlugin', - 'FMLAT': 'malmomod_at.cfg' - } - manifest { - attributes 'FMLCorePlugin': 'com.microsoft.Malmo.OverclockingPlugin', - 'FMLCorePluginContainsFMLMod': 'true' - } -} +//jar { +// +// manifest { +// attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker', +// 'TweakOrder': '0', +// 'FMLCorePluginContainsFMLMod': 'true', +// 'FMLCorePlugin': 'com.microsoft.Malmo.OverclockingPlugin', +// 'FMLAT': 'malmomod_at.cfg' +// } +// manifest { +// attributes 'FMLCorePlugin': 'com.microsoft.Malmo.OverclockingPlugin', +// 'FMLCorePluginContainsFMLMod': 'true' +// } +//} // 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"]) +// JavaExec exec = project.getTasks().getByName("runClient") +// 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. @@ -156,10 +149,8 @@ if (JavaVersion.current().isJava8Compatible()) // Mixin stuff. -sourceSets { - main { - ext.refMap = "mixins.malmomod.refmap.json" - } +mixin { + add sourceSets.main, "mixins.malmomod.refmap.json" } @@ -340,7 +331,7 @@ task copyModToServer(type: Copy) { // Interesting. We've packaged forge gradle into the full jar and use gradle inherently?? shadowJar { classifier = 'fat' - configurations = [project.configurations.all] + configurations = [project.configurations.compile, project.configurations.runtime] manifest { attributes "Main-Class": "com.microsoft.Malmo.Launcher.GradleStart" } diff --git a/minerl/Malmo/Minecraft/gradle/wrapper/gradle-wrapper.properties b/minerl/Malmo/Minecraft/gradle/wrapper/gradle-wrapper.properties index e18cba72f..5f06eb19e 100755 --- a/minerl/Malmo/Minecraft/gradle/wrapper/gradle-wrapper.properties +++ b/minerl/Malmo/Minecraft/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip From adb14d74c922a8fe5cdc361726c6a458c89670de Mon Sep 17 00:00:00 2001 From: Brandon Houghton Date: Wed, 19 Aug 2020 01:12:05 -0700 Subject: [PATCH 2/2] Revert handler re-scoping Update full_action_observation_mixin.py to work properly (needs to be refactored) Fixes issues with the build-kite fat-jar build.gradle Working with interactive mode currently! --- minerl/Malmo/Minecraft/build.gradle | 2 +- .../herobraine/hero/handlers/agent/action.py | 4 +-- .../agent/observations/equipped_item.py | 26 ++++++++++--------- .../handlers/agent/observations/inventory.py | 3 +++ .../handlers/agent/observations/lifestats.py | 4 +++ minerl/herobraine/hero/mc.py | 4 +++ 6 files changed, 28 insertions(+), 15 deletions(-) diff --git a/minerl/Malmo/Minecraft/build.gradle b/minerl/Malmo/Minecraft/build.gradle index 244d5e963..2a31f4e15 100755 --- a/minerl/Malmo/Minecraft/build.gradle +++ b/minerl/Malmo/Minecraft/build.gradle @@ -106,7 +106,7 @@ repositories { // exec.getOutputs().files.setFrom(file("dummy_value")) // We also force the up-to-date check to return false, since the user will ALWAYS want runClient to run. -exec.getOutputs().upToDateWhen( { return false } ) +// exec.getOutputs().upToDateWhen( { return false } ) dependencies { // compile 'com.github.SpongePowered:Mixin:404f5da' // 0.7.5-SNAPSHOT diff --git a/minerl/herobraine/hero/handlers/agent/action.py b/minerl/herobraine/hero/handlers/agent/action.py index 45ec3125f..489e7a7c4 100644 --- a/minerl/herobraine/hero/handlers/agent/action.py +++ b/minerl/herobraine/hero/handlers/agent/action.py @@ -76,8 +76,8 @@ def __init__(self, command: str, items: list, _default='none', _other='other'): self._items = items self._univ_items = ['minecraft:' + item for item in items] - assert _default in self._items - assert _other in self._items + # assert _default in self._items + # assert _other in self._items self._default = _default self._other = _other super().__init__( diff --git a/minerl/herobraine/hero/handlers/agent/observations/equipped_item.py b/minerl/herobraine/hero/handlers/agent/observations/equipped_item.py index 7ed5c594c..82d502a84 100644 --- a/minerl/herobraine/hero/handlers/agent/observations/equipped_item.py +++ b/minerl/herobraine/hero/handlers/agent/observations/equipped_item.py @@ -19,7 +19,7 @@ class EquippedItemObservation(TranslationHandlerGroup): """ - Enables the observation of equppied items in the main and offhand + Enables the observation of equipped items in the main and offhand of the agent. """ @@ -33,7 +33,7 @@ def xml_template(self) -> str: def __init__(self, items : Iterable[str], mainhand : bool = True , offhand : bool = False, - _default : str ='none', + _default : str ='air', _other : str ='other'): assert mainhand or offhand, "Must select at least one hand to observer." @@ -52,7 +52,7 @@ def __init__(self, def __eq__(self, other): return ( super().__eq__(other) - and other.hand == self.hand + and other.hand == self._hand ) def __or__(self, other): @@ -92,8 +92,10 @@ def __init__(self, class _TypeObservation(TranslationHandler): """ Returns the item list index of the tool in the given hand - List must start with 'none' as 0th element and end with 'other' as wildcard element - # TODO (R): Update this dcoumentation + If _default and _other are NOT specified, list must contain all possible items + @:param _default - Overrides the default type, "air" + @:param _other - String to return if the observerd element is not in items + # TODO (R): Update this documentation """ def __init__(self, hand: str, items: list, _default : str, _other : str): @@ -104,10 +106,10 @@ def __init__(self, hand: str, items: list, _default : str, _other : str): self._items = sorted(items) self._hand = hand self._univ_items = ['minecraft:' + item for item in items] - self._default = _default - self._other = _other - assert self._other in items - assert self._default in items + self._default = _default + self._other = _other + # assert self._other in items + # assert self._default in items super().__init__( spaces.Enum(*self._items, default=self._default) ) @@ -118,7 +120,8 @@ def to_string(self): def from_hero(self, obs_dict): try: item = obs_dict['equipped_item']['mainhand']['type'] - return (self._other if item not in self._items else item) + # TODO properly return _other for air? + return self._other if item not in self._items else item except KeyError: return self._default @@ -142,7 +145,7 @@ def from_universal(self, obs): raise NotImplementedError('type not implemented for hand type' + self._hand) except KeyError: # No item in hotbar slot - return 'none' - # This looks wierd, but this will happen if the obs doesn't show up in the univ json. + # This looks weird, but this will happen if the obs doesn't show up in the univ json. return self._default except ValueError: return self._other @@ -202,4 +205,3 @@ def from_universal(self, obs): def __eq__(self, other): return isinstance(other, self.__class__) and self._hand == other._hand and self.type_str == other.type_str - diff --git a/minerl/herobraine/hero/handlers/agent/observations/inventory.py b/minerl/herobraine/hero/handlers/agent/observations/inventory.py index dca8e7ab8..73bc6177e 100644 --- a/minerl/herobraine/hero/handlers/agent/observations/inventory.py +++ b/minerl/herobraine/hero/handlers/agent/observations/inventory.py @@ -15,6 +15,9 @@ class FlatInventoryObservation(TranslationHandler): Handles GUI Container Observations for selected items """ + def to_hero(self, x) -> str: + raise NotImplementedError + def to_string(self): return 'inventory' diff --git a/minerl/herobraine/hero/handlers/agent/observations/lifestats.py b/minerl/herobraine/hero/handlers/agent/observations/lifestats.py index 78701dfcb..53461899d 100644 --- a/minerl/herobraine/hero/handlers/agent/observations/lifestats.py +++ b/minerl/herobraine/hero/handlers/agent/observations/lifestats.py @@ -13,6 +13,10 @@ class ObservationFromFullStats(TranslationHandlerGroup): """Groups all of thhe lifestats observations together to correspond to one XML element..""" + + def to_string(self) -> str: + return "fullStats" + def __init__(self): super(ObservationFromFullStats, self).__init__( handlers=[ diff --git a/minerl/herobraine/hero/mc.py b/minerl/herobraine/hero/mc.py index 6a690debb..697c51dd6 100644 --- a/minerl/herobraine/hero/mc.py +++ b/minerl/herobraine/hero/mc.py @@ -519,8 +519,12 @@ def get_key_from_id(id: str) -> str: ) all_data = json.load(open(mc_constants_file)) +# Note minecraft:air is an ITEM in ALL_ITEMS it servers as a defualt item and fills all empty spaces ALL_ITEMS = [item["type"] for item in all_data["items"]] +# Real items are all items that can be dropped, picked-up, ect. +REAL_ITEMS = [item["type"] for item in all_data["items"] if item["type"] != 'air'] + # We choose these not to be included by default; they are not items. NONE = "none" INVALID = "invalid"