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): 1000 true + 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): 13000 false + 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 handlers, Map 1) + kbp.removeKey(this.originalBinding); + return; + } + catch (IllegalArgumentException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + catch (IllegalAccessException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } } @Override diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/CommandForWheeledRobotNavigationImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/CommandForWheeledRobotNavigationImplementation.java index 339270cf8..5644c87c1 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/CommandForWheeledRobotNavigationImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/CommandForWheeledRobotNavigationImplementation.java @@ -25,7 +25,6 @@ import net.minecraft.util.MovementInput; import net.minecraft.util.MovementInputFromOptions; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -102,7 +101,7 @@ public CommandForWheeledRobotNavigationImplementation() private void init() { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; this.mVelocity = 0; this.mTargetVelocity = 0; this.mTicksSinceLastVelocityChange = 0; @@ -284,7 +283,7 @@ public void onRenderTick(TickEvent.RenderTickEvent ev) { if (this.isOverriding()) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (player != null) { updateYawAndPitch(); @@ -309,7 +308,7 @@ public void install(MissionInit missionInit) { // Create our movement hook, which allows us to override the Minecraft movement. this.overrideMovement = new MovementHook(Minecraft.getMinecraft().gameSettings); - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (player != null) { // Insert it into the player, keeping a record of the original movement object @@ -317,8 +316,7 @@ public void install(MissionInit missionInit) this.originalMovement = player.movementInput; player.movementInput = this.overrideMovement; } - - FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); } @@ -326,13 +324,12 @@ public void install(MissionInit missionInit) public void deinstall(MissionInit missionInit) { // Restore the player's normal movement control: - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (player != null) { player.movementInput = this.originalMovement; } - FMLCommonHandler.instance().bus().unregister(this); MinecraftForge.EVENT_BUS.unregister(this); } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DefaultWorldGeneratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DefaultWorldGeneratorImplementation.java index 53f70f504..72ea5d02c 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DefaultWorldGeneratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DefaultWorldGeneratorImplementation.java @@ -25,7 +25,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import net.minecraft.world.WorldSettings; -import net.minecraft.world.WorldSettings.GameType; +import net.minecraft.world.GameType; import net.minecraft.world.WorldType; import com.microsoft.Malmo.MissionHandlerInterfaces.IWorldGenerator; @@ -71,9 +71,8 @@ public static long getWorldSeedFromString(String seedString) public boolean createWorld(MissionInit missionInit) { long seed = getWorldSeedFromString(this.dwparams.getSeed()); - WorldType.worldTypes[0].onGUICreateWorldPress(); - WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.worldTypes[0]); - worldsettings.setWorldName(""); + WorldType.WORLD_TYPES[0].onGUICreateWorldPress(); + WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, true, false, WorldType.WORLD_TYPES[0]); worldsettings.enableCommands(); // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world // will be created, it will simply load the old one. @@ -81,17 +80,12 @@ public boolean createWorld(MissionInit missionInit) } @Override - public boolean shouldCreateWorld(MissionInit missionInit) + public boolean shouldCreateWorld(MissionInit missionInit, World world) { if (this.dwparams != null && this.dwparams.isForceReset()) return true; - World world = null; - MinecraftServer server = MinecraftServer.getServer(); - if (server.worldServers != null && server.worldServers.length != 0) - world = server.getEntityWorld(); - - if (Minecraft.getMinecraft().theWorld == null || world == null) + if (Minecraft.getMinecraft().world == null || world == null) return true; // Definitely need to create a world if there isn't one in existence! String genOptions = world.getWorldInfo().getGeneratorOptions(); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DiscreteMovementCommandsImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DiscreteMovementCommandsImplementation.java index 38e540c0b..71d1271dc 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DiscreteMovementCommandsImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DiscreteMovementCommandsImplementation.java @@ -26,15 +26,18 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; +import net.minecraft.entity.MoverType; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.IThreadListener; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -83,16 +86,19 @@ public static class UseActionMessage implements IMessage public ItemStack itemStack; public EnumFacing face; public boolean standOnPlacedBlock; + public Vec3d hitVec; + public UseActionMessage() { } - public UseActionMessage(BlockPos pos, ItemStack itemStack, EnumFacing face, boolean standOnPlacedBlock) + public UseActionMessage(BlockPos pos, ItemStack itemStack, EnumFacing face, boolean standOnPlacedBlock, Vec3d hitVec) { this.pos = pos; this.itemStack = itemStack; this.face = face; this.standOnPlacedBlock = standOnPlacedBlock; + this.hitVec = hitVec; } @Override @@ -102,6 +108,7 @@ public void fromBytes(ByteBuf buf) this.itemStack = ByteBufUtils.readItemStack(buf); this.face = EnumFacing.values()[buf.readInt()]; this.standOnPlacedBlock = buf.readBoolean(); + this.hitVec = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble()); } @Override @@ -113,6 +120,9 @@ public void toBytes(ByteBuf buf) ByteBufUtils.writeItemStack(buf, this.itemStack); buf.writeInt(this.face.ordinal()); buf.writeBoolean(this.standOnPlacedBlock); + buf.writeDouble(this.hitVec.xCoord); + buf.writeDouble(this.hitVec.yCoord); + buf.writeDouble(this.hitVec.zCoord); } } @@ -125,32 +135,32 @@ public IMessage onMessage(final UseActionMessage message, final MessageContext c if (ctx.side == Side.CLIENT) return null; // Not interested. - mainThread = MinecraftServer.getServer(); + mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world; mainThread.addScheduledTask(new Runnable() { @Override public void run() { EntityPlayerMP player = ctx.getServerHandler().playerEntity; - PlayerInteractEvent event = new PlayerInteractEvent(player, PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK, message.pos, message.face, player.worldObj); + PlayerInteractEvent event = new PlayerInteractEvent.RightClickBlock(player, EnumHand.MAIN_HAND, message.pos, message.face, message.hitVec); MinecraftForge.EVENT_BUS.post(event); if (!event.isCanceled()) { BlockPos pos = message.pos.add( message.face.getDirectionVec() ); Block b = Block.getBlockFromItem( message.itemStack.getItem() ); if( b != null ) { IBlockState blockType = b.getStateFromMeta( message.itemStack.getMetadata() ); - if (player.worldObj.setBlockState( pos, blockType )) + if (player.world.setBlockState( pos, blockType )) { - BlockSnapshot snapshot = new BlockSnapshot(player.worldObj, pos, blockType); - BlockEvent.PlaceEvent placeevent = new BlockEvent.PlaceEvent(snapshot, player.worldObj.getBlockState(message.pos), player); + BlockSnapshot snapshot = new BlockSnapshot(player.world, pos, blockType); + BlockEvent.PlaceEvent placeevent = new BlockEvent.PlaceEvent(snapshot, player.world.getBlockState(message.pos), player); MinecraftForge.EVENT_BUS.post(placeevent); // We set the block, so remove it from the inventory. - if (!player.theItemInWorldManager.isCreative()) + if (!player.isCreative()) { - if (player.inventory.getCurrentItem().stackSize > 1) - player.inventory.getCurrentItem().stackSize--; + if (player.inventory.getCurrentItem().getCount() > 1) + player.inventory.getCurrentItem().setCount(player.inventory.getCurrentItem().getCount() - 1); else - player.inventory.mainInventory[player.inventory.currentItem] = null; + player.inventory.mainInventory.get(player.inventory.currentItem).setCount(0); } if (message.standOnPlacedBlock) { @@ -171,14 +181,16 @@ public static class AttackActionMessage implements IMessage { public BlockPos pos; public EnumFacing face; + public Vec3d hitVec; public AttackActionMessage() { } - public AttackActionMessage(BlockPos hitPos, EnumFacing face) + public AttackActionMessage(BlockPos hitPos, EnumFacing face, Vec3d hitVec) { this.pos = hitPos; this.face = face; + this.hitVec = hitVec; } @Override @@ -186,6 +198,7 @@ public void fromBytes(ByteBuf buf) { this.pos = new BlockPos( buf.readInt(), buf.readInt(), buf.readInt() ); this.face = EnumFacing.values()[buf.readInt()]; + this.hitVec = new Vec3d(buf.readDouble(), buf.readDouble(), buf.readDouble() ); } @Override @@ -195,6 +208,9 @@ public void toBytes(ByteBuf buf) buf.writeInt(this.pos.getY()); buf.writeInt(this.pos.getZ()); buf.writeInt(this.face.ordinal()); + buf.writeDouble(this.hitVec.xCoord); + buf.writeDouble(this.hitVec.yCoord); + buf.writeDouble(this.hitVec.zCoord); } } @@ -207,18 +223,18 @@ public IMessage onMessage(final AttackActionMessage message, final MessageContex if (ctx.side == Side.CLIENT) return null; // Not interested. - mainThread = MinecraftServer.getServer(); + mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world; mainThread.addScheduledTask(new Runnable() { @Override public void run() { EntityPlayerMP player = ctx.getServerHandler().playerEntity; - IBlockState iblockstate = player.worldObj.getBlockState(message.pos); + IBlockState iblockstate = player.world.getBlockState(message.pos); Block block = iblockstate.getBlock(); - if (block.getMaterial() != Material.air) + if (iblockstate.getMaterial() != Material.AIR) { - PlayerInteractEvent event = new PlayerInteractEvent(player, PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, message.pos, message.face, player.worldObj); + PlayerInteractEvent event = new PlayerInteractEvent.LeftClickBlock(player, message.pos, message.face, message.hitVec); MinecraftForge.EVENT_BUS.post(event); if (!event.isCanceled()) { @@ -226,15 +242,15 @@ public void run() // We do things this way, rather than pass true for dropBlock in world.destroyBlock, // because we want this to take instant effect - we don't want the intermediate stage // of spawning a free-floating item that the player must pick up. - java.util.List items = block.getDrops(player.worldObj, message.pos, iblockstate, 0); - player.worldObj.destroyBlock( message.pos, dropBlock ); + java.util.List items = block.getDrops(player.world, message.pos, iblockstate, 0); + player.world.destroyBlock( message.pos, dropBlock ); for (ItemStack item : items) { if (!player.inventory.addItemStackToInventory(item)) { - Block.spawnAsEntity(player.worldObj, message.pos, item); // Didn't fit in inventory, so spawn it. + Block.spawnAsEntity(player.world, message.pos, item); // Didn't fit in inventory, so spawn it. } } - BlockEvent.BreakEvent breakevent = new BlockEvent.BreakEvent(player.worldObj, message.pos, iblockstate, player); + BlockEvent.BreakEvent breakevent = new BlockEvent.BreakEvent(player.world, message.pos, iblockstate, player); MinecraftForge.EVENT_BUS.post(breakevent); } } @@ -276,7 +292,7 @@ private DiscreteMovementCommand verbToCommand(String verb) protected boolean onExecute(String verb, String parameter, MissionInit missionInit) { boolean handled = false; - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (player != null) { int z = 0; @@ -362,17 +378,17 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn break; case ATTACK: { - MovingObjectPosition mop = Minecraft.getMinecraft().objectMouseOver; - if( mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK ) { + RayTraceResult mop = Minecraft.getMinecraft().objectMouseOver; + if( mop.typeOfHit == RayTraceResult.Type.BLOCK ) { BlockPos hitPos = mop.getBlockPos(); EnumFacing face = mop.sideHit; - IBlockState iblockstate = player.worldObj.getBlockState(hitPos); + IBlockState iblockstate = player.world.getBlockState(hitPos); Block block = iblockstate.getBlock(); - if (block.getMaterial() != Material.air) + if (iblockstate.getMaterial() != Material.AIR) { - MalmoMod.network.sendToServer(new AttackActionMessage(hitPos, face)); + MalmoMod.network.sendToServer(new AttackActionMessage(hitPos, face, mop.hitVec)); // Trigger a reward for collecting the block - java.util.List items = block.getDrops(player.worldObj, hitPos, iblockstate, 0); + java.util.List items = block.getDrops(player.world, hitPos, iblockstate, 0); for (ItemStack item : items) { RewardForCollectingItemImplementation.GainItemEvent event = new RewardForCollectingItemImplementation.GainItemEvent(item); @@ -386,22 +402,22 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn case USE: case JUMPUSE: { - MovingObjectPosition mop = getObjectMouseOver(command); - if( mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK ) + RayTraceResult mop = getObjectMouseOver(command); + if( mop.typeOfHit == RayTraceResult.Type.BLOCK ) { - if( player.getCurrentEquippedItem() != null ) { - ItemStack itemStack = player.getCurrentEquippedItem(); + if( player.inventory.getCurrentItem() != null ) { + ItemStack itemStack = player.inventory.getCurrentItem(); Block b = Block.getBlockFromItem( itemStack.getItem() ); if( b != null ) { BlockPos pos = mop.getBlockPos().add( mop.sideHit.getDirectionVec() ); // Can we place this block here? - AxisAlignedBB axisalignedbb = b.getCollisionBoundingBox(player.worldObj, pos, b.getDefaultState()); + AxisAlignedBB axisalignedbb = b.getDefaultState().getCollisionBoundingBox(player.world, pos); Entity exceptedEntity = (command == DiscreteMovementCommand.USE) ? null : player; // (Not ideal, but needed by jump-use to allow the player to place a block where their feet would be.) - if (axisalignedbb == null || player.worldObj.checkNoEntityCollision(axisalignedbb, exceptedEntity)) + if (axisalignedbb == null || player.world.checkNoEntityCollision(axisalignedbb, exceptedEntity)) { boolean standOnBlockPlaced = (command == DiscreteMovementCommand.JUMPUSE && mop.getBlockPos().equals(new BlockPos(player.posX, player.posY - 1, player.posZ))); - MalmoMod.network.sendToServer(new UseActionMessage(mop.getBlockPos(), itemStack, mop.sideHit, standOnBlockPlaced)); + MalmoMod.network.sendToServer(new UseActionMessage(mop.getBlockPos(), itemStack, mop.sideHit, standOnBlockPlaced, mop.hitVec)); } } } @@ -427,7 +443,7 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn if (this.params.isAutoJump() && y == 0 && (z != 0 || x != 0)) { // Do we need to jump? - if (!player.worldObj.getCollidingBoundingBoxes(player, player.getEntityBoundingBox().offset(x, 0, z)).isEmpty()) + if (!player.world.getCollisionBoxes(player, player.getEntityBoundingBox().offset(x, 0, z)).isEmpty()) y = 1; } @@ -436,7 +452,7 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn // Attempt to move the entity: double oldX = player.posX; double oldZ = player.posZ; - player.moveEntity(x, y, z); + player.move(MoverType.SELF, (double)x, (double)y, (double)z); player.onUpdate(); if (this.params.isAutoFall()) { @@ -446,7 +462,7 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn while (!player.onGround && !player.capabilities.isFlying && bailCountdown > 0) { // Fast-forward downwards. - player.moveEntity(0, Math.floor(player.posY-0.0000001) - player.posY, 0); + player.move(MoverType.SELF, 0.0, Math.floor(player.posY-0.0000001) - player.posY, 0.0); player.onUpdate(); bailCountdown--; } @@ -474,7 +490,7 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn DiscretePartialMoveEvent event = new DiscretePartialMoveEvent(player.posX, player.posY, player.posZ); MinecraftForge.EVENT_BUS.post(event); // Now adjust the player: - player.moveEntity(oldX - newX, 0, oldZ - newZ); + player.move(MoverType.SELF, oldX - newX, 0.0, oldZ - newZ); player.onUpdate(); } // Now set the last tick pos values, to turn off inter-tick positional interpolation: @@ -497,21 +513,21 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn return handled; } - private MovingObjectPosition getObjectMouseOver(DiscreteMovementCommand command) + private RayTraceResult getObjectMouseOver(DiscreteMovementCommand command) { - MovingObjectPosition mop = null; + RayTraceResult mop = null; if (command.equals(DiscreteMovementCommand.USE)) mop = Minecraft.getMinecraft().objectMouseOver; else if (command.equals(DiscreteMovementCommand.JUMPUSE)) { long partialTicks = 0; //Minecraft.timer.renderPartialTicks - Entity viewer = Minecraft.getMinecraft().thePlayer; + Entity viewer = Minecraft.getMinecraft().player; double blockReach = Minecraft.getMinecraft().playerController.getBlockReachDistance(); - Vec3 eyePos = viewer.getPositionEyes(partialTicks); - Vec3 lookVec = viewer.getLook(partialTicks); + Vec3d eyePos = viewer.getPositionEyes(partialTicks); + Vec3d lookVec = viewer.getLook(partialTicks); int yOffset = 1; // For the jump - Vec3 searchVec = eyePos.addVector(lookVec.xCoord * blockReach, yOffset + lookVec.yCoord * blockReach, lookVec.zCoord * blockReach); - mop = Minecraft.getMinecraft().theWorld.rayTraceBlocks(eyePos, searchVec, false, false, false); + Vec3d searchVec = eyePos.addVector(lookVec.xCoord * blockReach, yOffset + lookVec.yCoord * blockReach, lookVec.zCoord * blockReach); + mop = Minecraft.getMinecraft().world.rayTraceBlocks(eyePos, searchVec, false, false, false); } return mop; } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DrawingDecoratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DrawingDecoratorImplementation.java index 06bb0d7b7..a3c7a07c4 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DrawingDecoratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/DrawingDecoratorImplementation.java @@ -49,7 +49,7 @@ public boolean parseParameters(Object params) } @Override - public void buildOnWorld(MissionInit missionInit) + public void buildOnWorld(MissionInit missionInit, World world) { Mission mission = missionInit.getMission(); if (mission != null) @@ -57,7 +57,7 @@ public void buildOnWorld(MissionInit missionInit) try { BlockDrawingHelper drawContext = new BlockDrawingHelper(); - drawContext.Draw(this.drawing, MinecraftServer.getServer().getEntityWorld()); + drawContext.Draw(this.drawing, world); } catch (Exception e) { diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FileWorldGeneratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FileWorldGeneratorImplementation.java index 5abf5bd1c..a71b09d8e 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FileWorldGeneratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FileWorldGeneratorImplementation.java @@ -20,11 +20,17 @@ package com.microsoft.Malmo.MissionHandlers; import java.io.File; +import java.util.List; +import net.minecraft.client.AnvilConverterException; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiErrorScreen; +import net.minecraft.client.resources.I18n; import net.minecraft.server.MinecraftServer; import net.minecraft.server.integrated.IntegratedServer; import net.minecraft.world.World; +import net.minecraft.world.storage.ISaveFormat; +import net.minecraft.world.storage.WorldSummary; import com.microsoft.Malmo.MissionHandlerInterfaces.IWorldGenerator; import com.microsoft.Malmo.Schemas.FileWorldGenerator; @@ -79,10 +85,34 @@ public boolean createWorld(MissionInit missionInit) return false; } - net.minecraftforge.fml.client.FMLClientHandler.instance().tryLoadExistingWorld(null, mapCopy.getName(), mapSource.getName()); + ISaveFormat isaveformat = Minecraft.getMinecraft().getSaveLoader(); + List worldlist; + try + { + worldlist = isaveformat.getSaveList(); + } + catch (AnvilConverterException anvilconverterexception) + { + this.errorDetails = "Minecraft couldn't rebuild saved world list."; + return false; + } + + WorldSummary newWorld = null; + for (WorldSummary ws : worldlist) + { + if (ws.getFileName().equals(mapCopy.getName())) + newWorld = ws; + } + if (newWorld == null) + { + this.errorDetails = "Minecraft could not find the copied world."; + return false; + } + + net.minecraftforge.fml.client.FMLClientHandler.instance().tryLoadExistingWorld(null, newWorld); IntegratedServer server = Minecraft.getMinecraft().getIntegratedServer(); String worldName = (server != null) ? server.getWorldName() : null; - if (worldName == null || !worldName.equals(mapSource.getName())) + if (worldName == null || !worldName.equals(newWorld.getDisplayName())) { this.errorDetails = "Minecraft could not load " + this.mapFilename + " - is it a valid saved world?"; return false; @@ -92,16 +122,11 @@ public boolean createWorld(MissionInit missionInit) } @Override - public boolean shouldCreateWorld(MissionInit missionInit) + public boolean shouldCreateWorld(MissionInit missionInit, World world) { if (this.fwparams != null && this.fwparams.isForceReset()) return true; - World world = null; - MinecraftServer server = MinecraftServer.getServer(); - if (server.worldServers != null && server.worldServers.length != 0) - world = server.getEntityWorld(); - if (world == null) return true; // There is no world, so we definitely need to create one. @@ -109,7 +134,7 @@ public boolean shouldCreateWorld(MissionInit missionInit) // Extract the name from the path (need to cope with backslashes or forward slashes.) String mapfile = (this.mapFilename == null) ? "" : this.mapFilename; // Makes no sense to have an empty filename, but createWorld will deal with it graciously. String[] parts = mapfile.split("[\\\\/]"); - if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().theWorld != null) + if (name.length() > 0 && parts[parts.length - 1].equalsIgnoreCase(name) && Minecraft.getMinecraft().world != null) return false; // We don't check whether the game modes match - it's up to the server state machine to sort that out. return true; // There's no world, or the world is different to the basemap file, so create. diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FlatWorldGeneratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FlatWorldGeneratorImplementation.java index 0a9f57199..7d4f97ada 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FlatWorldGeneratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/FlatWorldGeneratorImplementation.java @@ -23,7 +23,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.world.World; import net.minecraft.world.WorldSettings; -import net.minecraft.world.WorldSettings.GameType; +import net.minecraft.world.GameType; import net.minecraft.world.WorldType; import com.microsoft.Malmo.MissionHandlerInterfaces.IWorldGenerator; @@ -52,7 +52,7 @@ public boolean createWorld(MissionInit missionInit) WorldSettings worldsettings = new WorldSettings(seed, GameType.SURVIVAL, false, false, WorldType.FLAT); // This call to setWorldName allows us to specify the layers of our world, and also the features that will be created. // This website provides a handy way to generate these strings: http://chunkbase.com/apps/superflat-generator - worldsettings.setWorldName(this.fwparams.getGeneratorString()); + worldsettings.setGeneratorOptions(this.fwparams.getGeneratorString()); worldsettings.enableCommands(); // Enables cheat commands. // Create a filename for this map - we use the time stamp to make sure it is different from other worlds, otherwise no new world // will be created, it will simply load the old one. @@ -60,17 +60,12 @@ public boolean createWorld(MissionInit missionInit) } @Override - public boolean shouldCreateWorld(MissionInit missionInit) + public boolean shouldCreateWorld(MissionInit missionInit, World world) { - World world = null; - MinecraftServer server = MinecraftServer.getServer(); - if (server.worldServers != null && server.worldServers.length != 0) - world = server.getEntityWorld(); - if (this.fwparams != null && this.fwparams.isForceReset()) return true; - if (Minecraft.getMinecraft().theWorld == null && world == null) + if (Minecraft.getMinecraft().world == null && world == null) return true; // Definitely need to create a world if there isn't one in existence! String genOptions = world.getWorldInfo().getGeneratorOptions(); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/InventoryCommandsImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/InventoryCommandsImplementation.java index 11d05828e..ec25cd856 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/InventoryCommandsImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/InventoryCommandsImplementation.java @@ -129,24 +129,24 @@ static void combineSlots(EntityPlayerMP player, int dst, int add) // Check we can combine. This logic comes from InventoryPlayer.storeItemStack(): boolean itemsMatch = dstStack.getItem() == addStack.getItem(); - boolean dstCanStack = dstStack.isStackable() && dstStack.stackSize < dstStack.getMaxStackSize() && dstStack.stackSize < inv.getInventoryStackLimit(); + boolean dstCanStack = dstStack.isStackable() && dstStack.getCount() < dstStack.getMaxStackSize() && dstStack.getCount() < inv.getInventoryStackLimit(); boolean subTypesMatch = !dstStack.getHasSubtypes() || dstStack.getMetadata() == addStack.getMetadata(); boolean tagsMatch = ItemStack.areItemStackTagsEqual(dstStack, addStack); if (itemsMatch && dstCanStack && subTypesMatch && tagsMatch) { // We can combine, so figure out how much we have room for: int limit = Math.min(dstStack.getMaxStackSize(), inv.getInventoryStackLimit()); - int room = limit - dstStack.stackSize; - if (addStack.stackSize > room) + int room = limit - dstStack.getCount(); + if (addStack.getCount() > room) { // Not room for all of it, so shift across as much as possible. - addStack.stackSize -= room; - dstStack.stackSize += room; + addStack.setCount(addStack.getCount() - room); + dstStack.setCount(dstStack.getCount() + room); } else { // Room for the whole lot, so empty out the add slot. - dstStack.stackSize += addStack.stackSize; + dstStack.setCount(dstStack.getCount() + addStack.getCount()); inv.setInventorySlotContents(add, null); } } @@ -197,7 +197,7 @@ else if (verb.equalsIgnoreCase(InventoryCommand.COMBINE_INVENTORY_ITEMS.value()) else if (verb.equalsIgnoreCase(InventoryCommand.DISCARD_CURRENT_ITEM.value())) { // This we can do on the client side: - Minecraft.getMinecraft().thePlayer.dropOneItem(false); // false means just drop one item - true means drop everything in the current stack. + Minecraft.getMinecraft().player.dropItem(false); // false means just drop one item - true means drop everything in the current stack. return true; } return super.onExecute(verb, parameter, missionInit); @@ -227,7 +227,7 @@ private boolean getParameters(String parameter, List parsedParams) System.out.println("Malformed parameter string (" + parameter + ")"); return false; // Error - incorrect parameters. } - InventoryPlayer inv = Minecraft.getMinecraft().thePlayer.inventory; + InventoryPlayer inv = Minecraft.getMinecraft().player.inventory; if (lhs < 0 || lhs >= inv.getSizeInventory() || rhs < 0 || rhs >= inv.getSizeInventory()) { System.out.println("Inventory swap parameters out of bounds - must be between 0 and " + (inv.getSizeInventory() - 1)); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MazeDecoratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MazeDecoratorImplementation.java index 81ade49b8..54fe23e36 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MazeDecoratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MazeDecoratorImplementation.java @@ -28,7 +28,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.microsoft.Malmo.MissionHandlerInterfaces.IWorldDecorator; @@ -495,7 +495,7 @@ private void findSubgoals(Cell[] grid, Cell start, Cell end) int cellindex = cellx + cellz * width; if (cellindex < 0 || cellindex >= grid.length || grid[cellindex] == null) walkable = false; - if (walkable && gapHeight > optimalPathHeight && !gapBlock.equals(Blocks.air.getDefaultState())) + if (walkable && gapHeight > optimalPathHeight && !gapBlock.equals(Blocks.AIR.getDefaultState())) { // The "gaps" are in fact walls, so we need to be a bit more conservative with our path, since the // player has a width of 0.4 cells. We do this in a very unsophisticated, brute-force manor by testing @@ -594,11 +594,11 @@ private void placeBlocks(World world, Cell[] grid, Cell start, Cell end) bs = this.waypointBlock; h = this.pathHeight; } - else + else if (this.waypointItem != null) { // Place a waypoint item here: int offset = 0;//(scale % 2 == 0) ? 1 : 0; - drawContext.placeItem(ItemStack.copyItemStack(this.waypointItem), new BlockPos(x + this.xOrg + offset, this.yOrg + h + 1, z + this.zOrg + offset), world, (scale % 2 == 1)); + drawContext.placeItem(this.waypointItem.copy(), new BlockPos(x + this.xOrg + offset, this.yOrg + h + 1, z + this.zOrg + offset), world, (scale % 2 == 1)); } } if (c != null && c == start) @@ -659,7 +659,7 @@ private void recordStartAndEndPoints(Cell start, Cell end, MissionInit missionIn } @Override - public void buildOnWorld(MissionInit missionInit) + public void buildOnWorld(MissionInit missionInit, World world) { // Set up various parameters according to the XML specs: initRNGs(); @@ -696,7 +696,6 @@ public void buildOnWorld(MissionInit missionInit) findSubgoals(grid, start, end); // Now build the actual Minecraft world: - World world = MinecraftServer.getServer().getEntityWorld(); placeBlocks(world, grid, start, end); // Finally, write the start and goal points into the MissionInit data structure for the other MissionHandlers to use: diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionQuitCommandsImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionQuitCommandsImplementation.java index cb5723cc0..d6d7827d3 100644 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionQuitCommandsImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MissionQuitCommandsImplementation.java @@ -38,7 +38,7 @@ public class MissionQuitCommandsImplementation extends CommandBase implements IC @Override protected boolean onExecute(String verb, String parameter, MissionInit missionInit) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (player == null) { return false; diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MovingTargetDecoratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MovingTargetDecoratorImplementation.java index 7e1002bf3..efe326637 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MovingTargetDecoratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/MovingTargetDecoratorImplementation.java @@ -13,8 +13,8 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.microsoft.Malmo.MalmoMod; @@ -80,10 +80,9 @@ public boolean parseParameters(Object params) } @Override - public void buildOnWorld(MissionInit missionInit) throws DecoratorException + public void buildOnWorld(MissionInit missionInit, World world) throws DecoratorException { this.path.add(this.startPos); - World world = MinecraftServer.getServer().getEntityWorld(); this.originalPath.add(world.getBlockState(this.startPos)); BlockDrawingHelper drawContext = new BlockDrawingHelper(); drawContext.beginDrawing(world); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromChatImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromChatImplementation.java index 983fafed3..1a4a0fc8e 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromChatImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromChatImplementation.java @@ -66,6 +66,6 @@ public void cleanup() @SubscribeEvent public void onEvent(ClientChatReceivedEvent event) { - this.chatMessagesReceived.add(event.message.getUnformattedText()); + this.chatMessagesReceived.add(event.getMessage().getUnformattedText()); } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDiscreteCellImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDiscreteCellImplementation.java index 73ae31296..654b1b254 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDiscreteCellImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDiscreteCellImplementation.java @@ -32,7 +32,7 @@ public class ObservationFromDiscreteCellImplementation extends HandlerBase imple public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) { // Return a string that is unique for every cell on the x/z plane (ignores y) - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; // getPosition() rounds to int. int x = player.getPosition().getX(); int z = player.getPosition().getZ(); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDistanceImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDistanceImplementation.java index 9c1393ce5..6649f63b7 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDistanceImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromDistanceImplementation.java @@ -51,7 +51,7 @@ public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) { for (NamedPoint marker : odparams.getMarker()) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; json.addProperty("distanceFrom" + makeSafe(marker.getName()), PositionHelper.calcDistanceFromPlayerToPosition(player, marker)); } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromFullInventoryImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromFullInventoryImplementation.java index 1f5474f7a..31d458cf4 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromFullInventoryImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromFullInventoryImplementation.java @@ -36,20 +36,20 @@ public class ObservationFromFullInventoryImplementation extends HandlerBase impl @Override public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; getInventoryJSON(json, "InventorySlot_", player.inventory.getSizeInventory()); } public static void getInventoryJSON(JsonObject json, String prefix, int maxSlot) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; int nSlots = Math.min(player.inventory.getSizeInventory(), maxSlot); for (int i = 0; i < nSlots; i++) { ItemStack is = player.inventory.getStackInSlot(i); if (is != null) { - json.addProperty(prefix + i + "_size", is.stackSize); + json.addProperty(prefix + i + "_size", is.getCount()); DrawItem di = MinecraftTypeHelper.getDrawItemFromItemStack(is); String name = di.getType(); if (di.getColour() != null) diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromNearbyEntitiesImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromNearbyEntitiesImplementation.java index 3672a47b7..96f111fa3 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromNearbyEntitiesImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromNearbyEntitiesImplementation.java @@ -24,7 +24,9 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -59,10 +61,10 @@ public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) { this.tickCount++; - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; // Get all the currently loaded entities: - List entities = Minecraft.getMinecraft().theWorld.getLoadedEntityList(); + List entities = Minecraft.getMinecraft().world.getLoadedEntityList(); // Get the list of RangeDefinitions that need firing: List rangesToFire = new ArrayList(); @@ -118,7 +120,7 @@ public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) jsent.addProperty("y", e.posY); jsent.addProperty("z", e.posZ); jsent.addProperty("pitch", e.rotationPitch); - String name = e.getName(); + String name = MinecraftTypeHelper.getUnlocalisedEntityName(e); if (e instanceof EntityItem) { ItemStack is = ((EntityItem)e).getEntityItem(); @@ -131,7 +133,7 @@ public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) if (di.getVariant() != null) jsent.addProperty("variation", di.getVariant().getValue()); } - jsent.addProperty("quantity", is.stackSize); + jsent.addProperty("quantity", is.getCount()); } else if (e instanceof EntityLivingBase) { diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromRayImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromRayImplementation.java index 6430bf3be..7e5c6a2d1 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromRayImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromRayImplementation.java @@ -28,9 +28,9 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.Vec3d; import com.google.gson.JsonObject; import com.microsoft.Malmo.MissionHandlerInterfaces.IObservationProducer; @@ -66,13 +66,13 @@ public static void buildMouseOverData(JsonObject json) // We could use Minecraft.getMinecraft().objectMouseOver but it's limited to the block reach distance, and // doesn't register floating tile items. float partialTicks = 0; // Ideally use Minecraft.timer.renderPartialTicks - but we don't need sub-tick resolution. - Entity viewer = Minecraft.getMinecraft().thePlayer; + Entity viewer = Minecraft.getMinecraft().player; float depth = 50; // Hard-coded for now - in future will be parameterised via the XML. - Vec3 eyePos = viewer.getPositionEyes(partialTicks); - Vec3 lookVec = viewer.getLook(partialTicks); - Vec3 searchVec = eyePos.addVector(lookVec.xCoord * depth, lookVec.yCoord * depth, lookVec.zCoord * depth); - MovingObjectPosition mop = Minecraft.getMinecraft().theWorld.rayTraceBlocks(eyePos, searchVec, false, false, false); - MovingObjectPosition mopEnt = findEntity(eyePos, lookVec, depth, mop, true); + Vec3d eyePos = viewer.getPositionEyes(partialTicks); + Vec3d lookVec = viewer.getLook(partialTicks); + Vec3d searchVec = eyePos.addVector(lookVec.xCoord * depth, lookVec.yCoord * depth, lookVec.zCoord * depth); + RayTraceResult mop = Minecraft.getMinecraft().world.rayTraceBlocks(eyePos, searchVec, false, false, false); + RayTraceResult mopEnt = findEntity(eyePos, lookVec, depth, mop, true); if (mopEnt != null) mop = mopEnt; if (mop == null) @@ -85,14 +85,14 @@ public static void buildMouseOverData(JsonObject json) double entityReach = Minecraft.getMinecraft().playerController.extendedReach() ? 6.0 : 3.0; JsonObject jsonMop = new JsonObject(); - if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) + if (mop.typeOfHit == RayTraceResult.Type.BLOCK) { // We're looking at a block - send block data: jsonMop.addProperty("hitType", "block"); jsonMop.addProperty("x", mop.hitVec.xCoord); jsonMop.addProperty("y", mop.hitVec.yCoord); jsonMop.addProperty("z", mop.hitVec.zCoord); - IBlockState state = Minecraft.getMinecraft().theWorld.getBlockState(mop.getBlockPos()); + IBlockState state = Minecraft.getMinecraft().world.getBlockState(mop.getBlockPos()); List extraProperties = new ArrayList(); DrawBlock db = MinecraftTypeHelper.getDrawBlockFromBlockState(state, extraProperties); jsonMop.addProperty("type", db.getType().value()); @@ -119,7 +119,7 @@ else if (prop.getValueClass() == Integer.class) jsonMop.addProperty("inRange", hitDist <= blockReach); jsonMop.addProperty("distance", hitDist); } - else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) + else if (mop.typeOfHit == RayTraceResult.Type.ENTITY) { // Looking at an entity: Entity entity = mop.entityHit; @@ -130,7 +130,7 @@ else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) jsonMop.addProperty("z", entity.posZ); jsonMop.addProperty("yaw", entity.rotationYaw); jsonMop.addProperty("pitch", entity.rotationPitch); - String name = entity.getName(); + String name = MinecraftTypeHelper.getUnlocalisedEntityName(entity); String hitType = "entity"; if (entity instanceof EntityItem) { @@ -140,7 +140,7 @@ else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) jsonMop.addProperty("colour", di.getColour().value()); if (di.getVariant() != null) jsonMop.addProperty("variant", di.getVariant().getValue()); - jsonMop.addProperty("stackSize", is.stackSize); + jsonMop.addProperty("stackSize", is.getCount()); name = di.getType(); hitType = "item"; } @@ -153,17 +153,17 @@ else if (mop.typeOfHit == MovingObjectPosition.MovingObjectType.ENTITY) json.add("LineOfSight", jsonMop); } - static MovingObjectPosition findEntity(Vec3 eyePos, Vec3 lookVec, double depth, MovingObjectPosition mop, boolean includeTiles) + static RayTraceResult findEntity(Vec3d eyePos, Vec3d lookVec, double depth, RayTraceResult mop, boolean includeTiles) { // Based on code in EntityRenderer.getMouseOver() if (mop != null) depth = mop.hitVec.distanceTo(eyePos); - Vec3 searchVec = eyePos.addVector(lookVec.xCoord * depth, lookVec.yCoord * depth, lookVec.zCoord * depth); + Vec3d searchVec = eyePos.addVector(lookVec.xCoord * depth, lookVec.yCoord * depth, lookVec.zCoord * depth); Entity pointedEntity = null; - Vec3 hitVec = null; - Entity viewer = Minecraft.getMinecraft().thePlayer; - List list = Minecraft.getMinecraft().theWorld.getEntitiesWithinAABBExcludingEntity(viewer, viewer.getEntityBoundingBox().addCoord(lookVec.xCoord * depth, lookVec.yCoord * depth, lookVec.zCoord * depth).expand(1.0, 1.0, 1.0)); + Vec3d hitVec = null; + Entity viewer = Minecraft.getMinecraft().player; + List list = Minecraft.getMinecraft().world.getEntitiesWithinAABBExcludingEntity(viewer, viewer.getEntityBoundingBox().addCoord(lookVec.xCoord * depth, lookVec.yCoord * depth, lookVec.zCoord * depth).expand(1.0, 1.0, 1.0)); double distance = depth; for (int i = 0; i < list.size(); ++i) @@ -173,7 +173,7 @@ static MovingObjectPosition findEntity(Vec3 eyePos, Vec3 lookVec, double depth, { float border = entity.getCollisionBorderSize(); AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox().expand((double)border, (double)border, (double)border); - MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(eyePos, searchVec); + RayTraceResult movingobjectposition = axisalignedbb.calculateIntercept(eyePos, searchVec); if (axisalignedbb.isVecInside(eyePos)) { // If entity is right inside our head? @@ -189,7 +189,7 @@ else if (movingobjectposition != null) double distToEnt = eyePos.distanceTo(movingobjectposition.hitVec); if (distToEnt < distance || distance == 0.0D) { - if (entity == entity.ridingEntity && !entity.canRiderInteract()) + if (entity == entity.getRidingEntity() && !entity.canRiderInteract()) { if (distance == 0.0D) { @@ -209,7 +209,7 @@ else if (movingobjectposition != null) } if (pointedEntity != null && (distance < depth || mop == null)) { - MovingObjectPosition newMop = new MovingObjectPosition(pointedEntity, hitVec); + RayTraceResult newMop = new RayTraceResult(pointedEntity, hitVec); return newMop; } return null; diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromServer.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromServer.java index 84ea21e9d..ac4178684 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromServer.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromServer.java @@ -27,7 +27,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.IThreadListener; import net.minecraft.world.WorldServer; -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.network.simpleimpl.IMessage; @@ -37,8 +37,8 @@ import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.microsoft.Malmo.MalmoMod; -import com.microsoft.Malmo.MalmoMod.MalmoMessageType; import com.microsoft.Malmo.MalmoMod.IMalmoMessageListener; +import com.microsoft.Malmo.MalmoMod.MalmoMessageType; import com.microsoft.Malmo.MissionHandlerInterfaces.IObservationProducer; import com.microsoft.Malmo.Schemas.MissionInit; @@ -67,7 +67,7 @@ public abstract class ObservationFromServer extends HandlerBase implements IMalm ObservationFromServer() { // Register for client ticks so we can keep requesting stats. - FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent @@ -205,7 +205,7 @@ public ObservationRequestMessageHandler() /** IMPORTANT: Call this from the onMessage method in the subclass. */ public IMessage processMessage(final ObservationRequestMessage message, final MessageContext ctx) { - IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.worldObj; + IThreadListener mainThread = (WorldServer)ctx.getServerHandler().playerEntity.world; mainThread.addScheduledTask(new Runnable() { @Override public void run() { diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromSubgoalPositionListImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromSubgoalPositionListImplementation.java index aad1081d2..1e862989c 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromSubgoalPositionListImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ObservationFromSubgoalPositionListImplementation.java @@ -50,7 +50,7 @@ public void writeObservationsToJSON(JsonObject json, MissionInit missionInit) boolean foundNextPoint = false; double targetx = 0; double targetz = 0; - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if (player == null) return; // Nothing we can do. diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/QuitFromTimeUpBase.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/QuitFromTimeUpBase.java index bf32c9d77..cf55539a8 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/QuitFromTimeUpBase.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/QuitFromTimeUpBase.java @@ -46,7 +46,7 @@ protected void setTimeLimitMs(float limit) @Override public boolean doIWantToQuit(MissionInit missionInit) { - if (missionInit == null || missionInit.getMission() == null || Minecraft.getMinecraft().theWorld == null) + if (missionInit == null || missionInit.getMission() == null || Minecraft.getMinecraft().world == null) return false; // Initialise our start-of-mission time: diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCatchingMobImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCatchingMobImplementation.java index f05be4b54..5563d4cfb 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCatchingMobImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCatchingMobImplementation.java @@ -7,7 +7,7 @@ import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import com.microsoft.Malmo.Schemas.EntityTypes; @@ -33,10 +33,10 @@ public boolean parseParameters(Object params) static List getCaughtEntities() { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - World world = player.worldObj; + EntityPlayerSP player = Minecraft.getMinecraft().player; + World world = player.world; // Get all the currently loaded entities: - List entities = Minecraft.getMinecraft().theWorld.getLoadedEntityList(); + List entities = Minecraft.getMinecraft().world.getLoadedEntityList(); // Now filter out all the player entities: List entityPositions = new ArrayList(); for (Object obj : entities) @@ -104,7 +104,7 @@ public void getReward(MissionInit missionInit, MultidimensionalReward reward) { // If global flag is false, our player needs to be adjacent to the mob in order to claim the reward. BlockPos entityPos = new BlockPos(e.posX, e.posY, e.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/RewardForCollectingItemImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCollectingItemImplementation.java index 14dd88519..6907e56d2 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCollectingItemImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForCollectingItemImplementation.java @@ -97,10 +97,10 @@ public void onGainItem(GainItemEvent event) @SubscribeEvent public void onPickupItem(EntityItemPickupEvent event) { - if (event.item != null && event.entityPlayer instanceof EntityPlayerMP ) + if (event.getItem() != null && event.getEntityPlayer() instanceof EntityPlayerMP ) { // This event is received on the server side, so we need to pass it to the client. - sendItemStackToClient((EntityPlayerMP)event.entityPlayer, MalmoMessageType.SERVER_COLLECTITEM, event.item.getEntityItem()); + sendItemStackToClient((EntityPlayerMP)event.getEntityPlayer(), MalmoMessageType.SERVER_COLLECTITEM, event.getItem().getEntityItem()); } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDamagingEntityImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDamagingEntityImplementation.java index 5a40bf4f0..cff5f4b55 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDamagingEntityImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDamagingEntityImplementation.java @@ -35,7 +35,7 @@ public boolean parseParameters(Object params) public void getReward(MissionInit missionInit, MultidimensionalReward reward) { super.getReward(missionInit, reward); - if (missionInit == null || Minecraft.getMinecraft().thePlayer == null) + if (missionInit == null || Minecraft.getMinecraft().player == null) return; synchronized (this.damages) { @@ -67,7 +67,7 @@ public void cleanup() @SubscribeEvent public void onLivingAttackEvent(LivingAttackEvent event) { - if (event.entity == null || event.source.getEntity() != Minecraft.getMinecraft().thePlayer) + if (event.getEntity() == null || event.getSource().getEntity() != Minecraft.getMinecraft().player) return; synchronized (this.damages) { @@ -77,12 +77,12 @@ public void onLivingAttackEvent(LivingAttackEvent event) for (EntityTypes et : mob.getType()) { String mobName = et.value(); - if (event.entity.getName().equals(mobName)) + if (event.getEntity().getName().equals(mobName)) { if (this.damages.containsKey(mob)) - this.damages.put(mob, this.damages.get(mob) + event.ammount); + this.damages.put(mob, this.damages.get(mob) + event.getAmount()); else - this.damages.put(mob, event.ammount); + this.damages.put(mob, event.getAmount()); } } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDiscardingItemImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDiscardingItemImplementation.java index bd98ef603..a5a8cefb8 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDiscardingItemImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForDiscardingItemImplementation.java @@ -99,20 +99,20 @@ public void onLoseItem(LoseItemEvent event) @SubscribeEvent public void onTossItem(ItemTossEvent event) { - if (event.entityItem != null && event.player instanceof EntityPlayerMP) + if (event.getEntityItem() != null && event.getPlayer() instanceof EntityPlayerMP) { - ItemStack stack = event.entityItem.getEntityItem(); - sendItemStackToClient((EntityPlayerMP)event.player, MalmoMessageType.SERVER_DISCARDITEM, stack); + ItemStack stack = event.getEntityItem().getEntityItem(); + sendItemStackToClient((EntityPlayerMP)event.getPlayer(), MalmoMessageType.SERVER_DISCARDITEM, stack); } } @SubscribeEvent public void onPlaceBlock(BlockEvent.PlaceEvent event) { - if (event.itemInHand != null && event.player instanceof EntityPlayerMP ) + if (event.getPlayer().getHeldItem(event.getHand()) != null && event.getPlayer() instanceof EntityPlayerMP ) { // This event is received on the server side, so we need to pass it to the client. - sendItemStackToClient((EntityPlayerMP)event.player, MalmoMessageType.SERVER_DISCARDITEM, event.itemInHand); + sendItemStackToClient((EntityPlayerMP)event.getPlayer(), MalmoMessageType.SERVER_DISCARDITEM, event.getPlayer().getHeldItem(event.getHand())); } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForItemBase.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForItemBase.java index 18bbd9396..add335d6e 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForItemBase.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForItemBase.java @@ -125,7 +125,7 @@ protected void accumulateReward(int dimension, ItemStack stack) { if (matcher.matches(stack)) { - addAndShareCachedReward(dimension, stack.stackSize * matcher.reward(), matcher.distribution()); + addAndShareCachedReward(dimension, stack.getCount() * matcher.reward(), matcher.distribution()); } } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForReachingPositionImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForReachingPositionImplementation.java index bf39ba9bd..788bc15e5 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForReachingPositionImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForReachingPositionImplementation.java @@ -58,7 +58,7 @@ public boolean parseParameters(Object params) { @Override public void getReward(MissionInit missionInit, MultidimensionalReward reward) { super.getReward(missionInit, reward); - if (missionInit == null || Minecraft.getMinecraft().thePlayer == null) + if (missionInit == null || Minecraft.getMinecraft().player == null) return; if (this.rewardPoints != null) { @@ -69,7 +69,7 @@ public void getReward(MissionInit missionInit, MultidimensionalReward reward) { float reward_value = goal.getReward().floatValue(); float tolerance = goal.getTolerance().floatValue(); - float distance = PositionHelper.calcDistanceFromPlayerToPosition(Minecraft.getMinecraft().thePlayer, goal); + float distance = PositionHelper.calcDistanceFromPlayerToPosition(Minecraft.getMinecraft().player, goal); if (distance <= tolerance) { float adjusted_reward = adjustAndDistributeReward(reward_value, this.params.getDimension(), goal.getDistribution()); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForStructureCopyingImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForStructureCopyingImplementation.java index 980b9892d..96a1c63b1 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForStructureCopyingImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForStructureCopyingImplementation.java @@ -3,7 +3,6 @@ import java.util.Map; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; import com.microsoft.Malmo.MalmoMod; import com.microsoft.Malmo.MalmoMod.IMalmoMessageListener; @@ -87,7 +86,6 @@ public void prepare(MissionInit missionInit) { super.prepare(missionInit); MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); MalmoMod.MalmoMessageHandler.registerForMessage(this, MalmoMessageType.SERVER_BUILDBATTLEREWARD); if (this.rscparams.getAddQuitProducer() != null) @@ -130,7 +128,6 @@ public void cleanup() { super.cleanup(); MinecraftForge.EVENT_BUS.unregister(this); - FMLCommonHandler.instance().bus().unregister(this); structureHasBeenCompleted = false; MalmoMod.MalmoMessageHandler.deregisterForMessage(this, MalmoMessageType.SERVER_MISSIONOVER); } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForTouchingBlockTypeImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForTouchingBlockTypeImplementation.java index 707737e34..45bdd06d2 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForTouchingBlockTypeImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/RewardForTouchingBlockTypeImplementation.java @@ -26,7 +26,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; @@ -141,11 +141,11 @@ private void calculateReward(MultidimensionalReward reward) { // Determine what blocks we are touching. // This code is largely cribbed from Entity, where it is used to fire the Block.onEntityCollidedWithBlock methods. - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; List touchingBlocks = PositionHelper.getTouchingBlocks(player); for (BlockPos pos : touchingBlocks) { - IBlockState iblockstate = player.worldObj.getBlockState(pos); + IBlockState iblockstate = player.world.getBlockState(pos); for (BlockMatcher bm : this.matchers) { if (bm.applies(pos) && bm.matches(pos, iblockstate)) { diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ServerQuitFromTimeUpImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ServerQuitFromTimeUpImplementation.java index de6b5b14a..633dfef09 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ServerQuitFromTimeUpImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/ServerQuitFromTimeUpImplementation.java @@ -23,8 +23,9 @@ import java.util.Map; import net.minecraft.server.MinecraftServer; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; +import net.minecraftforge.fml.common.FMLCommonHandler; import com.microsoft.Malmo.MalmoMod; import com.microsoft.Malmo.MalmoMod.MalmoMessageType; @@ -55,9 +56,8 @@ public boolean parseParameters(Object params) protected long getWorldTime() { World world = null; - MinecraftServer server = MinecraftServer.getServer(); - if (server.worldServers != null && server.worldServers.length != 0) - world = server.getEntityWorld(); + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + world = server.getEntityWorld(); return (world != null) ? world.getTotalWorldTime() : 0; } @@ -66,9 +66,9 @@ protected void drawCountDown(int secondsRemaining) { Map data = new HashMap(); - String text = EnumChatFormatting.BOLD + "" + secondsRemaining + "..."; + String text = TextFormatting.BOLD + "" + secondsRemaining + "..."; if (secondsRemaining <= 5) - text = EnumChatFormatting.RED + text; + text = TextFormatting.RED + text; data.put("chat", text); MalmoMod.safeSendToAll(MalmoMessageType.SERVER_TEXT, data); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/SnakeDecoratorImplementation.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/SnakeDecoratorImplementation.java index 32e7d298c..7cac407a5 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/SnakeDecoratorImplementation.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/SnakeDecoratorImplementation.java @@ -28,7 +28,7 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -75,10 +75,10 @@ public class SnakeDecoratorImplementation extends HandlerBase implements IWorldD public SnakeDecoratorImplementation() { - Block fresh = (Block)Block.blockRegistry.getObject(new ResourceLocation(this.freshBlockName)); - Block stale = (Block)Block.blockRegistry.getObject(new ResourceLocation(this.staleBlockName)); - this.freshBlock = (fresh != null) ? fresh.getDefaultState() : Blocks.glowstone.getDefaultState(); - this.staleBlock = (stale != null) ? stale.getDefaultState() : Blocks.air.getDefaultState(); + Block fresh = (Block)Block.REGISTRY.getObject(new ResourceLocation(this.freshBlockName)); + Block stale = (Block)Block.REGISTRY.getObject(new ResourceLocation(this.staleBlockName)); + this.freshBlock = (fresh != null) ? fresh.getDefaultState() : Blocks.GLOWSTONE.getDefaultState(); + this.staleBlock = (stale != null) ? stale.getDefaultState() : Blocks.AIR.getDefaultState(); } @Override @@ -101,8 +101,7 @@ public void update(World world) { BlockPos bp = this.path.get(this.path.size() - 1); // Create the block, or a gap if we are leaving a gap: - world.setBlockState(bp, this.consecutiveGaps == 0 ? this.freshBlock : Blocks.air.getDefaultState()); - world.markBlockForUpdate(bp); + world.setBlockState(bp, this.consecutiveGaps == 0 ? this.freshBlock : Blocks.AIR.getDefaultState()); this.pendingBlock = false; // Create space above and below this block (even if we are leaving a gap): @@ -242,7 +241,7 @@ private Variation chooseVariant(List vars, Random r) } @Override - public void buildOnWorld(MissionInit missionInit) + public void buildOnWorld(MissionInit missionInit, World world) { initRNGs(); initBlocks(); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/WorldFromComposite.java b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/WorldFromComposite.java index c6356b267..b09c69cd2 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/WorldFromComposite.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/MissionHandlers/WorldFromComposite.java @@ -40,11 +40,11 @@ public void addBuilder(IWorldDecorator builder) } @Override - public void buildOnWorld(MissionInit missionInit) throws DecoratorException + public void buildOnWorld(MissionInit missionInit, World world) throws DecoratorException { for (IWorldDecorator builder : this.builders) { - builder.buildOnWorld(missionInit); + builder.buildOnWorld(missionInit, world); } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/OverclockingClassTransformer.java b/Minecraft/src/main/java/com/microsoft/Malmo/OverclockingClassTransformer.java index 9b9900a71..47a8f3a85 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/OverclockingClassTransformer.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/OverclockingClassTransformer.java @@ -19,7 +19,6 @@ package com.microsoft.Malmo; -import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.launchwrapper.IClassTransformer; import org.objectweb.asm.ClassReader; diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Server/MalmoModServer.java b/Minecraft/src/main/java/com/microsoft/Malmo/Server/MalmoModServer.java index 37de2f5e2..00b0eaff1 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Server/MalmoModServer.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Server/MalmoModServer.java @@ -19,12 +19,11 @@ package com.microsoft.Malmo.Server; -import com.microsoft.Malmo.Schemas.MissionInit; - import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import com.microsoft.Malmo.Schemas.MissionInit; + public class MalmoModServer { private ServerStateMachine stateMachine; @@ -55,7 +54,6 @@ public void sendMissionInitDirectToServer(MissionInit minit) private void initBusses() { // Register for various events: - FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Server/ServerStateMachine.java b/Minecraft/src/main/java/com/microsoft/Malmo/Server/ServerStateMachine.java index f9b753e1e..11e1d1de1 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Server/ServerStateMachine.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Server/ServerStateMachine.java @@ -26,7 +26,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Set; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; @@ -36,12 +35,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.launchwrapper.Launch; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.management.ServerConfigurationManager; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.server.management.PlayerList; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.GameType; import net.minecraft.world.World; -import net.minecraft.world.WorldSettings.GameType; -import net.minecraft.world.biome.BiomeGenBase.SpawnListEntry; +import net.minecraft.world.WorldServer; +import net.minecraft.world.biome.Biome.SpawnListEntry; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn; import net.minecraftforge.event.world.WorldEvent.PotentialSpawns; @@ -131,7 +131,7 @@ protected void setUserTurnSchedule(ArrayList schedule) protected boolean checkWatchList() { - String[] connected_users = MinecraftServer.getServer().getAllUsernames(); + String[] connected_users = FMLCommonHandler.instance().getMinecraftServerInstance().getOnlinePlayerNames(); if (connected_users.length < this.userConnectionWatchList.size()) return false; @@ -186,7 +186,6 @@ public ServerStateMachine(ServerState initialState, MissionInit minit) private void initBusses() { // Register ourself on the event busses, so we can harness the server tick: - FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); } @@ -229,12 +228,13 @@ public void onGetPotentialSpawns(PotentialSpawns ps) if (allowSpawning && sic.getAllowedMobs() != null && !sic.getAllowedMobs().isEmpty()) { // Spawning is allowed, but restricted to our list: - Iterator it = ps.list.iterator(); + Iterator it = ps.getList().iterator(); while (it.hasNext()) { // Is this on our list? SpawnListEntry sle = it.next(); - String mobName = EntityList.classToStringMapping.get(sle.entityClass).toString(); + net.minecraftforge.fml.common.registry.EntityEntry entry = net.minecraftforge.fml.common.registry.EntityRegistry.getEntry(sle.entityClass); + String mobName = entry == null ? null : entry.getName(); boolean allowed = false; for (EntityTypes mob : sic.getAllowedMobs()) { @@ -271,7 +271,7 @@ public void onCheckSpawn(CheckSpawn cs) { // Spawning is allowed, but restricted to our list. // Is this mob on our list? - String mobName = EntityList.classToStringMapping.get(cs.entity.getClass()).toString(); + String mobName = EntityList.getEntityString(cs.getEntity()); allowSpawning = false; for (EntityTypes mob : sic.getAllowedMobs()) { @@ -496,11 +496,12 @@ private void checkForMissionCommand() throws Exception protected void onReceiveMissionInit(MissionInit missionInit) { + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); System.out.println("Mission received: " + missionInit.getMission().getAbout().getSummary()); - ChatComponentText txtMission = new ChatComponentText("Received mission: " + EnumChatFormatting.BLUE + missionInit.getMission().getAbout().getSummary()); - ChatComponentText txtSource = new ChatComponentText("Source: " + EnumChatFormatting.GREEN + missionInit.getClientAgentConnection().getAgentIPAddress()); - MinecraftServer.getServer().getConfigurationManager().sendChatMsg(txtMission); - MinecraftServer.getServer().getConfigurationManager().sendChatMsg(txtSource); + TextComponentString txtMission = new TextComponentString("Received mission: " + TextFormatting.BLUE + missionInit.getMission().getAbout().getSummary()); + TextComponentString txtSource = new TextComponentString("Source: " + TextFormatting.GREEN + missionInit.getClientAgentConnection().getAgentIPAddress()); + server.getPlayerList().sendMessage(txtMission); + server.getPlayerList().sendMessage(txtSource); ServerStateMachine.this.currentMissionInit = missionInit; // Create the Mission Handlers @@ -532,6 +533,8 @@ protected BuildingWorldEpisode(ServerStateMachine machine) @Override protected void execute() { + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + World world = server.getEntityWorld(); MissionBehaviour handlers = this.ssmachine.getHandlers(); // Assume the world has been created correctly - now do the necessary building. boolean builtOkay = true; @@ -539,7 +542,7 @@ protected void execute() { try { - handlers.worldDecorator.buildOnWorld(this.ssmachine.currentMissionInit()); + handlers.worldDecorator.buildOnWorld(this.ssmachine.currentMissionInit(), world); } catch (DecoratorException e) { @@ -558,7 +561,7 @@ protected void execute() if (builtOkay) { // Now set up other attributes of the environment (eg weather) - EnvironmentHelper.setMissionWeather(currentMissionInit()); + EnvironmentHelper.setMissionWeather(currentMissionInit(), server.getEntityWorld().getWorldInfo()); episodeHasCompleted(ServerState.WAITING_FOR_AGENTS_TO_ASSEMBLE); } } @@ -789,7 +792,7 @@ private AgentSection getAgentSectionFromAgentName(String agentname) private EntityPlayerMP getPlayerFromUsername(String username) { - ServerConfigurationManager scoman = MinecraftServer.getServer().getConfigurationManager(); + PlayerList scoman = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); EntityPlayerMP player = scoman.getPlayerByUsername(username); return player; } @@ -804,8 +807,8 @@ private void initialisePlayer(String username, String agentname) if ((player.getHealth() <= 0 || player.isDead || !player.isEntityAlive())) { player.markPlayerActive(); - player = MinecraftServer.getServer().getConfigurationManager().recreatePlayerEntity(player, player.dimension, false); - player.playerNetServerHandler.playerEntity = player; + player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().recreatePlayerEntity(player, player.dimension, false); + player.connection.playerEntity = player; } // Reset their food and health: @@ -965,7 +968,7 @@ protected void onServerTick(ServerTickEvent ev) private void initialiseInventory(EntityPlayerMP player, Inventory inventory) { // Clear inventory: - player.inventory.func_174925_a(null, -1, -1, null); + player.inventory.clearMatchingItems(null, -1, -1, null); player.inventoryContainer.detectAndSendChanges(); if (!player.capabilities.isCreativeMode) player.updateHeldItem(); @@ -981,7 +984,7 @@ private void initialiseInventory(EntityPlayerMP player, Inventory inventory) ItemStack item = MinecraftTypeHelper.getItemStackFromDrawItem(di); if( item != null ) { - item.stackSize = obj.getQuantity(); + item.setCount(obj.getQuantity()); player.inventory.setInventorySlotContents(obj.getSlot(), item); } } @@ -1064,7 +1067,7 @@ else if (messageType == MalmoMessageType.CLIENT_TURN_TAKEN) else { // Find the relevant agent; send a message to it. - ServerConfigurationManager scoman = MinecraftServer.getServer().getConfigurationManager(); + PlayerList scoman = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); EntityPlayerMP player = scoman.getPlayerByUsername(nextAgentName); if (player != null) { @@ -1097,12 +1100,12 @@ protected void execute() if (sic != null && sic.getTime() != null) { boolean allowTimeToPass = (sic.getTime().isAllowPassageOfTime() != Boolean.FALSE); // Defaults to true if unspecified. - MinecraftServer server = MinecraftServer.getServer(); - if (server.worldServers != null && server.worldServers.length != 0) + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + if (server.worlds != null && server.worlds.length != 0) { - for (int i = 0; i < MinecraftServer.getServer().worldServers.length; ++i) + for (int i = 0; i < server.worlds.length; ++i) { - World world = MinecraftServer.getServer().worldServers[i]; + World world = server.worlds[i]; world.getGameRules().setOrCreateGameRule("doDaylightCycle", allowTimeToPass ? "true" : "false"); if (sic.getTime().getStartTime() != null) world.setWorldTime(sic.getTime().getStartTime()); @@ -1125,7 +1128,7 @@ protected void execute() if (!ServerStateMachine.this.userTurnSchedule.isEmpty()) { String agentName = ServerStateMachine.this.userTurnSchedule.get(0); - ServerConfigurationManager scoman = MinecraftServer.getServer().getConfigurationManager(); + PlayerList scoman = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList(); EntityPlayerMP player = scoman.getPlayerByUsername(agentName); if (player != null) { @@ -1147,7 +1150,7 @@ protected void onServerTick(ServerTickEvent ev) if (!ServerStateMachine.this.checkWatchList()) onError(null); // We've lost a connection - abort the mission. - + if (ev.phase == Phase.START) { // Measure our performance - especially useful if we've been overclocked. @@ -1166,14 +1169,12 @@ protected void onServerTick(ServerTickEvent ev) this.tickCount++; } + MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + if (ev.phase == Phase.END && getHandlers() != null && getHandlers().worldDecorator != null) { - MinecraftServer server = MinecraftServer.getServer(); - if (server.worldServers != null && server.worldServers.length != 0) - { - World world = server.getEntityWorld(); - getHandlers().worldDecorator.update(world); - } + World world = server.getEntityWorld(); + getHandlers().worldDecorator.update(world); } if (ev.phase == Phase.END) @@ -1192,9 +1193,9 @@ else if (this.runningAgents.isEmpty()) // We set the weather just after building the world, but it's not a permanent setting, // and apparently there is a known bug in Minecraft that means the weather sometimes changes early. // To get around this, we reset it periodically. - if (MinecraftServer.getServer().getTickCounter() % 500 == 0) + if (server.getTickCounter() % 500 == 0) { - EnvironmentHelper.setMissionWeather(currentMissionInit()); + EnvironmentHelper.setMissionWeather(currentMissionInit(), server.getEntityWorld().getWorldInfo()); } } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/StateEpisode.java b/Minecraft/src/main/java/com/microsoft/Malmo/StateEpisode.java index 3e7e28fb0..a1c96de91 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/StateEpisode.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/StateEpisode.java @@ -20,9 +20,7 @@ package com.microsoft.Malmo; import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingSpawnEvent.CheckSpawn; import net.minecraftforge.event.world.ChunkEvent; -import net.minecraftforge.event.world.WorldEvent.PotentialSpawns; import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/StateMachine.java b/Minecraft/src/main/java/com/microsoft/Malmo/StateMachine.java index eca04ff5e..a7d50a356 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/StateMachine.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/StateMachine.java @@ -22,10 +22,9 @@ import java.util.ArrayList; import java.util.logging.Level; -import com.microsoft.Malmo.Utils.TCPUtils; - import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; + +import com.microsoft.Malmo.Utils.TCPUtils; /** * Class designed to track and control the state of the mod, especially regarding mission launching/running.
@@ -84,7 +83,6 @@ public StateMachine(IState initialState) this.homeThread = Thread.currentThread(); // Register the EventWrapper on the event busses: - FMLCommonHandler.instance().bus().register(this.eventWrapper); MinecraftForge.EVENT_BUS.register(this.eventWrapper); } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AddressHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AddressHelper.java index fce102b0a..438ad8aa8 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AddressHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AddressHelper.java @@ -19,7 +19,7 @@ package com.microsoft.Malmo.Utils; -import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.ModMetadata; @@ -69,9 +69,9 @@ static public void setMissionControlPort(int port) // Also update our metadata, for displaying to the user: ModMetadata md = Loader.instance().activeModContainer().getMetadata(); if (port != -1) - md.description = "Talk to this Mod using port " + EnumChatFormatting.GREEN + port; + md.description = "Talk to this Mod using port " + TextFormatting.GREEN + port; else - md.description = EnumChatFormatting.RED + "ERROR: No mission control port - check configuration"; + md.description = TextFormatting.RED + "ERROR: No mission control port - check configuration"; // See if changing the port should lead to changing the login details: //AuthenticationHelper.update(MalmoMod.instance.getModPermanentConfigFile()); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AnimationDrawingHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AnimationDrawingHelper.java index 21780822f..a35ea6000 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AnimationDrawingHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AnimationDrawingHelper.java @@ -7,17 +7,17 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -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; public class AnimationDrawingHelper extends BlockDrawingHelper { - Vec3 origin = new Vec3(0,0,0); + Vec3d origin = new Vec3d(0,0,0); Set drawing = new HashSet(); Set previousFrame; - Vec3 minPos; - Vec3 maxPos; + Vec3d minPos; + Vec3d maxPos; @Override public void beginDrawing(World w) @@ -40,28 +40,28 @@ public void clearPrevious(World w) { for (BlockPos pos : this.previousFrame) { - w.setBlockState(pos, Blocks.air.getDefaultState(), 3); + w.setBlockState(pos, Blocks.AIR.getDefaultState(), 3); } } this.previousFrame = null; } - public Vec3 getMin() + public Vec3d getMin() { return this.minPos; } - public Vec3 getMax() + public Vec3d getMax() { return this.maxPos; } - public Vec3 getOrigin() + public Vec3d getOrigin() { return this.origin; } - public void setOrigin(Vec3 org) + public void setOrigin(Vec3d org) { this.origin = org; } @@ -73,24 +73,24 @@ public void setBlockState(World w, BlockPos pos, XMLBlockState state) this.drawing.add(offsetPos); this.previousFrame.remove(offsetPos); if (this.minPos == null) - this.minPos = new Vec3(offsetPos.getX() - 0.5, offsetPos.getY(), offsetPos.getZ() - 0.5); + this.minPos = new Vec3d(offsetPos.getX() - 0.5, offsetPos.getY(), offsetPos.getZ() - 0.5); else { double x = Math.min(this.minPos.xCoord, offsetPos.getX() - 0.5); double y = Math.min(this.minPos.yCoord, offsetPos.getY() - 0.5); double z = Math.min(this.minPos.zCoord, offsetPos.getZ() - 0.5); if (x != this.minPos.xCoord || y != this.minPos.yCoord || z != this.minPos.zCoord) - this.minPos = new Vec3(x,y,z); + this.minPos = new Vec3d(x,y,z); } if (this.maxPos == null) - this.maxPos = new Vec3(offsetPos.getX() + 0.5, offsetPos.getY() + 1, offsetPos.getZ() + 0.5); + this.maxPos = new Vec3d(offsetPos.getX() + 0.5, offsetPos.getY() + 1, offsetPos.getZ() + 0.5); else { double x = Math.max(this.maxPos.xCoord, offsetPos.getX() + 0.5); double y = Math.max(this.maxPos.yCoord, offsetPos.getY() + 0.5); double z = Math.max(this.maxPos.zCoord, offsetPos.getZ() + 0.5); if (x != this.maxPos.xCoord || y != this.maxPos.yCoord || z != this.maxPos.zCoord) - this.maxPos = new Vec3(x,y,z); + this.maxPos = new Vec3d(x,y,z); } super.setBlockState(w, offsetPos, state); } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AuthenticationHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AuthenticationHelper.java index af576f244..ed88f2399 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AuthenticationHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/AuthenticationHelper.java @@ -33,7 +33,7 @@ public static boolean setPlayerName(Session currentSession, String newPlayerName return true; // Create new session object: - Session newSession = new Session(newPlayerName, currentSession.getPlayerID(), currentSession.getToken(), currentSession.getSessionType().toString()); + Session newSession = new Session(newPlayerName, currentSession.getPlayerID(), currentSession.getToken(), "mojang"/*currentSession.getSessionType().toString()*/); return setSession(newSession); } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/BlockDrawingHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/BlockDrawingHelper.java index ccc5479ee..2b5c20312 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/BlockDrawingHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/BlockDrawingHelper.java @@ -30,16 +30,19 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.BlockPos; +import net.minecraft.tileentity.TileEntityNote; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.entity.EntityLivingBase; +import net.minecraftforge.fml.common.registry.EntityEntry; import com.microsoft.Malmo.Schemas.BlockType; import com.microsoft.Malmo.Schemas.Colour; @@ -52,6 +55,7 @@ import com.microsoft.Malmo.Schemas.DrawingDecorator; import com.microsoft.Malmo.Schemas.EntityTypes; import com.microsoft.Malmo.Schemas.Facing; +import com.microsoft.Malmo.Schemas.NoteTypes; import com.microsoft.Malmo.Schemas.ShapeTypes; import com.microsoft.Malmo.Schemas.Variation; @@ -344,9 +348,22 @@ private void DrawPrimitive( DrawItem i, World w ) throws Exception */ private void DrawPrimitive( DrawEntity e, World w ) throws Exception { - String entityName = e.getType().getValue(); + String oldEntityName = e.getType().getValue(); + String id = null; + for (EntityEntry ent : net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES) + { + if (ent.getName().equals(oldEntityName)) + { + id = ent.getRegistryName().toString(); + break; + } + } + if (id == null) + return; + NBTTagCompound nbttagcompound = new NBTTagCompound(); - nbttagcompound.setString("id", entityName); + nbttagcompound.setString("id", id); + nbttagcompound.setBoolean("PersistenceRequired", true); // Don't let this entity despawn Entity entity; try { @@ -366,7 +383,7 @@ private void DrawPrimitive( DrawEntity e, World w ) throws Exception ((EntityLivingBase)entity).renderYawOffset = e.getYaw().floatValue(); } w.getBlockState(entity.getPosition()); // Force-load the chunk if necessary, to ensure spawnEntity will work. - if (!w.spawnEntityInWorld(entity)) + if (!w.spawnEntity(entity)) { System.out.println("WARNING: Failed to spawn entity! Chunk not loaded?"); } @@ -397,7 +414,7 @@ public void placeItem(ItemStack stack, BlockPos pos, World world, boolean centre entityitem.motionY = 0; entityitem.motionZ = 0; entityitem.setDefaultPickupDelay(); - world.spawnEntityInWorld(entityitem); + world.spawnEntity(entityitem); } protected EntityItem createItem(ItemStack stack, double x, double y, double z, World w, boolean centreItem) @@ -485,7 +502,7 @@ public void setBlockState(World w, BlockPos pos, XMLBlockState state) try { EntityTypes entvar = EntityTypes.fromValue(state.variant.getValue()); - ((TileEntityMobSpawner)te).getSpawnerBaseLogic().setEntityName(entvar.value()); + ((TileEntityMobSpawner)te).getSpawnerBaseLogic().setEntityId(new ResourceLocation(entvar.value())); } catch (Exception e) { @@ -493,5 +510,25 @@ public void setBlockState(World w, BlockPos pos, XMLBlockState state) } } } + if (state.type == BlockType.NOTEBLOCK) + { + TileEntity te = w.getTileEntity(pos); + if (te != null && te instanceof TileEntityNote) + { + try + { + NoteTypes note = NoteTypes.fromValue(state.variant.getValue()); + if (note != null) + { + // User has requested a particular note. + ((TileEntityNote)te).note = (byte)note.ordinal(); + } + } + catch (IllegalArgumentException e) + { + // Wasn't a note variation. Ignore. + } + } + } } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/CraftingHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/CraftingHelper.java index 2dc51137d..7e274682f 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/CraftingHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/CraftingHelper.java @@ -40,6 +40,7 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraft.util.NonNullList; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; @@ -80,7 +81,7 @@ public static List getIngredients(IRecipe recipe) } else if (recipe instanceof ShapelessOreRecipe) { - ArrayList objs = ((ShapelessOreRecipe)recipe).getInput(); + NonNullList objs = ((ShapelessOreRecipe)recipe).getInput(); for (Object o : objs) { if (o != null) @@ -153,7 +154,7 @@ public static List consolidateItemStacks(List inputStacks) if (destIS != null && sourceIS != null && itemStackIngredientsMatch(destIS, sourceIS)) { bFound = true; - destIS.stackSize += sourceIS.stackSize; + destIS.setCount(destIS.getCount() + sourceIS.getCount()); } } if (!bFound) @@ -170,17 +171,17 @@ public static List consolidateItemStacks(List inputStacks) */ public static boolean playerHasIngredients(EntityPlayerMP player, List ingredients) { - ItemStack[] main = player.inventory.mainInventory; - ItemStack[] arm = player.inventory.armorInventory; + NonNullList main = player.inventory.mainInventory; + NonNullList arm = player.inventory.armorInventory; for (ItemStack isIngredient : ingredients) { - int target = isIngredient.stackSize; - for (int i = 0; i < main.length + arm.length && target > 0; i++) + int target = isIngredient.getCount(); + for (int i = 0; i < main.size() + arm.size() && target > 0; i++) { - ItemStack isPlayer = (i >= main.length) ? arm[i - main.length] : main[i]; + ItemStack isPlayer = (i >= main.size()) ? arm.get(i - main.size()) : main.get(i); if (isPlayer != null && isIngredient != null && itemStackIngredientsMatch(isPlayer, isIngredient)) - target -= isPlayer.stackSize; + target -= isPlayer.getCount(); } if (target > 0) return false; // Don't have enough of this. @@ -212,9 +213,9 @@ public static int totalBurnTimeInInventory(EntityPlayerMP player) { Integer fromCache = fuelCaches.get(player); int total = (fromCache != null) ? fromCache : 0; - for (int i = 0; i < player.inventory.mainInventory.length; i++) + for (int i = 0; i < player.inventory.mainInventory.size(); i++) { - ItemStack is = player.inventory.mainInventory[i]; + ItemStack is = player.inventory.mainInventory.get(i); total += TileEntityFurnace.getItemBurnTime(is); } return total; @@ -233,30 +234,30 @@ public static void burnInventory(EntityPlayerMP player, int burnAmount, ItemStac else fuelCaches.put(player, fuelCaches.get(player) - burnAmount); int index = 0; - while (fuelCaches.get(player) < 0 && index < player.inventory.mainInventory.length) + while (fuelCaches.get(player) < 0 && index < player.inventory.mainInventory.size()) { - ItemStack is = player.inventory.mainInventory[index]; + ItemStack is = player.inventory.mainInventory.get(index); if (is != null) { int burnTime = TileEntityFurnace.getItemBurnTime(is); if (burnTime != 0) { // Consume item: - if (is.stackSize > 1) - is.stackSize--; + if (is.getCount() > 1) + is.setCount(is.getCount() - 1); else { // If this is a bucket of lava, we need to consume the lava but leave the bucket. - if (is.getItem() == Items.lava_bucket) + if (is.getItem() == Items.LAVA_BUCKET) { // And if we're cooking wet sponge, we need to leave the bucket filled with water. - if (input.getItem() == Item.getItemFromBlock(Blocks.sponge) && input.getMetadata() == 1) - player.inventory.mainInventory[index] = new ItemStack(Items.water_bucket); + if (input.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && input.getMetadata() == 1) + player.inventory.mainInventory.set(index, new ItemStack(Items.WATER_BUCKET)); else - player.inventory.mainInventory[index] = new ItemStack(Items.bucket); + player.inventory.mainInventory.set(index, new ItemStack(Items.BUCKET)); } else - player.inventory.mainInventory[index] = null; + player.inventory.mainInventory.get(index).setCount(0); index++; } fuelCaches.put(player, fuelCaches.get(player) + burnTime); @@ -275,29 +276,29 @@ public static void burnInventory(EntityPlayerMP player, int burnAmount, ItemStac */ public static void removeIngredientsFromPlayer(EntityPlayerMP player, List ingredients) { - ItemStack[] main = player.inventory.mainInventory; - ItemStack[] arm = player.inventory.armorInventory; + NonNullList main = player.inventory.mainInventory; + NonNullList arm = player.inventory.armorInventory; for (ItemStack isIngredient : ingredients) { - int target = isIngredient.stackSize; - for (int i = 0; i < main.length + arm.length && target > 0; i++) + int target = isIngredient.getCount(); + for (int i = 0; i < main.size() + arm.size() && target > 0; i++) { - ItemStack isPlayer = (i >= main.length) ? arm[i - main.length] : main[i]; + ItemStack isPlayer = (i >= main.size()) ? arm.get(i - main.size()) : main.get(i); if (isPlayer != null && isIngredient != null && itemStackIngredientsMatch(isPlayer, isIngredient)) { - if (target >= isPlayer.stackSize) + if (target >= isPlayer.getCount()) { // Consume this stack: - target -= isPlayer.stackSize; - if (i >= main.length) - arm[i - main.length] = null; + target -= isPlayer.getCount(); + if (i >= main.size()) + arm.get(i - main.size()).setCount(0); else - main[i] = null; + main.get(i).setCount(0); } else { - isPlayer.stackSize -= target; + isPlayer.setCount(isPlayer.getCount() - target); target = 0; } } @@ -441,14 +442,14 @@ public static void dumpRecipes(String filename) throws IOException ItemStack is = ((IRecipe)obj).getRecipeOutput(); if (is == null) continue; - String s = is.stackSize + "x" + is.getUnlocalizedName() + " = "; + String s = is.getCount() + "x" + is.getUnlocalizedName() + " = "; List ingredients = getIngredients((IRecipe)obj); boolean first = true; for (ItemStack isIngredient : ingredients) { if (!first) s += ", "; - s += isIngredient.stackSize + "x" + isIngredient.getUnlocalizedName(); + s += isIngredient.getCount() + "x" + isIngredient.getUnlocalizedName(); s += "(" + isIngredient.getDisplayName() + ")"; first = false; } @@ -461,7 +462,7 @@ public static void dumpRecipes(String filename) throws IOException { ItemStack isInput = (ItemStack)furnaceIt.next(); ItemStack isOutput = (ItemStack)FurnaceRecipes.instance().getSmeltingList().get(isInput); - String s = isOutput.stackSize + "x" + isOutput.getUnlocalizedName() + " = FUEL + " + isInput.stackSize + "x" + isInput.getUnlocalizedName() + "\n"; + String s = isOutput.getCount() + "x" + isOutput.getUnlocalizedName() + " = FUEL + " + isInput.getCount() + "x" + isInput.getUnlocalizedName() + "\n"; writer.write(s); } writer.close(); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/EnvironmentHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/EnvironmentHelper.java index 1c86fd5a3..d41d42be4 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/EnvironmentHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/EnvironmentHelper.java @@ -19,8 +19,6 @@ package com.microsoft.Malmo.Utils; -import net.minecraft.server.MinecraftServer; -import net.minecraft.world.WorldServer; import net.minecraft.world.storage.WorldInfo; import com.microsoft.Malmo.Schemas.MissionInit; @@ -29,7 +27,7 @@ public class EnvironmentHelper { - public static void setMissionWeather(MissionInit minit) + public static void setMissionWeather(MissionInit minit, WorldInfo worldinfo) { ServerSection ss = minit.getMission().getServerSection(); ServerInitialConditions sic = (ss != null) ? ss.getServerInitialConditions() : null; @@ -40,9 +38,6 @@ public static void setMissionWeather(MissionInit minit) int raintime = (sic.getWeather().equalsIgnoreCase("rain")) ? maxtime : 0; int thundertime = (sic.getWeather().equalsIgnoreCase("thunder")) ? maxtime : 0; - WorldServer worldserver = MinecraftServer.getServer().worldServers[0]; - WorldInfo worldinfo = worldserver.getWorldInfo(); - worldinfo.setCleanWeatherTime(cleartime); worldinfo.setRainTime(raintime); worldinfo.setThunderTime(thundertime); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/JSONWorldDataHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/JSONWorldDataHelper.java index e4b559c29..16dcfe1e0 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/JSONWorldDataHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/JSONWorldDataHelper.java @@ -23,9 +23,9 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.stats.StatBase; -import net.minecraft.stats.StatFileWriter; import net.minecraft.stats.StatList; -import net.minecraft.util.BlockPos; +import net.minecraft.stats.StatisticsManagerServer; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.ResourceLocation; import com.google.gson.JsonArray; @@ -99,18 +99,18 @@ public GridDimensions(int xMargin, int zMargin) { */ public static void buildAchievementStats(JsonObject json, EntityPlayerMP player) { - StatFileWriter sfw = player.getStatFile(); + StatisticsManagerServer sfw = player.getStatFile(); json.addProperty("DistanceTravelled", - sfw.readStat((StatBase)StatList.distanceWalkedStat) - + sfw.readStat((StatBase)StatList.distanceSwumStat) - + sfw.readStat((StatBase)StatList.distanceDoveStat) - + sfw.readStat((StatBase)StatList.distanceFallenStat) + sfw.readStat((StatBase)StatList.WALK_ONE_CM) + + sfw.readStat((StatBase)StatList.SWIM_ONE_CM) + + sfw.readStat((StatBase)StatList.DIVE_ONE_CM) + + sfw.readStat((StatBase)StatList.FALL_ONE_CM) ); // TODO: there are many other ways of moving! - json.addProperty("TimeAlive", sfw.readStat((StatBase)StatList.timeSinceDeathStat)); - json.addProperty("MobsKilled", sfw.readStat((StatBase)StatList.mobKillsStat)); - json.addProperty("PlayersKilled", sfw.readStat((StatBase)StatList.playerKillsStat)); - json.addProperty("DamageTaken", sfw.readStat((StatBase)StatList.damageTakenStat)); - json.addProperty("DamageDealt", sfw.readStat((StatBase)StatList.damageDealtStat)); + json.addProperty("TimeAlive", sfw.readStat((StatBase)StatList.TIME_SINCE_DEATH)); + json.addProperty("MobsKilled", sfw.readStat((StatBase)StatList.MOB_KILLS)); + json.addProperty("PlayersKilled", sfw.readStat((StatBase)StatList.PLAYER_KILLS)); + json.addProperty("DamageTaken", sfw.readStat((StatBase)StatList.DAMAGE_TAKEN)); + json.addProperty("DamageDealt", sfw.readStat((StatBase)StatList.DAMAGE_DEALT)); /* Other potential reinforcement signals that may be worth researching: json.addProperty("BlocksDestroyed", sfw.readStat((StatBase)StatList.objectBreakStats) - but objectBreakStats is an array of 32000 StatBase objects - indexed by block type.); @@ -146,8 +146,8 @@ public static void buildPositionStats(JsonObject json, EntityPlayerMP player) public static void buildEnvironmentStats(JsonObject json, EntityPlayerMP player) { - json.addProperty("WorldTime", player.worldObj.getWorldTime()); // Current time in ticks - json.addProperty("TotalTime", player.worldObj.getTotalWorldTime()); // Total time world has been running + json.addProperty("WorldTime", player.world.getWorldTime()); // Current time in ticks + json.addProperty("TotalTime", player.world.getTotalWorldTime()); // Total time world has been running } /** * Build a signal for the cubic block grid centred on the player.
@@ -178,8 +178,8 @@ public static void buildGridData(JsonObject json, GridDimensions environmentDime else p = pos.add(x, y, z); String name = ""; - IBlockState state = player.worldObj.getBlockState(p); - Object blockName = Block.blockRegistry.getNameForObject(state.getBlock()); + IBlockState state = player.world.getBlockState(p); + Object blockName = Block.REGISTRY.getNameForObject(state.getBlock()); if (blockName instanceof ResourceLocation) { name = ((ResourceLocation)blockName).getResourcePath(); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MapFileHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MapFileHelper.java index e3e6dcc9d..f72db21e8 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MapFileHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MapFileHelper.java @@ -28,7 +28,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.world.WorldSettings; import net.minecraft.world.storage.ISaveFormat; -import net.minecraft.world.storage.SaveFormatComparator; +import net.minecraft.world.storage.WorldSummary; import net.minecraftforge.fml.client.FMLClientHandler; import org.apache.commons.io.FileUtils; @@ -116,7 +116,7 @@ public static boolean createAndLaunchWorld(WorldSettings worldsettings, boolean * @param currentWorld excludes this world from deletion, can be null */ public static void cleanupTemporaryWorlds(String currentWorld){ - List saveList; + List saveList; ISaveFormat isaveformat = Minecraft.getMinecraft().getSaveLoader(); isaveformat.flushCache(); @@ -129,7 +129,7 @@ public static void cleanupTemporaryWorlds(String currentWorld){ String searchString = tempMark + AddressHelper.getMissionControlPort() + "_"; - for (SaveFormatComparator s: saveList){ + for (WorldSummary s: saveList){ String folderName = s.getFileName(); if (folderName.startsWith(searchString) && !folderName.equals(currentWorld)){ isaveformat.deleteWorldDirectory(folderName); diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MinecraftTypeHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MinecraftTypeHelper.java index 52537ab64..01d0267ad 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MinecraftTypeHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/MinecraftTypeHelper.java @@ -29,12 +29,16 @@ import net.minecraft.block.BlockLever.EnumOrientation; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemMonsterPlacer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import com.microsoft.Malmo.Schemas.BlockType; @@ -65,7 +69,7 @@ public static IBlockState ParseBlockType( String s ) { if( s == null ) return null; - Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation( s )); + Block block = (Block)Block.REGISTRY.getObject(new ResourceLocation( s )); if( block instanceof BlockAir && !s.equals("air") ) // Minecraft returns BlockAir when it doesn't recognise the string return null; // unrecognised string return block.getDefaultState(); @@ -81,7 +85,7 @@ public static Item ParseItemType( String s, boolean checkBlocks ) { if (s == null) return null; - Item item = (Item)Item.itemRegistry.getObject(new ResourceLocation(s)); // Minecraft returns null when it doesn't recognise the string + Item item = (Item)Item.REGISTRY.getObject(new ResourceLocation(s)); // Minecraft returns null when it doesn't recognise the string if (item == null && checkBlocks) { // Maybe this is a request for a block item? @@ -98,7 +102,7 @@ public static Item ParseItemType( String s, boolean checkBlocks ) */ public static boolean blockColourMatches(IBlockState bs, List allowedColours) { - for (IProperty prop : (java.util.Set) bs.getProperties().keySet()) + for (IProperty prop : bs.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { @@ -121,7 +125,7 @@ public static boolean blockColourMatches(IBlockState bs, List allowedCol */ public static boolean blockVariantMatches(IBlockState bs, List allowedVariants) { - for (IProperty prop : (java.util.Set) bs.getProperties().keySet()) + for (IProperty prop : bs.getProperties().keySet()) { if (prop.getName().equals("variant") && prop.getValueClass().isEnum()) { @@ -185,7 +189,7 @@ public static Variation attemptToGetAsVariant(String part, ItemStack is) // (which are the names displayed by Minecraft when using the F3 debug etc.) ItemBlock ib = (ItemBlock)(is.getItem()); IBlockState bs = ib.block.getStateFromMeta(is.getMetadata()); - for (IProperty prop : (java.util.Set)bs.getProperties().keySet()) + for (IProperty prop : bs.getProperties().keySet()) { Comparable comp = bs.getValue(prop); Variation var = attemptToGetAsVariant(comp.toString()); @@ -318,7 +322,7 @@ public static DrawBlock getDrawBlockFromBlockState(IBlockState state, List) state.getProperties().keySet()) + for (IProperty prop : state.getProperties().keySet()) { String propVal = state.getValue(prop).toString(); boolean matched = false; @@ -391,7 +395,7 @@ public static DrawItem getDrawItemFromItemStack(ItemStack is) if (is.getItem() instanceof ItemMonsterPlacer) { // Special case for eggs: - itemParts.add(ItemMonsterPlacer.getEntityName(is)); + itemParts.add(ItemMonsterPlacer.getNamedIdFrom(is).toString()); } // First part will be "tile" or "item". // Second part will be the item itself (eg "dyePowder" or "stainedGlass" etc). @@ -415,7 +419,7 @@ else if (var == null) di.setVariant(var); } // Use the item registry name for the item - this is what we use in Types.XSD - Object obj = Item.itemRegistry.getNameForObject(is.getItem()); + Object obj = Item.REGISTRY.getNameForObject(is.getItem()); String publicName; if (obj instanceof ResourceLocation) publicName = ((ResourceLocation)obj).getResourcePath(); @@ -492,7 +496,7 @@ public static ItemStack getItemStackFromDrawItem(DrawItem i) { // Attempt to find the subtype for this colour/variant - made tricky // because Items don't provide any nice property stuff like Blocks do... - List subItems = new ArrayList(); + NonNullList subItems = NonNullList.create(); item.getSubItems(item, null, subItems); for (ItemStack is : subItems) @@ -500,7 +504,7 @@ public static ItemStack getItemStackFromDrawItem(DrawItem i) String fullName = is.getUnlocalizedName(); if (is.getItem() instanceof ItemMonsterPlacer) { - fullName += "." + ItemMonsterPlacer.getEntityName(is); // Special handling for eggs + fullName += "." + ItemMonsterPlacer.getNamedIdFrom(is).toString(); // Special handling for eggs } String[] parts = fullName.split("\\."); for (int p = 0; p < parts.length; p++) @@ -532,7 +536,7 @@ static IBlockState applyVariant(IBlockState state, Variation variant) boolean relaxRequirements = false; for (int i = 0; i < 2; i++) { - for (IProperty prop : (java.util.Set) state.getProperties().keySet()) + for (IProperty prop : state.getProperties().keySet()) { if ((prop.getName().equals("variant") || relaxRequirements) && prop.getValueClass().isEnum()) { @@ -558,7 +562,7 @@ static IBlockState applyVariant(IBlockState state, Variation variant) */ static IBlockState applyColour(IBlockState state, Colour colour) { - for (IProperty prop : (java.util.Set)state.getProperties().keySet()) + for (IProperty prop : state.getProperties().keySet()) { if (prop.getName().equals("color") && prop.getValueClass() == net.minecraft.item.EnumDyeColor.class) { @@ -577,30 +581,57 @@ static IBlockState applyColour(IBlockState state, Colour colour) * @param facing The new direction (N/S/E/W/U/D) * @return A new blockstate with the facing attribute edited */ - static IBlockState applyFacing(IBlockState state, Facing facing) - { - for (IProperty prop : (java.util.Set)state.getProperties().keySet()) - { - if (prop.getName().equals("facing")) - { - if(prop.getValueClass() == EnumFacing.class) - { - EnumFacing current = (EnumFacing)state.getValue(prop); - if (!current.getName().equalsIgnoreCase(facing.name())) - { - return state.withProperty(prop, EnumFacing.valueOf(facing.name())); - } - } - else if(prop.getValueClass() == EnumOrientation.class) - { - EnumOrientation current = (EnumOrientation)state.getValue(prop); - if (!current.getName().equalsIgnoreCase(facing.name())) - { - return state.withProperty(prop, EnumOrientation.valueOf(facing.name())); - } - } - } - } - return state; - } + static IBlockState applyFacing(IBlockState state, Facing facing) + { + for (IProperty prop : state.getProperties().keySet()) + { + if (prop.getName().equals("facing")) + { + if (prop.getValueClass() == EnumFacing.class) + { + EnumFacing current = (EnumFacing) state.getValue(prop); + if (!current.getName().equalsIgnoreCase(facing.name())) + { + return state.withProperty(prop, EnumFacing.valueOf(facing.name())); + } + } + else if (prop.getValueClass() == EnumOrientation.class) + { + EnumOrientation current = (EnumOrientation) state.getValue(prop); + if (!current.getName().equalsIgnoreCase(facing.name())) + { + return state.withProperty(prop, EnumOrientation.valueOf(facing.name())); + } + } + } + } + return state; + } + + /** Does essentially the same as entity.getName(), but without pushing the result + * through the translation layer. This ensures the result matches what we use in Types.XSD, + * and prevents things like "entity.ShulkerBullet.name" being returned, where there is no + * translation provided in the .lang file. + * @param ent The entity + * @return The entity's name. + */ + public static String getUnlocalisedEntityName(Entity e) + { + String name; + if (e.hasCustomName()) + { + name = e.getCustomNameTag(); + } + else if (e instanceof EntityPlayer) + { + name = e.getName(); // Just returns the user name + } + else + { + name = EntityList.getEntityString(e); + if (name == null) + name = "unknown"; + } + return name; + } } diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/PositionHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/PositionHelper.java index 9d723c9d6..f42af8f63 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/PositionHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/PositionHelper.java @@ -23,7 +23,7 @@ import java.util.List; import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.util.BlockPos; +import net.minecraft.util.math.BlockPos; import com.microsoft.Malmo.Schemas.Pos; @@ -52,7 +52,7 @@ public static List getTouchingBlocks(EntityPlayerSP player) BlockPos blockposmax = new BlockPos(player.getEntityBoundingBox().maxX + 0.001D, player.getEntityBoundingBox().maxY + 0.001D, player.getEntityBoundingBox().maxZ + 0.001D); List blocks = new ArrayList(); - if (player.worldObj.isAreaLoaded(blockposmin, blockposmax)) + if (player.world.isAreaLoaded(blockposmin, blockposmax)) { for (int i = blockposmin.getX(); i <= blockposmax.getX(); ++i) { diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/ScreenHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/ScreenHelper.java index 2e46a82ec..eef12597b 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/ScreenHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/ScreenHelper.java @@ -31,7 +31,6 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -104,7 +103,6 @@ public TextCategoryAttributes(int xorg, int yorg, int colour, boolean list, bool public ScreenHelper() { - FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); this.attributes.put(TextCategory.TXT_INFO, new TextCategoryAttributes(800, 850, 0x4488ff, true, false, DebugOutputLevel.OUTPUT_INFO)); @@ -208,10 +206,10 @@ public void onRenderTick(TickEvent.RenderTickEvent ev) purgeExpiredFragments(null); if (Minecraft.getMinecraft().currentScreen != null && !(Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu)) return; + if (Minecraft.getMinecraft().gameSettings.showDebugInfo) // Don't obscure MC debug info with our debug info + return; - int displayWidth = Minecraft.getMinecraft().displayWidth; - int displayHeight = Minecraft.getMinecraft().displayHeight; - ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft(), displayWidth, displayHeight); + ScaledResolution res = new ScaledResolution(Minecraft.getMinecraft()); int width = res.getScaledWidth(); int height = res.getScaledHeight(); float rx = (float) width / 1000f; diff --git a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/UDPSocketHelper.java b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/UDPSocketHelper.java index bbf2a2073..4e6e1c85a 100755 --- a/Minecraft/src/main/java/com/microsoft/Malmo/Utils/UDPSocketHelper.java +++ b/Minecraft/src/main/java/com/microsoft/Malmo/Utils/UDPSocketHelper.java @@ -25,7 +25,7 @@ import java.net.InetAddress; import java.net.SocketException; -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; @@ -154,7 +154,7 @@ static public class UDPClientHeartBeat extends UDPHeartBeat public UDPClientHeartBeat(InetAddress address, int port, int intervalMs) { super(address, port, intervalMs); - FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); } /** Tick event called on the Client.
@@ -184,7 +184,7 @@ static public class UDPServerHeartBeat extends UDPHeartBeat public UDPServerHeartBeat(InetAddress address, int port, int intervalMs) { super(address, port, intervalMs); - FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); } /** Tick event called on the Server.
diff --git a/Schemas/Mission.xsd b/Schemas/Mission.xsd index c799eaa56..abf0611ec 100755 --- a/Schemas/Mission.xsd +++ b/Schemas/Mission.xsd @@ -6,7 +6,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" elementFormDefault="qualified" jaxb:version="2.1" - version="0.22"> + version="0.30"> @@ -157,7 +157,7 @@ - If AllowSpawning is set to true, use this to specify a list of the allowed mobs. Only those mobs which are on the list will be allowed to spawn. If no list is specified, normal spawning behaviour will take place. Note that these settings do not effect mob_spawner blocks. + If AllowSpawning is set to true, use this to specify a list of the allowed mobs. Only those mobs which are on the list will be allowed to spawn. If no list is specified, normal spawning behaviour will take place. Note that these settings *do* effect mob_spawner blocks. diff --git a/Schemas/MissionEnded.xsd b/Schemas/MissionEnded.xsd index b54472ee7..2c825fefc 100755 --- a/Schemas/MissionEnded.xsd +++ b/Schemas/MissionEnded.xsd @@ -4,7 +4,7 @@ targetNamespace="http://ProjectMalmo.microsoft.com" xmlns="http://ProjectMalmo.microsoft.com" elementFormDefault="qualified" - version="0.22"> + version="0.30"> diff --git a/Schemas/MissionHandlers.xsd b/Schemas/MissionHandlers.xsd index d9cdcdf4f..ea99baa66 100755 --- a/Schemas/MissionHandlers.xsd +++ b/Schemas/MissionHandlers.xsd @@ -6,7 +6,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" elementFormDefault="qualified" jaxb:version="2.1" - version="0.22"> + version="0.30"> diff --git a/Schemas/MissionInit.xsd b/Schemas/MissionInit.xsd index 998e4c323..9031c1d50 100755 --- a/Schemas/MissionInit.xsd +++ b/Schemas/MissionInit.xsd @@ -4,7 +4,7 @@ targetNamespace="http://ProjectMalmo.microsoft.com" xmlns="http://ProjectMalmo.microsoft.com" elementFormDefault="qualified" - version="0.22"> + version="0.30"> diff --git a/Schemas/Types.xsd b/Schemas/Types.xsd index e5d93d08e..ebf0e5cbb 100755 --- a/Schemas/Types.xsd +++ b/Schemas/Types.xsd @@ -6,7 +6,7 @@ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" elementFormDefault="qualified" jaxb:version="2.1" - version="0.22"> + version="0.30"> @@ -58,30 +58,7 @@ - The 188 types of item allowed in the Minecraft world: {{{iron_shovel}}}, {{{iron_pickaxe}}}, {{{iron_axe}}}, {{{flint_and_steel}}}, {{{apple}}}, {{{bow}}}, - {{{arrow}}}, {{{coal}}}, {{{diamond}}}, {{{iron_ingot}}}, {{{gold_ingot}}}, {{{iron_sword}}}, {{{wooden_sword}}}, {{{wooden_shovel}}}, - {{{wooden_pickaxe}}}, {{{wooden_axe}}}, {{{stone_sword}}}, {{{stone_shovel}}}, {{{stone_pickaxe}}}, {{{stone_axe}}}, {{{diamond_sword}}}, - {{{diamond_shovel}}}, {{{diamond_pickaxe}}}, {{{diamond_axe}}}, {{{stick}}}, {{{bowl}}}, {{{mushroom_stew}}}, {{{golden_sword}}}, {{{golden_shovel}}}, - {{{golden_pickaxe}}}, {{{golden_axe}}}, {{{string}}}, {{{feather}}}, {{{gunpowder}}}, {{{wooden_hoe}}}, {{{stone_hoe}}}, {{{iron_hoe}}}, {{{diamond_hoe}}}, - {{{golden_hoe}}}, {{{wheat_seeds}}}, {{{wheat}}}, {{{bread}}}, {{{leather_helmet}}}, {{{leather_chestplate}}}, {{{leather_leggings}}}, {{{leather_boots}}}, - {{{chainmail_helmet}}}, {{{chainmail_chestplate}}}, {{{chainmail_leggings}}}, {{{chainmail_boots}}}, {{{iron_helmet}}}, {{{iron_chestplate}}}, - {{{iron_leggings}}}, {{{iron_boots}}}, {{{diamond_helmet}}}, {{{diamond_chestplate}}}, {{{diamond_leggings}}}, {{{diamond_boots}}}, {{{golden_helmet}}}, - {{{golden_chestplate}}}, {{{golden_leggings}}}, {{{golden_boots}}}, {{{flint}}}, {{{porkchop}}}, {{{cooked_porkchop}}}, {{{painting}}}, {{{golden_apple}}}, - {{{sign}}}, {{{wooden_door}}}, {{{bucket}}}, {{{bucket}}}, {{{water_bucket}}}, {{{lava_bucket}}}, {{{minecart}}}, {{{saddle}}}, {{{iron_door}}}, - {{{redstone}}}, {{{snowball}}}, {{{boat}}}, {{{leather}}}, {{{milk_bucket}}}, {{{brick}}}, {{{clay_ball}}}, {{{reeds}}}, {{{paper}}}, {{{book}}}, - {{{slime_ball}}}, {{{chest_minecart}}}, {{{furnace_minecart}}}, {{{egg}}}, {{{compass}}}, {{{fishing_rod}}}, {{{clock}}}, {{{glowstone_dust}}}, {{{fish}}}, - {{{cooked_fish}}}, {{{dye}}}, {{{bone}}}, {{{sugar}}}, {{{cake}}}, {{{bed}}}, {{{repeater}}}, {{{cookie}}}, {{{filled_map}}}, {{{shears}}}, {{{melon}}}, - {{{pumpkin_seeds}}}, {{{melon_seeds}}}, {{{beef}}}, {{{cooked_beef}}}, {{{chicken}}}, {{{cooked_chicken}}}, {{{rotten_flesh}}}, {{{ender_pearl}}}, - {{{blaze_rod}}}, {{{ghast_tear}}}, {{{gold_nugget}}}, {{{nether_wart}}}, {{{potion}}}, {{{glass_bottle}}}, {{{spider_eye}}}, {{{fermented_spider_eye}}}, - {{{blaze_powder}}}, {{{magma_cream}}}, {{{brewing_stand}}}, {{{cauldron}}}, {{{ender_eye}}}, {{{speckled_melon}}}, {{{spawn_egg}}}, {{{experience_bottle}}}, - {{{fire_charge}}}, {{{writable_book}}}, {{{written_book}}}, {{{emerald}}}, {{{item_frame}}}, {{{flower_pot}}}, {{{carrot}}}, {{{potato}}}, - {{{baked_potato}}}, {{{poisonous_potato}}}, {{{map}}}, {{{golden_carrot}}}, {{{skull}}}, {{{carrot_on_a_stick}}}, {{{nether_star}}}, {{{pumpkin_pie}}}, - {{{fireworks}}}, {{{firework_charge}}}, {{{enchanted_book}}}, {{{comparator}}}, {{{netherbrick}}}, {{{quartz}}}, {{{tnt_minecart}}}, {{{hopper_minecart}}}, - {{{prismarine_shard}}}, {{{prismarine_crystals}}}, {{{rabbit}}}, {{{cooked_rabbit}}}, {{{rabbit_stew}}}, {{{rabbit_foot}}}, {{{rabbit_hide}}}, - {{{armor_stand}}}, {{{iron_horse_armor}}}, {{{golden_horse_armor}}}, {{{diamond_horse_armor}}}, {{{lead}}}, {{{name_tag}}}, {{{command_block_minecart}}}, - {{{mutton}}}, {{{cooked_mutton}}}, {{{banner}}}, {{{spruce_door}}}, {{{birch_door}}}, {{{jungle_door}}}, {{{acacia_door}}}, {{{dark_oak_door}}}, - {{{record_13}}}, {{{record_cat}}}, {{{record_blocks}}}, {{{record_chirp}}}, {{{record_far}}}, {{{record_mall}}}, {{{record_mellohi}}}, {{{record_stal}}}, - {{{record_strad}}}, {{{record_ward}}}, {{{record_11}}}, {{{record_wait}}}. + The types of item allowed in the Minecraft world. @@ -261,6 +238,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -279,31 +276,7 @@ - The 198 block types allowed in the Minecraft world: {{{air}}}, {{{stone}}}, {{{grass}}}, {{{dirt}}}, {{{cobblestone}}}, {{{planks}}}, {{{sapling}}}, {{{bedrock}}}, - {{{flowing_water}}}, {{{water}}}, {{{flowing_lava}}}, {{{lava}}}, {{{sand}}}, {{{gravel}}}, {{{gold_ore}}}, {{{iron_ore}}}, {{{coal_ore}}}, {{{log}}}, {{{leaves}}}, - {{{sponge}}}, {{{glass}}}, {{{lapis_ore}}}, {{{lapis_block}}}, {{{dispenser}}}, {{{sandstone}}}, {{{noteblock}}}, {{{bed}}}, {{{golden_rail}}}, {{{detector_rail}}}, - {{{sticky_piston}}}, {{{web}}}, {{{tallgrass}}}, {{{deadbush}}}, {{{piston}}}, {{{piston_head}}}, {{{wool}}}, {{{piston_extension}}}, {{{yellow_flower}}}, - {{{red_flower}}}, {{{brown_mushroom}}}, {{{red_mushroom}}}, {{{gold_block}}}, {{{iron_block}}}, {{{double_stone_slab}}}, {{{stone_slab}}}, {{{brick_block}}}, - {{{tnt}}}, {{{bookshelf}}}, {{{mossy_cobblestone}}}, {{{obsidian}}}, {{{torch}}}, {{{fire}}}, {{{mob_spawner}}}, {{{oak_stairs}}}, {{{chest}}}, {{{redstone_wire}}}, - {{{diamond_ore}}}, {{{diamond_block}}}, {{{crafting_table}}}, {{{wheat}}}, {{{farmland}}}, {{{furnace}}}, {{{lit_furnace}}}, {{{standing_sign}}}, {{{wooden_door}}}, - {{{ladder}}}, {{{rail}}}, {{{stone_stairs}}}, {{{wall_sign}}}, {{{lever}}}, {{{stone_pressure_plate}}}, {{{iron_door}}}, {{{wooden_pressure_plate}}}, - {{{redstone_ore}}}, {{{lit_redstone_ore}}}, {{{unlit_redstone_torch}}}, {{{redstone_torch}}}, {{{stone_button}}}, {{{snow_layer}}}, {{{ice}}}, {{{snow}}}, - {{{cactus}}}, {{{clay}}}, {{{reeds}}}, {{{jukebox}}}, {{{fence}}}, {{{pumpkin}}}, {{{netherrack}}}, {{{soul_sand}}}, {{{glowstone}}}, {{{portal}}}, - {{{lit_pumpkin}}}, {{{cake}}}, {{{unpowered_repeater}}}, {{{powered_repeater}}}, {{{stained_glass}}}, {{{trapdoor}}}, {{{monster_egg}}}, {{{stonebrick}}}, - {{{brown_mushroom_block}}}, {{{red_mushroom_block}}}, {{{iron_bars}}}, {{{glass_pane}}}, {{{melon_block}}}, {{{pumpkin_stem}}}, {{{melon_stem}}}, {{{vine}}}, - {{{fence_gate}}}, {{{brick_stairs}}}, {{{stone_brick_stairs}}}, {{{mycelium}}}, {{{waterlily}}}, {{{nether_brick}}}, {{{nether_brick_fence}}}, - {{{nether_brick_stairs}}}, {{{nether_wart}}}, {{{enchanting_table}}}, {{{brewing_stand}}}, {{{cauldron}}}, {{{end_portal}}}, {{{end_portal_frame}}}, - {{{end_stone}}}, {{{dragon_egg}}}, {{{redstone_lamp}}}, {{{lit_redstone_lamp}}}, {{{double_wooden_slab}}}, {{{wooden_slab}}}, {{{cocoa}}}, {{{sandstone_stairs}}}, - {{{emerald_ore}}}, {{{ender_chest}}}, {{{tripwire_hook}}}, {{{tripwire}}}, {{{emerald_block}}}, {{{spruce_stairs}}}, {{{birch_stairs}}}, {{{jungle_stairs}}}, - {{{command_block}}}, {{{beacon}}}, {{{cobblestone_wall}}}, {{{flower_pot}}}, {{{carrots}}}, {{{potatoes}}}, {{{wooden_button}}}, {{{skull}}}, {{{anvil}}}, - {{{trapped_chest}}}, {{{light_weighted_pressure_plate}}}, {{{heavy_weighted_pressure_plate}}}, {{{unpowered_comparator}}}, {{{powered_comparator}}}, - {{{daylight_detector}}}, {{{redstone_block}}}, {{{quartz_ore}}}, {{{hopper}}}, {{{quartz_block}}}, {{{quartz_stairs}}}, {{{activator_rail}}}, {{{dropper}}}, - {{{stained_hardened_clay}}}, {{{stained_glass_pane}}}, {{{leaves2}}}, {{{log2}}}, {{{acacia_stairs}}}, {{{dark_oak_stairs}}}, {{{slime}}}, {{{barrier}}}, - {{{iron_trapdoor}}}, {{{prismarine}}}, {{{sea_lantern}}}, {{{hay_block}}}, {{{carpet}}}, {{{hardened_clay}}}, {{{coal_block}}}, {{{packed_ice}}}, - {{{double_plant}}}, {{{standing_banner}}}, {{{wall_banner}}}, {{{daylight_detector_inverted}}}, {{{red_sandstone}}}, {{{red_sandstone_stairs}}}, - {{{double_stone_slab2}}}, {{{stone_slab2}}}, {{{spruce_fence_gate}}}, {{{birch_fence_gate}}}, {{{jungle_fence_gate}}}, {{{dark_oak_fence_gate}}}, - {{{acacia_fence_gate}}}, {{{spruce_fence}}}, {{{birch_fence}}}, {{{jungle_fence}}}, {{{dark_oak_fence}}}, {{{acacia_fence}}}, {{{spruce_door}}}, {{{birch_door}}}, - {{{jungle_door}}}, {{{acacia_door}}}, {{{dark_oak_door}}}. + The block types allowed in the Minecraft world. @@ -505,6 +478,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -622,13 +633,20 @@ - Types of entity for eggs, spawners etc: {{{Creeper}}}, {{{Skeleton}}}, {{{Spider}}}, {{{Giant}}}, {{{Zombie}}}, {{{Slime}}}, {{{Ghast}}}, {{{PigZombie}}}, - {{{Enderman}}}, {{{CaveSpider}}}, {{{Silverfish}}}, {{{Blaze}}}, {{{LavaSlime}}}, {{{EnderDragon}}}, {{{WitherBoss}}}, {{{Bat}}}, {{{Witch}}}, - {{{Endermite}}}, {{{Guardian}}}, {{{Pig}}}, {{{Sheep}}}, {{{Cow}}}, {{{Chicken}}}, {{{Squid}}}, {{{Wolf}}}, {{{MushroomCow}}}, {{{SnowMan}}}, - {{{Ozelot}}}, {{{VillagerGolem}}}, {{{EntityHorse}}}, {{{Rabbit}}}, {{{Villager}}}, {{{EnderCrystal}}}. + Types of entity for eggs, spawners etc. + + + + + + + + + + @@ -648,6 +666,9 @@ + + + @@ -658,10 +679,11 @@ - + + + - @@ -672,10 +694,85 @@ - + + + + + + + + + + + + + + + + + + + Non-living entities which tend to represent projectiles thrown by other mobs, etc. + Doesn't make much sense to spawn/draw these, but the agent could encounter them in the wild. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Note values for creating tuned noteblocks + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -700,7 +797,7 @@ - + diff --git a/changelog.txt b/changelog.txt index 77303562a..e218fa1e5 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,12 @@ +0.30.0 +------------------- +New: UPGRADED TO LATEST MC/FORGE +Breaking: AllowSpawning/AllowedMobs now affects mob_spawners +Breaking: "Minecart" entity renamed to "MinecartRideable" +New: Now includes all mobs up to Minecraft 1.11, and "mob_zoo.py" sample +New: Added new blocktypes and items up to Minecraft 1.11 +New: Added support for drawing tuned note blocks and "note_block_test.py" sample + 0.22.0 ------------------- New: ObservationFromRay now returns distance.