Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update shadowJar includes to ignore useless runtime test configs #376

Open
wants to merge 2 commits into
base: wguss/unification
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 20 additions & 29 deletions minerl/Malmo/Minecraft/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -113,7 +106,7 @@ exec.jvmArgs(["-Dfml.coreMods.load=com.microsoft.Malmo.OverclockingPlugin","-Xmx
// 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
Expand Down Expand Up @@ -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"
}


Expand Down Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions minerl/herobraine/hero/handlers/agent/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down
26 changes: 14 additions & 12 deletions minerl/herobraine/hero/handlers/agent/observations/equipped_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand All @@ -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."
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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)
)
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
4 changes: 4 additions & 0 deletions minerl/herobraine/hero/mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down