PrismarineJS / node-minecraft-protocol-forge

Plugin to add FML/Forge client support (including auto-versioning) to node-minecraft-protocol
54 stars 18 forks source link

[WIP] Forge 1.7.10 support #7

Closed deathcap closed 8 years ago

deathcap commented 8 years ago
deathcap commented 8 years ago

Status: works with https://github.com/PrismarineJS/minecraft-data/pull/117 against forge-1.7.10-10.13.4.1614 server (not tested with other 1.7.x versions, or any server with any mods installed), and also maintains compatibility with 1.8.9+

deathcap commented 8 years ago

Tested with http://www.feed-the-beast.com/projects/ftb-infinity-evolved/files/2275596#additional-files FTBInfinityServer-2.3.5-1.7.10.zip

Received forgeMods event: [ { modid: 'MineFactoryReloaded|CompatExtraBiomes',
    version: '1.7.10R2.8.0' },
  { modid: 'BuildCraft|Silicon', version: '7.1.14' },
  { modid: 'ProjRed|Expansion', version: '4.7.0pre9.92' },
  { modid: 'ForgeMicroblock', version: '1.2.0.345' },
  { modid: 'iChunUtil', version: '4.2.2' },
  { modid: 'rftools', version: '4.20' },
  { modid: 'ExtraBees', version: '2.0-pre14' },
  { modid: 'PortalGun', version: '4.0.0-beta-6' },
  { modid: 'ThaumicExploration', version: '0.6.0' },
  { modid: 'springboards', version: '0.1' },
  { modid: 'EnderZoo', version: '1.7.10-1.0.15.32' },
  { modid: 'MineFactoryReloaded|CompatTwilightForest',
    version: '1.7.10R2.8.0' },
  { modid: 'MagicBees', version: '1.7.10-2.3.6' },
  { modid: 'Botany', version: '2.0-pre14' },
  { modid: 'ProjRed|Integration', version: '4.7.0pre9.92' },
  { modid: 'endercore', version: '1.7.10-0.2.0.31_beta' },
  { modid: 'Mystcraft', version: '0.12.3.01' },
  { modid: 'MineFactoryReloaded|CompatProjRed',
    version: '1.7.10R2.8.0' },
  { modid: 'BuildCraft|Robotics', version: '7.1.14' },
  { modid: 'McMultipart', version: '1.2.0.345' },
  { modid: 'BiomesOPlenty', version: '2.1.0' },
  { modid: 'props', version: '2.2.1' },
  { modid: 'ExtraUtilities', version: '1.2.12' },
  { modid: 'Railcraft', version: '9.8.0.0' },
  { modid: 'guideapi', version: '1.7.10-1.0.1-20' },
  { modid: 'MineFactoryReloaded|CompatRailcraft',
    version: '1.7.10R2.8.0' },
  { modid: 'WR-CBE|Addons', version: '1.4.1.9' },
  { modid: 'MineFactoryReloaded|CompatForestry',
    version: '1.7.10R2.8.0' },
  { modid: 'IC2NuclearControl', version: '2.3.3a-Exist' },
  { modid: 'ThermalFoundation', version: '1.7.10R1.2.0' },
  { modid: 'MineFactoryReloaded|CompatVanilla',
    version: '1.7.10R2.8.0' },
  { modid: 'ForgeMultipart', version: '1.2.0.345' },
  { modid: 'headcrumbs', version: '1.7.0' },
  { modid: 'StevesCarts', version: '2.0.0.b18' },
  { modid: 'BrandonsCore', version: '1.0.0.10' },
  { modid: 'RedstoneArsenal', version: '1.7.10R1.1.1' },
  { modid: 'MCFrames', version: '1.0' },
  { modid: 'CoFHCore', version: '1.7.10R3.0.3' },
  { modid: 'neresources', version: '0.1.0.106' },
  { modid: 'BiblioWoodsForestry', version: '1.7' },
  { modid: 'FastCraft', version: '1.21' },
  { modid: 'OpenPeripheral', version: '0.5' },
  { modid: 'Forge', version: '10.13.4.1614' },
  { modid: 'ExtraTrees', version: '2.0-pre14' },
  { modid: 'HatStand', version: '4.0.0' },
  { modid: 'StorageDrawers', version: '1.7.10-1.7.5' },
  { modid: 'gendustry', version: '1.6.0.125' },
  { modid: 'ThaumicTinkerer', version: 'unspecified' },
  { modid: 'MineFactoryReloaded|CompatChococraft',
    version: '1.7.10R2.8.0' },
  { modid: 'AdvancedSolarPanel', version: '1.7.10-3.5.1' },
  { modid: 'BuildCraft|Energy', version: '7.1.14' },
  { modid: 'modtweaker2', version: '0.9.4' },
  { modid: 'IC2', version: '2.2.804-experimental' },
  { modid: 'JABBA', version: '1.2.1' },
  { modid: 'ExtraTiC', version: '1.4.5' },
  { modid: 'MineFactoryReloaded|CompatMystcraft',
    version: '1.7.10R2.8.0' },
  { modid: 'MineFactoryReloaded|CompatIC2',
    version: '1.7.10R2.8.0' },
  { modid: 'ProjRed|Transportation', version: '4.7.0pre9.92' },
  { modid: 'FML', version: '7.10.99.99' },
  { modid: 'Natura', version: '2.2.0' },
  { modid: 'NEIAddons|Forestry', version: '1.12.11.36' },
  { modid: 'TiCTooltips', version: '1.2.5' },
  { modid: 'BiblioWoodsNatura', version: '1.5' },
  { modid: '<CoFH ASM>', version: '000' },
  { modid: 'NEIAddons|CraftingTables', version: '1.12.11.36' },
  { modid: 'NEIAddons|ExNihilo', version: '1.12.11.36' },
  { modid: 'WailaHarvestability', version: '1.1.6' },
  { modid: 'ThermalDynamics', version: '1.7.10R1.1.0' },
  { modid: 'ProjRed|Illumination', version: '4.7.0pre9.92' },
  { modid: 'TMechworks', version: '0.2.15.106' },
  { modid: 'fastleafdecay', version: '1.4' },
  { modid: 'Botania', version: 'r1.8-247' },
  { modid: 'Hats', version: '4.0.1' },
  { modid: 'LogisticsPipes', version: '0.9.3.70' },
  { modid: 'Avaritia', version: '0.2b' },
  { modid: 'FTBU', version: '1.0.14.2' },
  { modid: 'FTBT', version: '1.0.1' },
  { modid: 'NotEnoughItems', version: '1.0.5.118' },
  { modid: 'Thaumcraft', version: '4.2.3.5' },
  { modid: 'Waila', version: '1.5.10' },
  { modid: 'ProjRed|Compatibility', version: '4.7.0pre9.92' },
  { modid: 'ForgeRelocation', version: '0.0.1.4' },
  { modid: 'extracells', version: '2.3.7' },
  { modid: 'TConstruct', version: '1.7.10-1.8.8.build988' },
  { modid: 'simplyjetpacks', version: '1.5.3' },
  { modid: 'StevesFactoryManager', version: 'A93' },
  { modid: 'appliedenergistics2-core', version: 'rv2-stable-10' },
  { modid: 'NEIAddons', version: '1.12.11.36' },
  { modid: 'BinnieCore', version: '2.0-pre14' },
  { modid: 'inpure|core', version: '1.7.10R1.0.0B9' },
  { modid: 'StorageDrawersForestry', version: '1.7.10-1.1.0' },
  { modid: 'BiblioCraft', version: '1.11.4' },
  { modid: 'BuildCraft|Core', version: '7.1.14' },
  { modid: 'OpenModsCore', version: '0.9' },
  { modid: 'ImmersiveEngineering', version: '0.6.5.1' },
  { modid: 'SolarExpansion', version: '1.6a' },
  { modid: 'bdlib', version: '1.9.2.104' },
  { modid: 'NEIAddons|Developer', version: '1.12.11.36' },
  { modid: 'wawla', version: '1.3.3' },
  { modid: 'RelocationFMP', version: '0.0.1.2' },
  { modid: 'Genetics', version: '2.0-pre14' },
  { modid: 'mcp', version: '9.05' },
  { modid: 'Mantle', version: '1.7.10-0.3.2.jenkins191' },
  { modid: 'ProjRed|Transmission', version: '4.7.0pre9.92' },
  { modid: 'journeymap', version: '5.1.3' },
  { modid: 'appliedenergistics2', version: 'rv2-stable-10' },
  { modid: 'thaumcraftneiplugin', version: '@VERSION@' },
  { modid: 'WR-CBE|Logic', version: '1.4.1.9' },
  { modid: 'MineFactoryReloaded|CompatAtum',
    version: '1.7.10R2.8.0' },
  { modid: 'OpenPeripheralIntegration', version: '0.4' },
  { modid: 'MineFactoryReloaded|CompatTConstruct',
    version: '1.7.10R2.8.0' },
  { modid: 'MineFactoryReloaded|CompatAppliedEnergistics',
    version: '1.7.10R2.8.0' },
  { modid: 'DraconicEvolution', version: '1.0.2-snapshot_9' },
  { modid: 'WR-CBE|Core', version: '1.4.1.9' },
  { modid: 'inventorytweaks', version: '1.59-dev-152-cf6e263' },
  { modid: 'MineFactoryReloaded|CompatBuildCraft',
    version: '1.7.10R2.8.0' },
  { modid: 'StorageDrawersMisc', version: '1.7.10-1.1.0' },
  { modid: 'harvestcraft', version: '1.7.10j' },
  { modid: 'Morpheus', version: '1.7.10-1.6.20' },
  { modid: 'ThermalExpansion', version: '1.7.10R4.0.3B1' },
  { modid: 'TwilightForest', version: '2.3.7' },
  { modid: 'BuildCraft|Factory', version: '7.1.14' },
  { modid: 'MineFactoryReloaded|CompatThaumcraft',
    version: '1.7.10R2.8.0' },
  { modid: 'GraviSuite', version: '1.7.10-2.0.3' },
  { modid: 'AgriCraft', version: '1.7.10-1.4.6-hotfix' },
  { modid: 'OpenPeripheralCore', version: '1.2.1' },
  { modid: 'NEIAddons|AppEng', version: '1.12.11.36' },
  { modid: 'OpenBlocks', version: '1.5' },
  { modid: 'EnderStorage', version: '1.4.7.37' },
  { modid: 'ForbiddenMagic', version: '1.7.10-0.572' },
  { modid: 'EnderTech', version: '1.7.10-0.3.2.405' },
  { modid: 'MineFactoryReloaded|CompatSufficientBiomes',
    version: '1.7.10R2.8.0' },
  { modid: 'FTBL', version: '1.0.14.2' },
  { modid: 'MineFactoryReloaded|CompatForgeMicroblock',
    version: '1.7.10R2.8.0' },
  { modid: 'CarpentersBlocks', version: '3.3.7' },
  { modid: 'MineFactoryReloaded', version: '1.7.10R2.8.0' },
  { modid: 'StevesWorkshop', version: '0.5.1' },
  { modid: 'EnderIO', version: '1.7.10-2.3.0.422_beta' },
  { modid: 'BuildCraft|Compat', version: '7.1.3' },
  { modid: 'Translocator', version: '1.1.2.15' },
  { modid: 'ComputerCraft', version: '1.75' },
  { modid: 'funkylocomotion', version: '1.0' },
  { modid: 'neiintegration', version: '1.0.12' },
  { modid: 'AWWayofTime', version: 'v1.3.3' },
  { modid: 'MrTJPCoreMod', version: '1.1.0.31' },
  { modid: 'immersiveintegration', version: '0.6.6' },
  { modid: 'IronChest', version: '6.0.62.742' },
  { modid: 'NEIAddons|Botany', version: '1.12.11.36' },
  { modid: 'MineFactoryReloaded|CompatThermalExpansion',
    version: '1.7.10R2.8.0' },
  { modid: 'thaumicenergistics', version: '0.8.10.10' },
  { modid: 'CodeChickenCore', version: '1.0.7.47' },
  { modid: 'BigReactors', version: '0.4.3A' },
  { modid: 'MineTweaker3', version: '3.0.10' },
  { modid: 'ThaumicTinkerer-preloader', version: '0.1' },
  { modid: 'aobd', version: '2.8.4' },
  { modid: 'NetherOres', version: '1.7.10R2.3.0' },
  { modid: 'debug', version: '1.0' },
  { modid: 'StorageDrawersNatura', version: '1.7.10-1.1.0' },
  { modid: 'BuildCraft|Transport', version: '7.1.14' },
  { modid: 'StorageDrawersBop', version: '1.7.10-1.1.0' },
  { modid: 'chisel', version: '2.9.4.10' },
  { modid: 'Baubles', version: '1.0.1.10' },
  { modid: 'StevesAddons', version: '0.10.16' },
  { modid: 'ProjRed|Core', version: '4.7.0pre9.92' },
  { modid: 'denseores', version: '1.0' },
  { modid: 'ProjRed|Exploration', version: '4.7.0pre9.92' },
  { modid: 'witchery', version: '0.24.1' },
  { modid: 'Forestry', version: '3.6.6.24' },
  { modid: 'OpenMods', version: '0.9' },
  { modid: 'BiblioWoodsBoP', version: '1.9' },
  { modid: 'PTRModelLib', version: '1.0.0' },
  { modid: 'BuildCraft|Builders', version: '7.1.14' },
  { modid: 'MineFactoryReloaded|CompatBackTools',
    version: '1.7.10R2.8.0' },
  { modid: 'runicdungeons', version: '1.1.6a' } ]

