baritone icon indicating copy to clipboard operation
baritone copied to clipboard

Added Litematica support

Open EmersonDove opened this issue 3 years ago • 15 comments

Added litematica support to 1.12.2 master.

Issues with this version:

  • Some states (such as iron bars) are unrecognized
  • In 1.12, the long array (blockstates) isn't exposed by the libraries so parsing has to be done manually
  • Only reads in first region of the .litematic

#2338 Is a fully working implementation for modern versions of MC

If anyone has knowledge or cleaner solutions for any of these leave a comment so I can update it.

EmersonDove avatar Mar 07 '21 16:03 EmersonDove

@EmersonDove are you still working on this?

ZacSharp avatar May 10 '21 20:05 ZacSharp

@ZacSharp I've been on and off about it. I haven't fixed any the original bugs enough to commit. I talked to masa and he believes it should be possible but in general the 1.12.2 port has had a lot of issues. I'll probably give it another try after the semester is over.

EmersonDove avatar May 11 '21 15:05 EmersonDove

I'd like to express my interest here as well -- I have a lot of complex redstone that I need to place (running experimental 1.17.1 build) and this would make life much easier for me

sudofox avatar Oct 25 '21 17:10 sudofox

I ported this up to 1.17 a while ago here, did the work translating mappings etc

https://raw.githubusercontent.com/sudofox/baritone-1.17/master/src/main/java/baritone/utils/schematic/format/defaults/LitematicaSchematic.java?token=GHSAT0AAAAAABKUY4TPGPDW7HIUI2M37YD2YQLEGKA

Unsure what needs to be done to push things forward

sudofox avatar Feb 10 '22 20:02 sudofox

Issues with this version:

  • Some states (such as iron bars) are unrecognized
  • In 1.12, the long array (blockstates) isn't exposed by the libraries so parsing has to be done manually
  • Only reads in first region of the .litematic

I't probably useable as is (never managed to get myself to have a look at it), but not ready for merging. The reason for the first point is unknown (as far as I know), the other two points have already been addressed in the discussion here.

ZacSharp avatar Feb 10 '22 23:02 ZacSharp

Hey everyone looks like I should follow up here -

I wouldn't feel good merging it in with its current state - I would expect this will create GH issues than are closed.

I'm interested in pushing things forward for a 1.12 implementation with @sudofox but hit a wall with the mixins and have been working on other projects (@blankly-finance). I talked to Mesa a few months ago and there is no technical reason why this couldn't work.

If someone could tackle or give some pointers on the mixin for the long array that would be great.

EmersonDove avatar Feb 11 '22 01:02 EmersonDove

For the mixin you probably want a simple mixin on NBTTagLongArray with an @Accessor for the data field. Since Baritone has the mixin classes in a separate source set you also need an interface for the accessor in the main source set and make the mixin class implement it. If you've got it right you can then safely cast the long array to the accessor interface and youse the mixin generated method to get the data. I think the easiest way to see how to do it is looking at the interfaces in baritone.utils.accessor and their implementations in baritone.launch.mixins.

ZacSharp avatar Feb 13 '22 15:02 ZacSharp

Thanks for the mention Emerson. I should establish that my Java skills are quite hodgepodgey so I'll try to contribute as much as I can but otherwise I'll cheer you on from the sidelines 😅

sudofox avatar Feb 13 '22 15:02 sudofox

I've had a look at it and I think you can copy the changes from https://github.com/ZacSharp/baritone/commit/0550fe362369d12e0aefe6ffb0b8f9190f2f7f69 as is. I also had a try at loading all regions of the schematic in https://github.com/ZacSharp/baritone/commit/3cf9e2f2580481350fcf1c4a1481164cde62b72d but that commit is not useable as is and comes with debug printouts and will likely (didn't try it) crash with map art mode enabled for any litematic that does completely fill its enclosing box volume.

ZacSharp avatar Mar 03 '22 16:03 ZacSharp

I've invested some more time and used the approach from #3317 (patching the holes with air) to fix mapArtMode. You can find the changes at https://github.com/ZacSharp/baritone/commit/3661fea4f05755ebf285b883aabfe2abde34f76d and its parents in case you want to use them.

ZacSharp avatar Mar 31 '22 22:03 ZacSharp

I also failed to reproduce the bug with iron bars not being loaded correctly, all 16 worked.

ZacSharp avatar Mar 31 '22 22:03 ZacSharp

What does this PR still need to get released?

ThalusA avatar May 28 '22 18:05 ThalusA

News on why there is still no merge ?

amatheo avatar Aug 10 '22 15:08 amatheo

It's a draft? it isn't finished yet if you couldn't tell

ehylo avatar Aug 10 '22 16:08 ehylo

What's currently missing (both done on my branch but @EmersonDove hasn't done it here yet)

  • Read all regions of the .litematic instead of just the first
  • Get rid of the hacky string parsing

@leijurv I'd really like to know whether static schematics are allowed to have holes (i.e. behavior of getDirect is undefined at positions within the schematic bounds as it is the case for other schematics).

ZacSharp avatar Aug 27 '22 02:08 ZacSharp

Superseded by #3672

scorbett123 avatar Oct 03 '22 20:10 scorbett123