diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8338dfb2..c5d6ac689 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@ project( Malmo )
# -------------------- Options --------------------------------
set( MALMO_VERSION_MAJOR 0)
-set( MALMO_VERSION_MINOR 22)
+set( MALMO_VERSION_MINOR 30)
set( MALMO_VERSION_REVISION 0)
set( MALMO_VERSION ${MALMO_VERSION_MAJOR}.${MALMO_VERSION_MINOR}.${MALMO_VERSION_REVISION} )
# N.B. Check that this version number matches the ones in the schemas.
diff --git a/Malmo/samples/Python_examples/CMakeLists.txt b/Malmo/samples/Python_examples/CMakeLists.txt
index d8527e613..562aef9fc 100755
--- a/Malmo/samples/Python_examples/CMakeLists.txt
+++ b/Malmo/samples/Python_examples/CMakeLists.txt
@@ -20,7 +20,6 @@
set( SOURCES
animation_test.py
build_test.py
- cart_test.py
chat_reward.py
chunk_test.py
craft_work.py
@@ -79,6 +78,10 @@ set( MULTI_AGENT_TESTS
set( OTHER_FILES
tutorial_6.xml
Tutorial.pdf
+ note_block_test.py # Currently no way to test audio
+ cart_test.py # Currently unreliable
+ mob_zoo.py # Currently unreliable
+ block_type_test.py # WIP
)
install( FILES ${SOURCES} ${MULTI_AGENT_TESTS} ${OTHER_FILES} DESTINATION Python_Examples )
diff --git a/Malmo/samples/Python_examples/block_type_test.py b/Malmo/samples/Python_examples/block_type_test.py
new file mode 100755
index 000000000..7e619ace7
--- /dev/null
+++ b/Malmo/samples/Python_examples/block_type_test.py
@@ -0,0 +1,180 @@
+# ------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 Microsoft Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+# associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all copies or
+# substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# ------------------------------------------------------------------------------------------------
+
+# Work in progress: this will eventually be a test of Malmo's support for all block types.
+
+import MalmoPython
+import os
+import sys
+import time
+import json
+import copy
+import errno
+import xml.etree.ElementTree as ET
+
+# Parse schema to collect all block types.
+# First find the schema file:
+schema_dir = None
+try:
+ schema_dir = os.environ['MALMO_XSD_PATH']
+except KeyError:
+ print "MALMO_XSD_PATH not set? Check environment."
+ exit(1)
+types_xsd = schema_dir + os.sep + "Types.xsd"
+
+# Now try to parse it:
+types_tree = None
+try:
+ types_tree = ET.parse(types_xsd)
+except (ET.ParseError, IOError):
+ print "Could not find or parse Types.xsd - check Malmo installation."
+ exit(1)
+
+# Find the BlockType element:
+root = types_tree.getroot()
+block_types_element = root.find("*[@name='BlockType']")
+if block_types_element == None:
+ print "Could not find block types in Types.xsd - file corruption?"
+ exit(1)
+
+# Find the enum inside the BlockType element:
+block_types_enum = block_types_element.find("*[@base]")
+if block_types_enum == None:
+ print "Unexpected schema format. Did the format get changed without this test getting updated?"
+ exit(1)
+
+# Now make a list of block types:
+block_types = [block.get("value") for block in block_types_enum]
+
+def getMissionXML(block_types):
+ forceReset = '"true"'
+ structureXML = ""
+ for i, b in enumerate(block_types):
+ structureXML += ''.format(i % 10, 3, i / 10, b)
+ structureXML += ""
+ startpos=(-2, 10, -2)
+
+ return '''
+
+
+
+ Block Test
+
+
+
+
+ ''' + structureXML + '''
+
+
+
+
+
+ Blocky
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 860
+ 480
+
+
+
+ '''
+
+sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) # flush print output immediately
+
+agent_host = MalmoPython.AgentHost()
+agent_host.addOptionalStringArgument( "recordingDir,r", "Path to location for saving mission recordings", "" )
+try:
+ agent_host.parse( sys.argv )
+except RuntimeError as e:
+ print 'ERROR:',e
+ print agent_host.getUsage()
+ exit(1)
+if agent_host.receivedArgument("help"):
+ print agent_host.getUsage()
+ exit(0)
+
+num_iterations = 30000
+if agent_host.receivedArgument("test"):
+ num_iterations = 10
+
+recording = False
+my_mission_record = MalmoPython.MissionRecordSpec()
+recordingsDirectory = agent_host.getStringArgument("recordingDir")
+if len(recordingsDirectory) > 0:
+ recording = True
+ try:
+ os.makedirs(recordingsDirectory)
+ except OSError as exception:
+ if exception.errno != errno.EEXIST: # ignore error if already existed
+ raise
+ my_mission_record.recordRewards()
+ my_mission_record.recordObservations()
+ my_mission_record.recordCommands()
+ my_mission_record.recordMP4(24,2000000)
+
+for i in xrange(num_iterations):
+ missionXML = getMissionXML(block_types)
+ if recording:
+ my_mission_record.setDestination(recordingsDirectory + "//" + "Mission_" + str(i+1) + ".tgz")
+ my_mission = MalmoPython.MissionSpec(missionXML, True)
+
+ max_retries = 3
+ for retry in range(max_retries):
+ try:
+ agent_host.startMission( my_mission, my_mission_record )
+ break
+ except RuntimeError as e:
+ if retry == max_retries - 1:
+ print "Error starting mission:",e
+ exit(1)
+ else:
+ time.sleep(2)
+
+ world_state = agent_host.getWorldState()
+ while not world_state.has_mission_begun:
+ sys.stdout.write(".")
+ time.sleep(0.1)
+ world_state = agent_host.getWorldState()
+ print
+
+ # main loop:
+ while world_state.is_mission_running:
+ if world_state.number_of_observations_since_last_state > 0:
+ msg = world_state.observations[-1].text
+ ob = json.loads(msg)
+ if "all_the_blocks" in ob:
+ blocks = ob["all_the_blocks"]
+ missing_blocks = [b for b in block_types if not b in blocks]
+ if len(missing_blocks) > 0:
+ print "MISSING:"
+ for b in missing_blocks:
+ print b,
+ print
+ world_state = agent_host.getWorldState()
diff --git a/Malmo/samples/Python_examples/cart_test.py b/Malmo/samples/Python_examples/cart_test.py
index d9a1901be..b4d9059d7 100755
--- a/Malmo/samples/Python_examples/cart_test.py
+++ b/Malmo/samples/Python_examples/cart_test.py
@@ -297,10 +297,10 @@ def calcYawToMob(entities, x, y, z):
''' + drawHilbert(4,16,34,16) + '''
-
+
-
+
''' + timeoutCondition + '''
diff --git a/Malmo/samples/Python_examples/hit_test.py b/Malmo/samples/Python_examples/hit_test.py
index e7ca5dc55..c262d1f52 100755
--- a/Malmo/samples/Python_examples/hit_test.py
+++ b/Malmo/samples/Python_examples/hit_test.py
@@ -70,6 +70,8 @@ def getMissionXML(summary):
1000true
+ true
+ Pig Sheep
diff --git a/Malmo/samples/Python_examples/mob_fun.py b/Malmo/samples/Python_examples/mob_fun.py
index c461b3154..242bba9e1 100755
--- a/Malmo/samples/Python_examples/mob_fun.py
+++ b/Malmo/samples/Python_examples/mob_fun.py
@@ -92,6 +92,8 @@ def getMissionXML(summary):
13000false
+ true
+ ''' + MOB_TYPE + '''
diff --git a/Malmo/samples/Python_examples/mob_zoo.py b/Malmo/samples/Python_examples/mob_zoo.py
new file mode 100755
index 000000000..0f77b53c0
--- /dev/null
+++ b/Malmo/samples/Python_examples/mob_zoo.py
@@ -0,0 +1,390 @@
+# ------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 Microsoft Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+# associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all copies or
+# substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# ------------------------------------------------------------------------------------------------
+
+# Test blaze drawing, entity tracking etc.
+
+import MalmoPython
+import os
+import random
+import sys
+import time
+import json
+import random
+import re
+import math
+from collections import namedtuple
+import xml.etree.ElementTree
+
+
+EntityInfo = namedtuple('EntityInfo', 'x, y, z, yaw, pitch, name, colour, variation, quantity, life')
+EntityInfo.__new__.__defaults__ = (0, 0, 0, 0, 0, "", "", "", 1, "")
+
+hostileMobs = [("ElderGuardian", "", 2),
+ ("WitherSkeleton", "", 1.95),
+ ("Stray", "", 1.95),
+ ("Husk", "", 1.95),
+ ("ZombieVillager", "", 1.95),
+ ("SkeletonHorse", "", 1.6),
+ ("ZombieHorse", "", 1.6),
+ ("EvocationIllager", "", 1.95),
+ ("VindicationIllager", "", 1.95),
+ ("", '', 0.4), # Vexes won't stay put, so draw one, but don't include its name in the list.
+ ("Giant", "", 11.7),
+
+ ("Skeleton", "", 2.0),
+ ("Spider", "", 0.9),
+ ("Creeper", "", 1.7),
+ ("Zombie", "", 1.9),
+ ("Slime", "", 0.5),
+ ("Ghast", "", 4),
+ ("PigZombie", "", 1.95),
+ ("Enderman", "", 2.9),
+ ("CaveSpider", '', 0.5),
+ #Cave spider will die from repeatedly climbing/falling, unless we give him a cushion of water to fall into.
+ ("Silverfish", "", 0.2),
+ ("",'', 0), #Padding cell for the giant's torso
+
+ ("Blaze", "", 1.8),
+ ("LavaSlime", "", 0.4),
+ ("EnderDragon", "", 5),
+ ("WitherBoss", '', 3.5),
+ ("Witch", '', 1.95),
+ ("Bat", "", 0.5),
+ ("Endermite", "", 0.3),
+ ("Guardian", "", 0.85),
+ ("Shulker", "", 1.0),
+ ("","",0), #Padding cell
+ ("",'',0)] #Padding cell for the giant's head
+
+friendlyMobs = [("Donkey", "", 1.6),
+ ("Mule", "", 1.6),
+ ("Pig", "", 0.9),
+ ("Sheep", "", 1.3),
+ ("Cow", "", 1.4),
+ ("Chicken", "", 0.7),
+ ("Squid", '', 0.8),
+ ("Wolf", "", 0.85),
+ ("MushroomCow", "", 1.4),
+ ("SnowMan", "", 1.9),
+ ("Ozelot", "", 0.7),
+ ("VillagerGolem", "", 2.7),
+ ("Horse", "", 1.6),
+ ("Rabbit", "", 0.4),
+ ("PolarBear", "", 1.4),
+ ("Llama", "", 1.9),
+ ("Villager", "", 1.95)]
+
+def checkEnts(present_entities, required_entities):
+ missing = []
+ for ent in required_entities:
+ if not ent in present_entities:
+ missing.append(ent)
+ if len(missing) > 0:
+ print "Can't find:", missing
+ if TESTING:
+ exit(1)
+
+def angvel(target, current, scale):
+ '''Use sigmoid function to choose a delta that will help smoothly steer from current angle to target angle.'''
+ delta = target - current
+ while delta < -180:
+ delta += 360;
+ while delta > 180:
+ delta -= 360;
+ return (2.0 / (1.0 + math.exp(-delta/scale))) - 1.0
+
+def pointTo(agent_host, ob, target_pitch, target_yaw, threshold):
+ '''Steer towards the target pitch/yaw, return True when within the given tolerance threshold.'''
+ pitch = ob.get(u'Pitch', 0)
+ yaw = ob.get(u'Yaw', 0)
+ delta_yaw = angvel(target_yaw, yaw, 50.0)
+ delta_pitch = angvel(target_pitch, pitch, 50.0)
+ agent_host.sendCommand("turn " + str(delta_yaw))
+ agent_host.sendCommand("pitch " + str(delta_pitch))
+ if abs(pitch-target_pitch) + abs(yaw-target_yaw) < threshold:
+ agent_host.sendCommand("turn 0")
+ agent_host.sendCommand("pitch 0")
+ return True
+ return False
+
+def calcYawAndPitchToMob(target, x, y, z, target_height):
+ dx = target.x - x
+ dz = target.z - z
+ yaw = -180 * math.atan2(dx, dz) / math.pi
+ distance = math.sqrt(dx * dx + dz * dz)
+ pitch = math.atan2(((y + 1.625) - (target.y + target_height * 0.9)), distance) * 180.0 / math.pi
+ return yaw, pitch
+
+agent_host = MalmoPython.AgentHost()
+agent_host.addOptionalFlag("mayhem,m", "Remove the safety glass from the cages...")
+try:
+ agent_host.parse( sys.argv )
+except RuntimeError as e:
+ print 'ERROR:',e
+ print agent_host.getUsage()
+ exit(1)
+if agent_host.receivedArgument("help"):
+ print agent_host.getUsage()
+ exit(0)
+
+rail_endpoints = []
+cell_midpoints = []
+endCondition = ""
+timeoutCondition = ""
+TESTING = agent_host.receivedArgument("test")
+if TESTING:
+ timeoutCondition = ''
+ endCondition = '''
+
+ '''
+# If we're not testing, and the user is after a little mayhem, swap the safety glass for air and make it night time.
+barrier_type = "air" if agent_host.receivedArgument("mayhem") and not TESTING else "barrier"
+start_time = "13000" if agent_host.receivedArgument("mayhem") and not TESTING else "10000"
+
+def getMissionXML(endCondition, timeoutCondition):
+ return '''
+
+
+ Zoo!
+
+
+
+ 50
+
+
+
+
+ false
+
+
+
+ ''' \
+ + getZooXML(friendlyMobs, cells_across=6, cell_depth=6, cell_height=6, cell_width=7, orgx=18, orgy=56, orgz=5, left_padding = 18, right_padding = 17) \
+ + getZooXML(hostileMobs, cells_across=11, cell_depth=-6, cell_height=6, cell_width=7, orgx=0, orgy=60, orgz=-5) \
+ + getRailXML() \
+ + timeoutCondition + '''
+
+
+
+
+
+ Gerald
+
+
+
+
+
+
+
+
+
+ ''' + endCondition + '''
+
+
+
+
+
+
+ '''
+
+def getRailXML():
+ railXML = ""
+ if len(rail_endpoints) != 12:
+ return "" # Works on the assumption that both zoos have three levels
+ for i in range(1, 6):
+ a = rail_endpoints[i]
+ b = rail_endpoints[i + 6] if i % 2 == 1 else rail_endpoints[i + 4]
+ railXML += ''.format(a[0], a[1], a[2], b[0], b[1], b[2])
+ railXML += ''.format(a[0], a[1] + 1, a[2], b[0], b[1] + 1, b[2])
+
+ # Add a diamond and a barrier at the ends:
+ end = rail_endpoints[-2]
+ start = rail_endpoints[0]
+ railXML += ''.format(end[0] + 1, end[1] + 2, end[2] - 1)
+ railXML += ''.format(end[0], end[1] + 1, end[2] - 1)
+ railXML += ''.format(start[0], start[1] + 1, start[2] + 1)
+ # And add the minecart:
+ railXML += ''
+ return railXML + ''
+
+def getZooXML(zooMobs, cells_across, cell_width, cell_height, cell_depth, orgx, orgy, orgz, left_padding = 0, right_padding = 0):
+ global rail_endpoints, cell_midpoints
+ missionXML = ""
+
+ # Get some dimensions:
+ # We allow cell_depth to be positive or negative, to specify front facing or back facing cells.
+ z_offset = 1 if cell_depth > 0 else -1
+ outer_left = orgx
+ outer_right = outer_left + cell_width * cells_across
+ inner_left, inner_right = outer_left + 1, outer_right - 1
+ outer_front = orgz
+ outer_back = orgz + cell_depth
+ inner_front, inner_back = outer_front + z_offset, outer_back - z_offset
+ outer_bottom, outer_top, inner_bottom, inner_top = 0, 0, 0, 0 # Filled in later
+ plug_in_dimensions = lambda s : s.format(outer_left = outer_left,
+ inner_left = inner_left,
+ outer_right = outer_right,
+ inner_right = inner_right,
+ outer_top = outer_top,
+ inner_top = inner_top,
+ outer_bottom = outer_bottom,
+ inner_bottom = inner_bottom,
+ outer_front = outer_front,
+ inner_front = inner_front,
+ outer_back = outer_back,
+ inner_back = inner_back)
+ # Draw the levels:
+ num_levels = int(math.ceil(float(len(zooMobs)) / float(cells_across)))
+ for i in xrange(num_levels):
+ # Dimensions for this level:
+ outer_bottom = orgy + i * cell_height
+ outer_top = orgy + (i + 1) * cell_height
+ inner_bottom, inner_top = outer_bottom + 1, outer_top - 1
+
+ drawLevelXML = '''
+
+ '''
+ missionXML += plug_in_dimensions(drawLevelXML)
+ # Add a platform and golden rail for this level:
+ missionXML += '''
+
+
+ '''.format(
+ outer_left = outer_left - left_padding,
+ outer_right = outer_right + right_padding,
+ inner_bottom = inner_bottom,
+ outer_bottom = outer_bottom,
+ front_lip = outer_front - z_offset)
+ rail_endpoints.append((outer_left - left_padding, outer_bottom, outer_front - 2 * z_offset))
+ rail_endpoints.append((outer_right + right_padding, outer_bottom, outer_front - 2 * z_offset))
+
+ # Draw the dividing walls, cell contents, and the entities. We do this in two passes,
+ # since drawing the walls after drawing the entities can result in killing them.
+ for draw_pass in ["cell", "entity"]:
+ for i, mob in enumerate(zooMobs):
+ x = i % cells_across
+ y = i / cells_across
+ # Dimensions for this cell:
+ outer_left = orgx + x * cell_width
+ outer_right = outer_left + cell_width
+ inner_left, inner_right = outer_left + 1, outer_right - 1
+ outer_bottom = orgy + y * cell_height
+ outer_top = outer_bottom + cell_height
+ inner_bottom, inner_top = outer_bottom + 1, outer_top - 1
+
+ # Should we draw the entity?
+ if draw_pass == "entity" and len(mob[0]) > 0:
+ mobx, moby, mobz = outer_left + cell_width / 2, inner_bottom, orgz + 3 * z_offset
+ missionXML += ''.format(mobx, moby, mobz, mob[0])
+ cell_midpoints.append((mobx, moby, mobz, mob[0]))
+
+ if draw_pass == "cell":
+ cellXML = ''''''
+ missionXML += plug_in_dimensions(cellXML)
+ # Draw any extra cell furniture:
+ if len(mob[1]) > 0:
+ missionXML += plug_in_dimensions(mob[1])
+
+ missionXML += ''''''
+ return missionXML
+
+my_client_pool = MalmoPython.ClientPool()
+my_client_pool.add(MalmoPython.ClientInfo("127.0.0.1", 10000))
+
+sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) # flush print output immediately
+my_mission = MalmoPython.MissionSpec(getMissionXML(endCondition, timeoutCondition), True)
+
+my_mission_record = MalmoPython.MissionRecordSpec()
+max_retries = 3
+for retry in range(max_retries):
+ try:
+ agent_host.startMission( my_mission, my_client_pool, my_mission_record, 0, "blahblah" )
+ break
+ except RuntimeError as e:
+ if retry == max_retries - 1:
+ print "Error starting mission",e
+ print "Is the game running?"
+ exit(1)
+ else:
+ time.sleep(2)
+
+world_state = agent_host.getWorldState()
+while not world_state.has_mission_begun:
+ time.sleep(0.1)
+ world_state = agent_host.getWorldState()
+
+agent_host.sendCommand("use 1")
+agent_host.sendCommand("move 0.1")
+
+mob_list = friendlyMobs[0:6] + hostileMobs[10::-1] + friendlyMobs[6:12] + hostileMobs[21:10:-1] + friendlyMobs[12:] + hostileMobs[:21:-1]
+mobs_to_view = [mob[0] for mob in mob_list if mob[0] != ""]
+mob_index = 0
+
+while world_state.is_mission_running:
+ world_state = agent_host.getWorldState()
+ if world_state.number_of_observations_since_last_state > 0:
+ obvsText = world_state.observations[-1].text
+ data = json.loads(obvsText) # observation comes in as a JSON string...
+ current_x = data.get(u'XPos', 0)
+ current_z = data.get(u'ZPos', 0)
+ current_y = data.get(u'YPos', 0)
+ if "entities" in data:
+ entities = [EntityInfo(**k) for k in data["entities"]]
+ checkEnts([ent.name for ent in entities], mobs_to_view)
+ # Find our closest cell, and work out what should be in it:
+ dist_to_cells = [abs(c[0] - current_x) + abs(c[1] - current_y) + abs(c[2] - current_z) for c in cell_midpoints]
+ target_ent_name = cell_midpoints[dist_to_cells.index(min(dist_to_cells))][3]
+ if mob_index < len(mobs_to_view) and target_ent_name == mobs_to_view[mob_index]:
+ agent_host.sendCommand("chat hello " + target_ent_name)
+ mob_index += 1
+ # Attempt to find that entity in our entities list:
+ target_ents = [e for e in entities if e.name == target_ent_name]
+ if len(target_ents) != 1:
+ pass
+ else:
+ target_ent = target_ents[0]
+ # Look up height of entity from our table:
+ target_height = [e for e in mob_list if e[0] == target_ent_name][0][2]
+ # Calculate where to look in order to see it:
+ target_yaw, target_pitch = calcYawAndPitchToMob(target_ent, current_x, current_y, current_z, target_height)
+ # And point ourselves there:
+ pointing_at_target = pointTo(agent_host, data, target_pitch, target_yaw, 0.5)
+
+# End of mission:
+reward = world_state.rewards[-1].getValue()
+print "Result: " + str(reward)
+if reward < 0:
+ exit(1)
+else:
+ exit(0)
\ No newline at end of file
diff --git a/Malmo/samples/Python_examples/note_block_test.py b/Malmo/samples/Python_examples/note_block_test.py
new file mode 100755
index 000000000..f30f4678d
--- /dev/null
+++ b/Malmo/samples/Python_examples/note_block_test.py
@@ -0,0 +1,172 @@
+# ------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 Microsoft Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
+# associated documentation files (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge, publish, distribute,
+# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all copies or
+# substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
+# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# ------------------------------------------------------------------------------------------------
+
+# Test of note blocks.
+# Create three rows of noteblocks, tuned according to a random tone-row, and triggered by tripwires.
+# As entities move around in the arena, they will play notes.
+# Noteblocks use a different instrument sound depending on the block they sit on top of.
+# Note that they need an air block directly above them in order to sound.
+# For best results, adjust your Minecraft sound options - put Noteblocks on 100% and reduce everything else.
+
+import MalmoPython
+import json
+import math
+import os
+import random
+import sys
+import time
+
+def genNoteblocks(x1, z1, x2, z2):
+ pitches = [
+ "F_sharp_3",
+ "G3",
+ "G_sharp_3",
+ "A3",
+ "A_sharp_3",
+ "B3",
+ "C4",
+ "C_sharp_4",
+ "D4",
+ "D_sharp_4",
+ "E4",
+ "F4",
+ "F_sharp_4",
+ "G4",
+ "G_sharp_4",
+ "A4",
+ "A_sharp_4",
+ "B4",
+ "C5",
+ "C_sharp_5",
+ "D5",
+ "D_sharp_5",
+ "E5",
+ "F5",
+ "F_sharp_5"]
+
+ # Randomise the pitches:
+ tone_row = pitches
+ for i in xrange(len(tone_row)):
+ s = random.randint(0, len(tone_row) - 1 - i)
+ tone_row[i], tone_row[i + s] = tone_row[i + s], tone_row[i]
+
+ # Draw wall around the playing arena:
+ xml = '''
+ '''.format(left = x1 - 2, right = x2 + 1, front = z1 - 1, back = z2 + 1, inner_left = x1 - 1, inner_right = x2, inner_front = z1, inner_back = z2)
+
+ # Draw the rows of triggers and supports:
+ xml += '''
+
+
+
+
+
+
+ '''.format(left = x1, right = x2, front = z1, back = z2, inner_front = z1 + 1, inner_back = z2 - 1, y_lower = 227, y_upper = 230)
+ xml += '''
+
+
+ '''.format(left = x1 - 1, inner_left = x1, right = x2 + 1, inner_right = x2, front = z1 + 1, back = z2 - 1, y_lower = 228)
+
+ # Draw the trip wires and noteblocks:
+ for x in xrange(x1, x2 + 1):
+ xml += ''.format(x = x, front = z1 + 2, back = z2 - 2, y_lower = 227)
+ xml += ''.format(x = x, front = z1 + 2, back = z2 - 2, y_upper = 230)
+
+ xml += ''.format(x = x, front = z1, pitch = tone_row[(x - x1) % 25])
+ xml += ''.format(x = x, front = z2, pitch = tone_row[(x - x1) % 25])
+ for z in xrange(z1 + 1, z2):
+ xml += ''.format(left = x1 + 1, z = z, right = x2 - 1)
+ xml += ''.format(x = x1 - 1, z = z, pitch = tone_row[(z - z1) % 25])
+
+ # Add some entities:
+ for i in xrange(10):
+ xml += ''.format(random.randint(x1, x2), random.randint(z1, z2), random.choice(["Rabbit","Rabbit","Rabbit", "Sheep"]))
+ return xml
+
+missionXML = '''
+
+
+ Mobophone
+
+
+
+
+
+ ''' + genNoteblocks(-20, -20, 20, 20) + '''
+
+
+
+
+
+
+ Webern
+
+
+
+
+
+
+
+
+ '''
+
+sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) # flush print output immediately
+my_mission = MalmoPython.MissionSpec(missionXML,True)
+agent_host = MalmoPython.AgentHost()
+try:
+ agent_host.parse( sys.argv )
+except RuntimeError as e:
+ print 'ERROR:',e
+ print agent_host.getUsage()
+ exit(1)
+if agent_host.receivedArgument("help"):
+ print agent_host.getUsage()
+ exit(0)
+
+my_mission_record = MalmoPython.MissionRecordSpec()
+max_retries = 3
+for retry in range(max_retries):
+ try:
+ agent_host.startMission( my_mission, my_mission_record )
+ break
+ except RuntimeError as e:
+ if retry == max_retries - 1:
+ print "Error starting mission",e
+ print "Is the game running?"
+ exit(1)
+ else:
+ time.sleep(2)
+
+world_state = agent_host.peekWorldState()
+while not world_state.has_mission_begun:
+ time.sleep(0.1)
+ world_state = agent_host.peekWorldState()
+
+# Just wander around randomly until we run out of time:
+agent_host.sendCommand("move 1")
+while world_state.is_mission_running:
+ world_state = agent_host.peekWorldState()
+ if random.random() > 0.96:
+ agent_host.sendCommand("turn " + str(2 * random.random() - 1.0))
+ if random.random() > 0.97:
+ agent_host.sendCommand("jump 1")
+ if random.random() > 0.85:
+ agent_host.sendCommand("jump 0")
+ time.sleep(0.1)
\ No newline at end of file
diff --git a/Malmo/samples/Python_examples/team_reward_test.py b/Malmo/samples/Python_examples/team_reward_test.py
index cb28e34db..a688d9c81 100755
--- a/Malmo/samples/Python_examples/team_reward_test.py
+++ b/Malmo/samples/Python_examples/team_reward_test.py
@@ -162,6 +162,9 @@ def safeWaitForStart(agent_hosts):
+
+
+
diff --git a/Malmo/src/AgentHost.cpp b/Malmo/src/AgentHost.cpp
index c3d696160..b7f07b7b3 100755
--- a/Malmo/src/AgentHost.cpp
+++ b/Malmo/src/AgentHost.cpp
@@ -426,7 +426,8 @@ namespace malmo
void AgentHost::setDebugOutput(bool debug)
{
- Logger::getLogger().setLogging("", Logger::LOG_INFO);
+ // Deprecated - use Logger.setLogging instead.
+ Logger::getLogger().setLogging("", debug ? Logger::LOG_INFO : Logger::LOG_OFF);
}
void AgentHost::setVideoPolicy(VideoPolicy videoPolicy)
diff --git a/Minecraft/LICENSE-fml.txt b/Minecraft/LICENSE-new.txt
similarity index 92%
rename from Minecraft/LICENSE-fml.txt
rename to Minecraft/LICENSE-new.txt
index 26cca072e..be2c9e66d 100755
--- a/Minecraft/LICENSE-fml.txt
+++ b/Minecraft/LICENSE-new.txt
@@ -1,39 +1,27 @@
-This minecraft mod, Forge Mod Loader, including all parts herein except as noted below,
-is licensed under the GNU LGPL v2.1 or later.
+Minecraft Forge is licensed under the terms of the LGPL 2.1 found
+here http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt and copied
+below.
+
+A note on authorship:
+All source artifacts are property of their original author, with
+the exclusion of the contents of the patches directory and others
+copied from it from time to time. Authorship of the contents of
+the patches directory is retained by the Minecraft Forge project.
+This is because the patches are partially machine generated
+artifacts, and are changed heavily due to the way forge works.
+Individual attribution within them is impossible.
+
+Consent:
+All contributions to Forge must consent to the release of any
+patch content to the Forge project.
+
+A note on infectivity:
+The LGPL is chosen specifically so that projects may depend on Forge
+features without being infected with its license. That is the
+purpose of the LGPL. Mods and others using this code via ordinary
+Java mechanics for referencing libraries are specifically not bound
+by Forge's license for the Mod code.
-Homepage: https://github.com/MinecraftForge/FML
-
-This software includes portions from the Apache Maven project at
-http://maven.apache.org/ specifically the ComparableVersion.java code. It is
-included based on guidelines at
-http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
-with notices intact. The only change is a non-functional change of package name.
-
-This software contains a partial repackaging of javaxdelta, a BSD licensed program for generating
-binary differences and applying them, sourced from the subversion at http://sourceforge.net/projects/javaxdelta/
-authored by genman, heikok, pivot.
-The only changes are to replace some Trove collection types with standard Java collections, and repackaged.
-
-
-=== MCP Data ===
-This software includes data from the Minecraft Coder Pack (MCP), with kind permission
-from them. The license to MCP data is not transitive - distribution of this data by
-third parties requires independent licensing from the MCP team. This data is not
-redistributable without permission from the MCP team.
-
-=== Sharing ===
-I grant permission for some parts of FML to be redistributed outside the terms of the LGPL, for the benefit of
-the minecraft modding community. All contributions to these parts should be licensed under the same additional grant.
-
--- Runtime patcher --
-License is granted to redistribute the runtime patcher code (common/cpw/mods/fml/patcher and subdirectories) under
-any alternative open source license as classified by the OSI (http://opensource.org/licenses)
-
--- ASM transformers --
-License is granted to redistribute the ASM transformer code (common/cpw/mods/fml/common/asm/ and subdirectories)
-under any alternative open source license as classified by the OSI (http://opensource.org/licenses)
-
-========
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
@@ -43,6 +31,10 @@ under any alternative open source license as classified by the OSI (http://opens
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
Preamble
The licenses for most software are designed to take away your
@@ -88,7 +80,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
-
+
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@@ -144,7 +136,7 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
-
+
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
@@ -191,7 +183,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
-
+
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@@ -249,7 +241,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
-
+
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@@ -300,7 +292,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
-
+
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@@ -362,7 +354,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
-
+
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@@ -403,7 +395,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
-
+
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@@ -455,7 +447,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
-
+
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
diff --git a/Minecraft/MinecraftForge-License.txt b/Minecraft/MinecraftForge-License.txt
deleted file mode 100755
index 1cc2a3e9d..000000000
--- a/Minecraft/MinecraftForge-License.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-Minecraft Forge Public Licence
-==============================
-
-Version 1.0
-
-0. Definitions
---------------
-
-Minecraft: Denotes a copy of the Minecraft game licensed by Mojang AB
-
-User: Anybody that interract with the software in one of the following ways:
- - play
- - decompile
- - recompile or compile
- - modify
-
-Minecraft Forge: The Minecraft Forge code, in source form, class file form, as
-obtained in a standalone fashion or as part of a wider distribution.
-
-Dependency: Code required to have Minecraft Forge working properly. That can
-include dependencies required to compile the code as well as modifications in
-the Minecraft sources that are required to have Minecraft Forge working.
-
-1. Scope
---------
-
-The present license is granted to any user of Minecraft Forge, for all files included
-unless stated otherwise in the file itself. As a prerequisite, a user of Minecraft
-Forge must own a legally aquired copy of Minecraft.
-
-2. Play rights
---------------
-
-The user of Minecraft Forge is allowed to install the software on a client or
-a server and to play it without restriction.
-
-3. Modification rights
-----------------------
-
-The user has the right to decompile the source code, look at either the
-decompiled version or the original source code, and to modify it.
-
-4. Derivation rights
---------------------
-
-The user has the rights to derive code from Minecraft Forge, that is to say to
-write code that either extends Minecraft Forge class and interfaces,
-instantiate the objects declared or calls the functions. This code is known as
-"derived" code, and can be licensed with conditions different from Minecraft
-Forge.
-
-
-5. Distribution rights
-----------------------
-
-The user of Minecraft Forge is allowed to redistribute Minecraft Forge in
-partially, in totallity, or included in a distribution. When distributing
-binaries or class files, the user must provide means to obtain the sources of
-the distributed version of Minecraft Forge at no costs. This includes the
-files as well as any dependency that the code may rely on, including patches to
-minecraft original sources.
-
-Modification of Minecraft Forge as well as dependencies, including patches to
-minecraft original sources, has to remain under the terms of the present
-license.
-
-The right to distribute Minecraft Forge does not extend to the right to distribute
-MCP data files included within Minecraft Forge. These are the property of the MCP
-project and should be removed from any customized distribution of Minecraft Forge
-or permission sought separately from the MCP team.
diff --git a/Minecraft/Minecraft_Client.launch b/Minecraft/Minecraft_Client.launch
index 823fd223f..666c7629b 100755
--- a/Minecraft/Minecraft_Client.launch
+++ b/Minecraft/Minecraft_Client.launch
@@ -8,5 +8,5 @@
-
+
diff --git a/Minecraft/build.gradle b/Minecraft/build.gradle
index 0000300fa..131f046da 100755
--- a/Minecraft/build.gradle
+++ b/Minecraft/build.gradle
@@ -1,25 +1,17 @@
-import org.gradle.internal.os.OperatingSystem;
-/*
// For those who want the bleeding edge
buildscript {
repositories {
jcenter()
maven {
- name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
- classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
+ classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
-*/
-// for people who want stable
-plugins {
- id "net.minecraftforge.gradle.forge" version "2.0.1"
-}
// Read the version number from the Mod's version properties file.
if (!file('src/main/resources/version.properties').exists()) {
@@ -34,7 +26,7 @@ group= "com.microsoft.MalmoMod" // http://maven.apache.org/guides/mini/guide-nam
archivesBaseName = "MalmoMod"
minecraft {
- version = "1.8-11.14.3.1543"
+ version = "1.11.2-13.20.0.2228"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
@@ -42,25 +34,8 @@ minecraft {
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
- mappings = "snapshot_20141130"
+ mappings = "snapshot_20161220"
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
-
- /*
- afterEvaluate {
- // At this point, we can extract the command line used to run minecraft, and save it into
- // a bat/sh file for quicker startup on subsequent runs.
- JavaExec rc = project.getTasks().getByName("runClient");
- String fname = "runMC.sh"
- if (OperatingSystem.current().isWindows())
- fname = "runMC.bat"
- if (!file(fname).exists()) {
- def cmdlineFile = file(fname)
- rc.getCommandLine().each {
- cmdlineFile << "${it} "
- }
- }
- }
- */
}
// Add the overclocking plugin to the manifest so that it is loaded when running in a non-dev environment (eg from the launcher)
diff --git a/Minecraft/gradle/wrapper/gradle-wrapper.properties b/Minecraft/gradle/wrapper/gradle-wrapper.properties
index b32dc93e2..e18cba72f 100755
--- a/Minecraft/gradle/wrapper/gradle-wrapper.properties
+++ b/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.11-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip
diff --git a/Minecraft/run/options.txt b/Minecraft/run/options.txt
index e9df83295..125a28e9d 100644
--- a/Minecraft/run/options.txt
+++ b/Minecraft/run/options.txt
@@ -1,3 +1,4 @@
+version:922
invertYMouse:false
mouseSensitivity:0.5
fov:0.0
@@ -15,8 +16,9 @@ fancyGraphics:false
ao:0
renderClouds:true
resourcePacks:[]
+incompatibleResourcePacks:[]
lastServer:
-lang:en_US
+lang:en_us
chatVisibility:0
chatColors:true
chatLinks:true
@@ -39,20 +41,16 @@ chatScale:1.0
chatWidth:1.0
showInventoryAchievementHint:false
mipmapLevels:4
-streamBytesPerPixel:0.5
-streamMicVolume:1.0
-streamSystemVolume:1.0
-streamKbps:0.5412844
-streamFps:0.31690142
-streamCompression:1
-streamSendMetadata:true
-streamPreferredServer:
-streamChatEnabled:0
-streamChatUserFilter:0
-streamMicToggleBehavior:0
forceUnicodeFont:false
-allowBlockAlternatives:true
reducedDebugInfo:false
+useNativeTransport:true
+entityShadows:true
+mainHand:right
+attackIndicator:1
+showSubtitles:false
+realmsNotifications:true
+enableWeakAttacks:false
+autoJump:false
key_key.attack:-100
key_key.use:-99
key_key.forward:17
@@ -61,6 +59,7 @@ key_key.back:31
key_key.right:32
key_key.jump:57
key_key.sneak:42
+key_key.sprint:29
key_key.drop:16
key_key.inventory:18
key_key.chat:20
@@ -70,13 +69,9 @@ key_key.command:53
key_key.screenshot:60
key_key.togglePerspective:63
key_key.smoothCamera:0
-key_key.sprint:29
-key_key.streamStartStop:64
-key_key.streamPauseUnpause:65
-key_key.streamCommercial:0
-key_key.streamToggleMic:0
key_key.fullscreen:87
key_key.spectatorOutlines:0
+key_key.swapHands:33
key_key.hotbar.1:2
key_key.hotbar.2:3
key_key.hotbar.3:4
@@ -97,6 +92,7 @@ soundCategory_hostile:1.0
soundCategory_neutral:1.0
soundCategory_player:1.0
soundCategory_ambient:1.0
+soundCategory_voice:1.0
modelPart_cape:true
modelPart_jacket:true
modelPart_left_sleeve:true
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java b/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java
index 7a042ff57..837fcd725 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/Client/ClientStateMachine.java
@@ -47,10 +47,12 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.network.NetworkManager;
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.integrated.IntegratedServer;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.MathHelper;
-import net.minecraft.world.WorldSettings.GameType;
+import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.text.TextComponentString;
+import net.minecraft.world.GameType;
+import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.common.MinecraftForge;
@@ -90,11 +92,11 @@
import com.microsoft.Malmo.Utils.AuthenticationHelper;
import com.microsoft.Malmo.Utils.SchemaHelper;
import com.microsoft.Malmo.Utils.ScreenHelper;
-import com.microsoft.Malmo.Utils.TCPUtils;
import com.microsoft.Malmo.Utils.ScreenHelper.TextCategory;
import com.microsoft.Malmo.Utils.TCPInputPoller;
import com.microsoft.Malmo.Utils.TCPInputPoller.CommandAndIPAddress;
import com.microsoft.Malmo.Utils.TCPSocket;
+import com.microsoft.Malmo.Utils.TCPUtils;
import com.microsoft.Malmo.Utils.TimeHelper;
/**
@@ -204,7 +206,6 @@ public ClientStateMachine(ClientState initialState, MalmoModClient inputControll
this.inputController = inputController;
// Register ourself on the event busses, so we can harness the client tick:
- FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
MalmoMod.MalmoMessageHandler.registerForMessage(this, MalmoMessageType.SERVER_TEXT);
}
@@ -235,7 +236,7 @@ public void onMessage(MalmoMessageType messageType, Map data)
{
String chat = data.get("chat");
if (chat != null)
- Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new ChatComponentText(chat), 1);
+ Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(chat), 1);
else
{
String text = data.get("text");
@@ -678,7 +679,7 @@ abstract public class ConfigAwareStateEpisode extends ErrorAwareEpisode
@Override
public void onConfigChanged(OnConfigChangedEvent ev)
{
- if (ev.configID.equals(MalmoMod.SOCKET_CONFIGS))
+ if (ev.getConfigID().equals(MalmoMod.SOCKET_CONFIGS))
{
AddressHelper.update(MalmoMod.instance.getModSessionConfigFile());
try
@@ -893,11 +894,11 @@ private boolean isChunkReady()
if (as.getAgentStart() != null && as.getAgentStart().getPlacement() != null)
{
PosAndDirection pos = as.getAgentStart().getPlacement();
- int x = MathHelper.floor_double(pos.getX().doubleValue()) >> 4;
- int z = MathHelper.floor_double(pos.getZ().doubleValue()) >> 4;
+ int x = MathHelper.floor(pos.getX().doubleValue()) >> 4;
+ int z = MathHelper.floor(pos.getZ().doubleValue()) >> 4;
// Now get the chunk we should be starting in:
- IChunkProvider chunkprov = Minecraft.getMinecraft().theWorld.getChunkProvider();
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ IChunkProvider chunkprov = Minecraft.getMinecraft().world.getChunkProvider();
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
if (player.addedToChunk)
{
// Our player is already added to a chunk - is it the right one?
@@ -930,11 +931,11 @@ protected void onClientTick(ClientTickEvent ev)
{
// Tell the server what our agent name is.
// We do this repeatedly, because the server might not yet be listening.
- if (Minecraft.getMinecraft().thePlayer != null && !this.waitingForChunk)
+ if (Minecraft.getMinecraft().player != null && !this.waitingForChunk)
{
HashMap map = new HashMap();
map.put("agentname", agentName);
- map.put("username", Minecraft.getMinecraft().thePlayer.getName());
+ map.put("username", Minecraft.getMinecraft().player.getName());
currentMissionBehaviour().appendExtraServerInformation(map);
System.out.println("***Telling server we are ready - " + agentName);
MalmoMod.network.sendToServer(new MalmoMod.MalmoMessage(MalmoMessageType.CLIENT_AGENTREADY, 0, map));
@@ -1006,13 +1007,13 @@ else if (agents.size() > 1)
int port = currentMissionInit().getMinecraftServerConnection().getPort();
String targetIP = address + ":" + port;
System.out.println("We should be joining " + targetIP);
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
- boolean namesMatch = (player == null) || Minecraft.getMinecraft().thePlayer.getName().equals(this.agentName);
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
+ boolean namesMatch = (player == null) || Minecraft.getMinecraft().player.getName().equals(this.agentName);
if (!namesMatch)
{
// The name of our agent no longer matches the agent in our game profile -
// safest way to update is to log out and back in again.
- Minecraft.getMinecraft().theWorld.sendQuittingDisconnectingPacket();
+ Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket();
Minecraft.getMinecraft().loadWorld((WorldClient)null);
}
if (Minecraft.getMinecraft().getCurrentServerData() == null || !Minecraft.getMinecraft().getCurrentServerData().serverIP.equals(targetIP))
@@ -1205,8 +1206,12 @@ protected void execute()
episodeHasCompletedWithErrors(ClientState.ERROR_DUFF_HANDLERS, "Could not create server mission handlers: " + e.getMessage());
}
- boolean needsNewWorld = serverHandlers != null && serverHandlers.worldGenerator != null && serverHandlers.worldGenerator.shouldCreateWorld(currentMissionInit());
- boolean worldCurrentlyExists = Minecraft.getMinecraft().getIntegratedServer() != null && Minecraft.getMinecraft().theWorld != null;
+ World world = null;
+ if (Minecraft.getMinecraft().getIntegratedServer() != null)
+ world = Minecraft.getMinecraft().getIntegratedServer().getEntityWorld();
+
+ boolean needsNewWorld = serverHandlers != null && serverHandlers.worldGenerator != null && serverHandlers.worldGenerator.shouldCreateWorld(currentMissionInit(), world);
+ boolean worldCurrentlyExists = Minecraft.getMinecraft().getIntegratedServer() != null && Minecraft.getMinecraft().world != null;
if (worldCurrentlyExists)
{
// If a world already exists, we need to check that our requested agent name matches the name
@@ -1214,9 +1219,9 @@ protected void execute()
// Get our name from the Mission:
List agents = currentMissionInit().getMission().getAgentSection();
String agentName = agents.get(currentMissionInit().getClientRole()).getName();
- if (Minecraft.getMinecraft().thePlayer != null)
+ if (Minecraft.getMinecraft().player != null)
{
- if (!Minecraft.getMinecraft().thePlayer.getName().equals(agentName))
+ if (!Minecraft.getMinecraft().player.getName().equals(agentName))
needsNewWorld = true;
}
}
@@ -1282,7 +1287,7 @@ public class PauseOldServerEpisode extends ConfigAwareStateEpisode
@Override
protected void execute()
{
- if (Minecraft.getMinecraft().getIntegratedServer() != null && Minecraft.getMinecraft().theWorld != null)
+ if (Minecraft.getMinecraft().getIntegratedServer() != null && Minecraft.getMinecraft().world != null)
{
// If the integrated server has been opened to the LAN, we won't be able to pause it.
// To get around this, we need to make it think it's not open, by modifying its isPublic flag.
@@ -1386,11 +1391,11 @@ public class CloseOldServerEpisode extends ConfigAwareStateEpisode
@Override
protected void execute()
{
- if (Minecraft.getMinecraft().theWorld != null)
+ if (Minecraft.getMinecraft().world != null)
{
// If the Minecraft server isn't paused at this point,
// then the following line will cause the server thread to exit...
- Minecraft.getMinecraft().theWorld.sendQuittingDisconnectingPacket();
+ Minecraft.getMinecraft().world.sendQuittingDisconnectingPacket();
// ...in which case the next line will hang.
Minecraft.getMinecraft().loadWorld((WorldClient) null);
// Must display the GUI or Minecraft will attempt to access a non-existent player in the client tick.
@@ -1536,7 +1541,7 @@ protected void onMissionStarted()
// Tell the server we have started:
HashMap map = new HashMap();
- map.put("username", Minecraft.getMinecraft().thePlayer.getName());
+ map.put("username", Minecraft.getMinecraft().player.getName());
MalmoMod.network.sendToServer(new MalmoMod.MalmoMessage(MalmoMessageType.CLIENT_AGENTRUNNING, 0, map));
// Set up our mission handlers:
@@ -1617,7 +1622,7 @@ public void onClientTick(ClientTickEvent event)
onMissionEnded(ClientState.MISSION_ABORTED, "Mission was aborted by server: " + ClientStateMachine.this.getErrorDetails());
// Check to see whether we've been kicked from the server.
- NetworkManager netman = Minecraft.getMinecraft().getNetHandler().getNetworkManager();
+ NetworkManager netman = Minecraft.getMinecraft().getConnection().getNetworkManager();
if (netman != null && !netman.hasNoChannel() && !netman.isChannelOpen())
{
// Connection has been lost.
@@ -1646,7 +1651,7 @@ public void onClientTick(ClientTickEvent event)
}
// Check here to see whether the player has died or not:
- if (!this.playerDied && Minecraft.getMinecraft().thePlayer.isDead)
+ if (!this.playerDied && Minecraft.getMinecraft().player.isDead)
{
this.playerDied = true;
this.quitCode = MalmoMod.AGENT_DEAD_QUIT_CODE;
@@ -1696,7 +1701,7 @@ public void onClientTick(ClientTickEvent event)
String agentName = agents.get(currentMissionInit().getClientRole()).getName();
HashMap map = new HashMap();
map.put("agentname", agentName);
- map.put("username", Minecraft.getMinecraft().thePlayer.getName());
+ map.put("username", Minecraft.getMinecraft().player.getName());
map.put("quitcode", this.quitCode);
MalmoMod.network.sendToServer(new MalmoMod.MalmoMessage(MalmoMessageType.CLIENT_AGENTFINISHEDMISSION, 0, map));
onMissionEnded(ClientState.IDLING, null);
@@ -1870,11 +1875,11 @@ else if (messageType == MalmoMessageType.SERVER_GO)
// First, force all entities to get re-added to their chunks, clearing out any old entities in the process.
// We need to do this because the process of teleporting all agents to their start positions, combined
// with setting them to/from spectator mode, leaves the client chunk entity lists etc in a parlous state.
- List lel = Minecraft.getMinecraft().theWorld.loadedEntityList;
+ List lel = Minecraft.getMinecraft().world.loadedEntityList;
for (int i = 0; i < lel.size(); i++)
{
Entity entity = (Entity)lel.get(i);
- Chunk chunk = Minecraft.getMinecraft().theWorld.getChunkFromChunkCoords(entity.chunkCoordX, entity.chunkCoordZ);
+ Chunk chunk = Minecraft.getMinecraft().world.getChunkFromChunkCoords(entity.chunkCoordX, entity.chunkCoordZ);
List entitiesToRemove = new ArrayList();
for (int k = 0; k < chunk.getEntityLists().length; k++)
{
@@ -1901,6 +1906,12 @@ else if (messageType == MalmoMessageType.SERVER_GO)
((EntityLivingBase)entity).renderYawOffset = entity.rotationYaw;
((EntityLivingBase)entity).prevRenderYawOffset = entity.rotationYaw;
}
+ if (entity instanceof EntityPlayerSP)
+ {
+ // Although the following call takes place on the server, and should have taken effect already,
+ // there is some discontinuity which is causing the effects to get lost, so we call it here too:
+ entity.setInvisible(false);
+ }
}
this.serverHasFiredStartingPistol = true; // GO GO GO!
}
@@ -1949,8 +1960,8 @@ protected void execute()
{
// Inform the server of what has happened.
HashMap map = new HashMap();
- if (Minecraft.getMinecraft().thePlayer != null) // Might not be a player yet.
- map.put("username", Minecraft.getMinecraft().thePlayer.getName());
+ if (Minecraft.getMinecraft().player != null) // Might not be a player yet.
+ map.put("username", Minecraft.getMinecraft().player.getName());
map.put("error", ClientStateMachine.this.getErrorDetails());
MalmoMod.network.sendToServer(new MalmoMod.MalmoMessage(MalmoMessageType.CLIENT_BAILED, 0, map));
}
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Client/KeyManager.java b/Minecraft/src/main/java/com/microsoft/Malmo/Client/KeyManager.java
index 2ef28a18c..638676b30 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/Client/KeyManager.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/Client/KeyManager.java
@@ -23,7 +23,7 @@
import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
-import net.minecraftforge.fml.common.FMLCommonHandler;
+import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
@@ -47,7 +47,7 @@ public KeyManager(GameSettings settings, ArrayList additionalKeys)
if (additionalKeys != null)
{
fixAdditionalKeyBindings(settings);
- FMLCommonHandler.instance().bus().register(this);
+ MinecraftForge.EVENT_BUS.register(this);
}
}
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java b/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java
index e5c7fbb99..1d473748f 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/Client/MalmoModClient.java
@@ -27,7 +27,6 @@
import net.minecraft.util.MouseHelper;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.client.GuiIngameModOptions;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -91,7 +90,6 @@ enum InputType
public void init(FMLInitializationEvent event)
{
// Register for various events:
- FMLCommonHandler.instance().bus().register(this);
MinecraftForge.EVENT_BUS.register(this);
GameSettings settings = Minecraft.getMinecraft().gameSettings;
@@ -169,13 +167,14 @@ public void onPressed()
this.keyManager = new KeyManager(settings, extraKeys);
}
+ /*
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onEvent(GuiOpenEvent event)
{
- if (event.gui instanceof GuiIngameModOptions)
+ if (event.getGui() instanceof GuiIngameModOptions)
{
- event.gui = new MalmoModGuiOptions.MalmoModGuiScreen(null);
+ event.setGui(new MalmoModGuiOptions.MalmoModGuiScreen(null));
}
- }
+ }*/
}
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java b/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java
index a5cca7240..240807498 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/Client/VideoHook.java
@@ -29,7 +29,6 @@
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.common.gameevent.TickEvent.RenderTickEvent;
@@ -127,7 +126,6 @@ public void start(MissionInit missionInit, IVideoProducer videoProducer)
try
{
MinecraftForge.EVENT_BUS.register(this);
- FMLCommonHandler.instance().bus().register(this);
}
catch(Exception e)
{
@@ -173,7 +171,6 @@ public void stop()
try
{
MinecraftForge.EVENT_BUS.unregister(this);
- FMLCommonHandler.instance().bus().unregister(this);
}
catch(Exception e)
{
@@ -212,12 +209,12 @@ public void onRender(RenderTickEvent event)
@SubscribeEvent
public void postRender(RenderWorldLastEvent event)
{
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
- float x = (float) (player.lastTickPosX + (player.posX - player.lastTickPosX) * event.partialTicks);
- float y = (float) (player.lastTickPosY + (player.posY - player.lastTickPosY) * event.partialTicks);
- float z = (float) (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.partialTicks);
- float yaw = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * event.partialTicks;
- float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialTicks;
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
+ 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/Minecraft/src/main/java/com/microsoft/Malmo/EpisodeEventWrapper.java b/Minecraft/src/main/java/com/microsoft/Malmo/EpisodeEventWrapper.java
index d5fe8e0eb..e69351c7a 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/EpisodeEventWrapper.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/EpisodeEventWrapper.java
@@ -138,7 +138,7 @@ public void onPlayerDies(LivingDeathEvent lde)
@SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent ev)
{
- if (ev.modID == MalmoMod.MODID) // Check we are responding to the correct Mod's event!
+ if (ev.getModID() == MalmoMod.MODID) // Check we are responding to the correct Mod's event!
{
this.stateEpisodeLock.readLock().lock();
if (this.stateEpisode != null && this.stateEpisode.isLive())
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java b/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java
index c5a9f8471..fac824aad 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java
@@ -37,6 +37,7 @@
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.IThreadListener;
import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
@@ -64,6 +65,7 @@
import com.microsoft.Malmo.Utils.SchemaHelper;
import com.microsoft.Malmo.Utils.ScreenHelper;
import com.microsoft.Malmo.Utils.TCPUtils;
+import net.minecraft.world.WorldServer;
@Mod(modid = MalmoMod.MODID, guiFactory = "com.microsoft.Malmo.MalmoModGuiOptions")
public class MalmoMod
@@ -133,7 +135,9 @@ public static Hashtable getPropertiesForCurrentThread() throws E
{
if (Minecraft.getMinecraft().isCallingFromMinecraftThread())
return clientProperties;
- if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isCallingFromMinecraftThread())
+
+ MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
+ if (server != null && server.isCallingFromMinecraftThread())
return serverProperties;
else throw new Exception("Request for properties made from unrecognised thread.");
}
@@ -385,7 +389,7 @@ public IMessage onMessage(final MalmoMessage message, final MessageContext ctx)
if (ctx.side == Side.CLIENT)
mainThread = Minecraft.getMinecraft();
else
- mainThread = MinecraftServer.getServer();
+ mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world;
mainThread.addScheduledTask(new Runnable()
{
@Override
@@ -408,8 +412,8 @@ public void run()
public static void safeSendToAll(MalmoMessageType malmoMessage)
{
// network.sendToAll() is buggy - race conditions result in the message getting trashed if there is more than one client.
- MinecraftServer server = MinecraftServer.getServer();
- for (Object player : server.getConfigurationManager().playerEntityList)
+ MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
+ for (Object player : server.getPlayerList().getPlayers())
{
if (player != null && player instanceof EntityPlayerMP)
{
@@ -427,8 +431,8 @@ public static void safeSendToAll(MalmoMessageType malmoMessage, Map getConfigElements()
return list;
}
- @SuppressWarnings("unchecked") // Needed for the buttonList.add call - Minecraft code declares buttonList as unparameterised.
@Override
public void initGui()
{
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldDecorator.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldDecorator.java
index fb2b804ea..3f6b4d79b 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldDecorator.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldDecorator.java
@@ -43,7 +43,7 @@ public DecoratorException(String message)
/** Get the world into the required state for the start of the mission.
* @param missionInit the MissionInit object for the currently running mission, which may contain parameters for the observation requirements.
*/
- public void buildOnWorld(MissionInit missionInit) throws DecoratorException;
+ public void buildOnWorld(MissionInit missionInit, World world) throws DecoratorException;
/** Gives the decorator a chance to add any client-side mission handlers that might be required - eg end-points for the maze generator, etc -
* and to communicate (via the map) any data back to the client-side.
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldGenerator.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldGenerator.java
index 642a873f7..1d25da142 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldGenerator.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlerInterfaces/IWorldGenerator.java
@@ -19,6 +19,8 @@
package com.microsoft.Malmo.MissionHandlerInterfaces;
+import net.minecraft.world.World;
+
import com.microsoft.Malmo.Schemas.MissionInit;
/** Interface for objects which can determine the world structure for the Minecraft mission.
@@ -38,7 +40,7 @@ public interface IWorldGenerator
* @param missionInit the MissionInit object for the currently running mission, which may contain parameters for the observation requirements.
* @return true if the world should be created, false otherwise.
*/
- public boolean shouldCreateWorld(MissionInit missionInit);
+ public boolean shouldCreateWorld(MissionInit missionInit, World world);
public String getErrorDetails();
}
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AbsoluteMovementCommandsImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AbsoluteMovementCommandsImplementation.java
index 152f46daa..ee9970602 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AbsoluteMovementCommandsImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AbsoluteMovementCommandsImplementation.java
@@ -27,9 +27,10 @@
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
-import net.minecraft.network.play.server.S08PacketPlayerPosLook;
+import net.minecraft.network.play.server.SPacketPlayerPosLook;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.IThreadListener;
+import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
@@ -71,7 +72,7 @@ public boolean parseParameters(Object params)
private void sendChanges()
{
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
if (player == null)
return;
@@ -172,27 +173,27 @@ public IMessage onMessage(final TeleportMessage message, final MessageContext ct
if (ctx.side == Side.CLIENT)
mainThread = Minecraft.getMinecraft();
else
- mainThread = MinecraftServer.getServer();
+ mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world;
mainThread.addScheduledTask(new Runnable()
{
@Override
public void run()
{
- EnumSet enumset = EnumSet.noneOf(S08PacketPlayerPosLook.EnumFlags.class);
+ EnumSet enumset = EnumSet.noneOf(SPacketPlayerPosLook.EnumFlags.class);
if (!message.setX)
- enumset.add(S08PacketPlayerPosLook.EnumFlags.X);
+ enumset.add(SPacketPlayerPosLook.EnumFlags.X);
if (!message.setY)
- enumset.add(S08PacketPlayerPosLook.EnumFlags.Y);
+ enumset.add(SPacketPlayerPosLook.EnumFlags.Y);
if (!message.setZ)
- enumset.add(S08PacketPlayerPosLook.EnumFlags.Z);
+ enumset.add(SPacketPlayerPosLook.EnumFlags.Z);
if (!message.setYaw)
- enumset.add(S08PacketPlayerPosLook.EnumFlags.Y_ROT);
+ enumset.add(SPacketPlayerPosLook.EnumFlags.Y_ROT);
if (!message.setPitch)
- enumset.add(S08PacketPlayerPosLook.EnumFlags.X_ROT);
+ enumset.add(SPacketPlayerPosLook.EnumFlags.X_ROT);
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
- player.mountEntity((Entity) null);
- player.playerNetServerHandler.setPlayerLocation(message.x, message.y, message.z, message.yaw, message.pitch, enumset);
+ player.dismountRidingEntity();
+ player.connection.setPlayerLocation(message.x, message.y, message.z, message.yaw, message.pitch, enumset);
player.setRotationYawHead(message.yaw);
}
});
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCatchingMobImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCatchingMobImplementation.java
index 07a0de972..91d12c418 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCatchingMobImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCatchingMobImplementation.java
@@ -5,7 +5,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
-import net.minecraft.util.BlockPos;
+import net.minecraft.util.math.BlockPos;
import com.microsoft.Malmo.MissionHandlerInterfaces.IWantToQuit;
import com.microsoft.Malmo.Schemas.AgentQuitFromCatchingMob;
@@ -46,7 +46,7 @@ public boolean doIWantToQuit(MissionInit missionInit)
{
// If global flag is false, our player needs to be adjacent to the mob in order to claim the reward.
BlockPos entityPos = new BlockPos(ent.posX, ent.posY, ent.posZ);
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
BlockPos playerPos = new BlockPos(player.posX, player.posY, player.posZ);
if (Math.abs(entityPos.getX() - playerPos.getX()) + Math.abs(entityPos.getZ() - playerPos.getZ()) > 1)
continue;
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCollectingItemImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCollectingItemImplementation.java
index 2c058a186..42b37c887 100644
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCollectingItemImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromCollectingItemImplementation.java
@@ -83,9 +83,9 @@ public void onGainItem(GainItemEvent event)
@SubscribeEvent
public void onPickupItem(EntityItemPickupEvent event)
{
- if (event.item != null && event.item.getEntityItem() != null)
+ if (event.getItem() != null && event.getItem().getEntityItem() != null)
{
- ItemStack stack = event.item.getEntityItem();
+ ItemStack stack = event.getItem().getEntityItem();
checkForMatch(stack);
}
}
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromReachingPositionImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromReachingPositionImplementation.java
index b979843b1..fc2277c75 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromReachingPositionImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromReachingPositionImplementation.java
@@ -53,7 +53,7 @@ public boolean doIWantToQuit(MissionInit missionInit)
if (missionInit == null || this.qrpparams == null)
return false;
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
for (PointWithToleranceAndDescription goal : this.qrpparams.getMarker())
{
float distance = PositionHelper.calcDistanceFromPlayerToPosition(player, goal);
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTimeUpImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTimeUpImplementation.java
index a36347d70..c83058e57 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTimeUpImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTimeUpImplementation.java
@@ -20,9 +20,9 @@
package com.microsoft.Malmo.MissionHandlers;
import net.minecraft.client.Minecraft;
-import net.minecraft.util.ChatComponentText;
-import net.minecraft.util.ChatStyle;
-import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.text.TextComponentString;
+import net.minecraft.util.text.Style;
+import net.minecraft.util.text.TextFormatting;
import com.microsoft.Malmo.Schemas.AgentQuitFromTimeUp;
import com.microsoft.Malmo.Schemas.MissionInit;
@@ -50,19 +50,19 @@ public boolean parseParameters(Object params)
@Override
protected long getWorldTime()
{
- return Minecraft.getMinecraft().theWorld.getTotalWorldTime();
+ return Minecraft.getMinecraft().world.getTotalWorldTime();
}
@Override
protected void drawCountDown(int secondsRemaining)
{
- ChatComponentText text = new ChatComponentText("" + secondsRemaining + "...");
- ChatStyle style = new ChatStyle();
+ TextComponentString text = new TextComponentString("" + secondsRemaining + "...");
+ Style style = new Style();
style.setBold(true);
if (secondsRemaining <= 5)
- style.setColor(EnumChatFormatting.RED);
+ style.setColor(TextFormatting.RED);
- text.setChatStyle(style);
+ text.setStyle(style);
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1);
}
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTouchingBlockTypeImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTouchingBlockTypeImplementation.java
index c64661d06..73b2dab14 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTouchingBlockTypeImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AgentQuitFromTouchingBlockTypeImplementation.java
@@ -27,7 +27,7 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
-import net.minecraft.util.BlockPos;
+import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@@ -81,11 +81,11 @@ public boolean doIWantToQuit(MissionInit missionInit)
if (this.wantToQuit)
return true;
- EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;
+ EntityPlayerSP player = Minecraft.getMinecraft().player;
List touchingBlocks = PositionHelper.getTouchingBlocks(player);
for (BlockPos pos : touchingBlocks)
{
- IBlockState bs = player.worldObj.getBlockState(pos);
+ IBlockState bs = player.world.getBlockState(pos);
// Does this block match our trigger specs?
String blockname = bs.getBlock().getUnlocalizedName().toLowerCase();
if (!this.blockTypeNames.contains(blockname))
@@ -148,7 +148,7 @@ private boolean findMatch(BlockSpec blockspec, IBlockState blockstate)
// Next, check for a colour match:
net.minecraft.item.EnumDyeColor blockColour = null;
- for (IProperty prop : (java.util.Set)blockstate.getProperties().keySet())
+ for (IProperty prop : blockstate.getProperties().keySet())
{
if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class)
{
@@ -160,7 +160,7 @@ private boolean findMatch(BlockSpec blockspec, IBlockState blockstate)
// Now check for the variant match:
Object blockVariant = null;
- for (IProperty prop : (java.util.Set)blockstate.getProperties().keySet())
+ for (IProperty prop : blockstate.getProperties().keySet())
{
if (prop.getName().equals("variant") && prop.getValueClass().isEnum())
{
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AnimationDecoratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AnimationDecoratorImplementation.java
index b9df1ab58..a3745f3aa 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AnimationDecoratorImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/AnimationDecoratorImplementation.java
@@ -25,8 +25,8 @@
import java.util.Random;
import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.BlockPos;
-import net.minecraft.util.Vec3;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import com.microsoft.Malmo.MissionHandlerInterfaces.IWorldDecorator;
@@ -42,10 +42,10 @@ public class AnimationDecoratorImplementation extends HandlerBase implements IWo
{
AnimationDecorator params = null;
AnimationDrawingHelper drawContext = new AnimationDrawingHelper();
- Vec3 origin;
- Vec3 velocity;
- Vec3 minCanvas;
- Vec3 maxCanvas;
+ Vec3d origin;
+ Vec3d velocity;
+ Vec3d minCanvas;
+ Vec3d maxCanvas;
int frameCount = 0;
int tickCounter = 0;
Random rng;
@@ -62,10 +62,10 @@ public boolean parseParameters(Object params)
if (this.params.getLinear() != null)
{
Linear linear = this.params.getLinear();
- this.origin = new Vec3(linear.getInitialPos().getX().doubleValue(), linear.getInitialPos().getY().doubleValue(), linear.getInitialPos().getZ().doubleValue());
- this.velocity = new Vec3(linear.getInitialVelocity().getX().doubleValue(), linear.getInitialVelocity().getY().doubleValue(), linear.getInitialVelocity().getZ().doubleValue());
- this.minCanvas = new Vec3(linear.getCanvasBounds().getMin().getX(), linear.getCanvasBounds().getMin().getY(), linear.getCanvasBounds().getMin().getZ());
- this.maxCanvas = new Vec3(linear.getCanvasBounds().getMax().getX(), linear.getCanvasBounds().getMax().getY(), linear.getCanvasBounds().getMax().getZ());
+ this.origin = new Vec3d(linear.getInitialPos().getX().doubleValue(), linear.getInitialPos().getY().doubleValue(), linear.getInitialPos().getZ().doubleValue());
+ this.velocity = new Vec3d(linear.getInitialVelocity().getX().doubleValue(), linear.getInitialVelocity().getY().doubleValue(), linear.getInitialVelocity().getZ().doubleValue());
+ this.minCanvas = new Vec3d(linear.getCanvasBounds().getMin().getX(), linear.getCanvasBounds().getMin().getY(), linear.getCanvasBounds().getMin().getZ());
+ this.maxCanvas = new Vec3d(linear.getCanvasBounds().getMax().getX(), linear.getCanvasBounds().getMax().getY(), linear.getCanvasBounds().getMax().getZ());
}
else
{
@@ -82,7 +82,7 @@ public boolean parseParameters(Object params)
double x = EvaluationHelper.eval(this.params.getParametric().getX(), 0, this.rng);
double y = EvaluationHelper.eval(this.params.getParametric().getY(), 0, this.rng);
double z = EvaluationHelper.eval(this.params.getParametric().getZ(), 0, this.rng);
- this.origin = new Vec3(x, y, z);
+ this.origin = new Vec3d(x, y, z);
}
catch (Exception e)
{
@@ -97,14 +97,14 @@ public boolean parseParameters(Object params)
}
@Override
- public void buildOnWorld(MissionInit missionInit) throws DecoratorException
+ public void buildOnWorld(MissionInit missionInit, World world) throws DecoratorException
{
if (this.origin == null)
throw new DecoratorException("Origin not specified - check syntax of equations?");
try
{
this.drawContext.setOrigin(this.origin);
- this.drawContext.Draw(this.params.getDrawingDecorator(), MinecraftServer.getServer().getEntityWorld());
+ this.drawContext.Draw(this.params.getDrawingDecorator(), world);
}
catch (Exception e)
{
@@ -136,7 +136,7 @@ public void update(World world)
dy = -dy;
if (this.drawContext.getMax().zCoord + dz > linear.getCanvasBounds().getMax().getZ() + 1.0 || this.drawContext.getMin().zCoord + dz < linear.getCanvasBounds().getMin().getZ())
dz = -dz;
- this.velocity = new Vec3(dx, dy, dz);
+ this.velocity = new Vec3d(dx, dy, dz);
this.origin = this.origin.add(this.velocity);
}
else
@@ -146,7 +146,7 @@ public void update(World world)
double x = EvaluationHelper.eval(this.params.getParametric().getX(), this.frameCount, this.rng);
double y = EvaluationHelper.eval(this.params.getParametric().getY(), this.frameCount, this.rng);
double z = EvaluationHelper.eval(this.params.getParametric().getZ(), this.frameCount, this.rng);
- this.origin = new Vec3(x, y, z);
+ this.origin = new Vec3d(x, y, z);
}
catch (Exception e)
{
@@ -160,8 +160,8 @@ public void update(World world)
try
{
this.drawContext.setOrigin(this.origin);
- this.drawContext.Draw(this.params.getDrawingDecorator(), MinecraftServer.getServer().getEntityWorld());
- this.drawContext.clearPrevious(MinecraftServer.getServer().getEntityWorld());
+ this.drawContext.Draw(this.params.getDrawingDecorator(), world);
+ this.drawContext.clearPrevious(world);
}
catch (Exception e)
{
diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/BuildBattleDecoratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/BuildBattleDecoratorImplementation.java
index b781e4322..560ac926f 100755
--- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/BuildBattleDecoratorImplementation.java
+++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/BuildBattleDecoratorImplementation.java
@@ -10,16 +10,14 @@
import net.minecraft.block.BlockSnow;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
-import net.minecraft.server.MinecraftServer;
-import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
-import net.minecraft.util.Vec3i;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent.BreakEvent;
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
-import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import com.microsoft.Malmo.MalmoMod;
@@ -47,6 +45,7 @@ public class BuildBattleDecoratorImplementation extends HandlerBase implements I
private List dest;
private int currentScore = 0;
private boolean valid = true;
+ private boolean initialised = false;
/**
* Attempt to parse the given object as a set of parameters for this handler.
@@ -82,7 +81,7 @@ public boolean parseParameters(Object params)
}
@Override
- public void buildOnWorld(MissionInit missionInit) throws DecoratorException
+ public void buildOnWorld(MissionInit missionInit, World world) throws DecoratorException
{
// Does nothing at the moment, though we could add an option to draw the bounds of the arenas here,
// if it seems to be something people want.
@@ -97,7 +96,12 @@ public boolean getExtraAgentHandlersAndData(List