{ [Error: Read error for discriminator : 7 is not in the mappings value] field: 'discriminator' }
/Users/admin/games/voxeljs/node-minecraft-protocols/src/transforms/framing.js:87
          throw e;
          ^

Error: Read error for discriminator : 7 is not in the mappings value
    at ProtoDef.readMapper (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/datatypes/utils.js:36:41)
    at ProtoDef.read (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/protodef.js:46:25)
    at ProtoDef.read (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/protodef.js:107:42)
    at /Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/datatypes/structures.js:114:32
    at tryCatch (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/utils.js:33:12)
    at tryDoc (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/utils.js:40:10)
    at /Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/datatypes/structures.js:113:5
    at Array.forEach (native)
    at ProtoDef.readContainer (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/datatypes/structures.js:108:12)
    at ProtoDef.read (/Users/admin/games/voxeljs/node-minecraft-protocol-forge/node_modules/protodef/dist/protodef.js:46:25)

this is https://github.com/PrismarineJS/node-minecraft-protocol-forge/issues/1, the plugin channel packet:

d2 c8 0f 3f 06 46 4d 4c 7c 48 53 e4 47 07 03 e4 42 1a 01 41 67 72 69 43 72 61 66 74 3a 63 72 6f 70 42 6f 74 61 6e 69 61 4c 69 6d 65 88 15 1c 01 68 61 ...

0xe447 is the 'short' length, readInt16BE() = -7097, negative, which is not used in vanilla but in Forge indicates the next byte (0x07) is also part of the length (high 8 bits, short is lower 15 bits):

(0x07 << 15) | (0xe447 & 0x7fff) 255047

deathcap commented 8 years ago

Progress: with https://github.com/roblabla/ProtoDef/pull/52 + https://github.com/PrismarineJS/minecraft-data/pull/120, able to connect to FTBInfinityServer-2.3.5-1.7.10.zip server. Receives a ton of custom payload messages, gets further. But then it crashes:

{ [Error: Read error for name : -26 is not in the mappings value] field: 'name' }
/Users/admin/games/voxeljs/node-minecraft-protocols/src/transforms/framing.js:87
          throw e;
          ^

Error: Read error for name : -26 is not in the mappings value
    at ProtoDef.readMapper (/Users/admin/games/voxeljs/ProtoDef/dist/datatypes/utils.js:38:41)
    at ProtoDef.read (/Users/admin/games/voxeljs/ProtoDef/dist/protodef.js:103:31)
    at /Users/admin/games/voxeljs/ProtoDef/dist/datatypes/structures.js:114:32
    at tryCatch (/Users/admin/games/voxeljs/ProtoDef/dist/utils.js:31:12)
    at tryDoc (/Users/admin/games/voxeljs/ProtoDef/dist/utils.js:38:10)
    at /Users/admin/games/voxeljs/ProtoDef/dist/datatypes/structures.js:113:5
    at Array.forEach (native)
    at ProtoDef.readContainer (/Users/admin/games/voxeljs/ProtoDef/dist/datatypes/structures.js:108:12)
    at ProtoDef.read (/Users/admin/games/voxeljs/ProtoDef/dist/protodef.js:46:25)
    at ProtoDef.read (/Users/admin/games/voxeljs/ProtoDef/dist/protodef.js:103:31)

trying to read an unrecognized packet type! What to do with custom packets? (note: not "custom_payload" plugin channel messages, these are completely custom packets with their own IDs).

Seeing what other projects do:

https://github.com/WaterfallMC/Waterfall/commit/312b3a7ce743145c46aff043b24d84ebdb8c5038 Don't attempt to rewrite negative packet IDs

Since the packets are all length-prefixed (at least in 1.7 and after), even if unknown they could be read in their entirety, just as opaque blobs.

update: https://github.com/PrismarineJS/node-minecraft-protocol/issues/367

deathcap commented 8 years ago

Looks like -26 (unsigned 230) is the only custom packet in FTB IE, at least on the initial connection.

If I make this change to minecraft-data data/1.7/protocol.json:

diff --git a/data/1.7/protocol.json b/data/1.7/protocol.json
index a1925cf..d23291e 100644
--- a/data/1.7/protocol.json
+++ b/data/1.7/protocol.json
@@ -1931,6 +1931,15 @@
               "type": "string"
             }
           ]
+        },
+        "unknown_e6": {
+          "id": "-0x1a",
+          "fields": [
+            {
+              "name": "data",
+              "type": "restBuffer"
+            }
+          ]
         }
       },
       "toServer": {

then the client_forge example can login.

According to http://forum.industrial-craft.net/index.php?page=Thread&postID=28216 "BadPackedID 230 = ModLoader MP isn't installed (properly)", but that's from 2011. Wonder what mod is using it still...

Looks like its caused by: mods/CoFHCore-[1.7.10]3.0.3-303.jar - reproduces with only CoFHCore installed, nothing else. On the wire:

  15 e6 ff ff ff 0f c3 9f  a4 c6 85 a3 35 82 81 67 ........ ....5..g

https://github.com/CoFH/CoFHCore/blob/0c145bb15b0265e5ac432a91eef3fd435be14e0d/src/main/java/cofh/core/network/PacketCore.java - config sync?

deathcap commented 8 years ago

Packet -26 is definitely CoFHCore. Found the CoFHCore issue tracker: https://github.com/CoFH/Feedback/issues/415 Bad packet id -26 server https://github.com/CoFH/Feedback/issues/453 Use plugin messages rather than packets (?) [seems like a good idea..], "It's confirmed as a bug that negative ID packets were slipping past the guards on packet id. They [BungeeCord] should have a release out covering it soon." .. following the trail https://github.com/SpigotMC/BungeeCord/issues/1437 [Forge] Bungee errors with CoFH packet, developer explains (& why it isn't using plugin channels):

For further information: This particular packet is being registered on both client&server as is appropriate for it to function, and is used to work around a combination vanilla/forge bug wherein the client-side EntityPlayer's UUID does not match the server-side UUID (fixed by vanilla in 1.8) and is implemented in the vanilla system so it can be done as part of CoFHLib (no requirement for Core). "Easiest" fix is to forward all unrecognized packets on to the client they're meant for.

https://github.com/CoFH/CoFHLib/blob/737cf7aee0a6de2559143ed63a8077fe40196813/src/main/java/cofh/lib/util/helpers/SecurityHelper.java#L237-L280 - [registered here](registered here https://github.com/CoFH/CoFHLib/blob/737cf7aee0a6de2559143ed63a8077fe40196813/src/main/java/cofh/lib/util/helpers/SecurityHelper.java):

  EnumConnectionState.PLAY.func_150755_b().put(-26, Login.S__PacketSendUUID.class);
deathcap commented 8 years ago

This works decently well with https://github.com/PrismarineJS/minecraft-data/pull/121, merging