Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Analyze the impact of the Flattening in McPython ecosystem #58

Closed
acs opened this issue May 9, 2020 · 8 comments
Closed

Analyze the impact of the Flattening in McPython ecosystem #58

acs opened this issue May 9, 2020 · 8 comments

Comments

@acs
Copy link
Contributor

acs commented May 9, 2020

From the experience in:

#50
#52

understand the impact of https://minecraft.gamepedia.com/Java_Edition_1.13/Flattening and how it is managed in Spigot with the Legacy Material support.

@acs
Copy link
Contributor Author

acs commented May 9, 2020

The Spigot support for legacy material is inside Craftbuckit in the file:

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java

We should analyze it to understand how the numeric ids are supported in new versions of MC.

It seems that the key is in: import net.minecraft.server.DataConverterFlattenData;

But this is a class from the vanilla server. And the mapping is ... huge!

https://github.com/Akarin-project/Minecraft/blob/master/1.13.2/spigot/net/minecraft/server/DataConverterFlattenData.java

@acs
Copy link
Contributor Author

acs commented May 9, 2020

But, is it possible to just have a new mcpi.blocks mapping the names to the new format?

https://www.stuffaboutcode.com/p/minecraft-api-reference.html


 AIR                 = Block(0)

 AIR                 = Block("minecraft:air")

With that, all the code using the named blocks won't break.

@acs acs changed the title Analyze the impact of the Analyze the impact of the Flattening in McPython ecosystem May 10, 2020
@acs
Copy link
Contributor Author

acs commented May 10, 2020

After thinking about it, probably the first step is to release a mcpi2 lib supporting materials instead of blocks. Creating a map from raspbi block to materials is easy: just use the blocks gallery to fill the blocks in a new MC post 1.13 and after that, get the blocks definition. And you have the map.

With this map, it is easy to add the materials support to mcpi2.

Also, the support for the extended API as for example, spawnEntity, must be analyzed.

@acs
Copy link
Contributor Author

acs commented May 10, 2020

The first step is to check that if we send using mcpi (modified) a material using the setBlock API, it is received correctly and created in MC 1.15.2. And after that, we can continue with the plan!

As the plugin is configured in legacy mode, using the Python API we can not create blocks using the new materials definition. So for using it, we need a plugin version that works without the legacy material support.

@acs
Copy link
Contributor Author

acs commented May 10, 2020

So the next step is to start the plugin but modifying the version to 1.15

[tmp]$ cat plugin.yml 
author: Zhuowei
database: false
description: Implementation of the Minecraft PI modding API
main: net.zhuoweizhang.raspberryjuice.RaspberryJuicePlugin
name: RaspberryJuice
startup: postworld
version: '1.11'

Time to get the last version: https://www.spigotmc.org/resources/raspberryjuice.22724/

@acs
Copy link
Contributor Author

acs commented May 10, 2020

It seems that the best approach is to test this PR: zhuowei/RaspberryJuice@cec5f99

So we have the plugin for 1.14 and start testing with it.

It is pretty easy to package the plugin (mvn package). And I have created a package with the above PR and it works using string for the blocks instead of integers.

For example:

        pos.x += 1
        block = Block(pos)
        block.block = "bedrock"
        block.build()

Screenshot from 2020-05-10 18-23-20

I needed also to modify mcpi so I can send strings:

    def setBlock(self, *args):
        """Set block (x,y,z,id,[data])"""
        # self.conn.send(b"world.setBlock", intFloor(args))
        self.conn.send(b"world.setBlock", args)

@acs
Copy link
Contributor Author

acs commented May 11, 2020

And, what about Minetest? All the schematics using Materials can not be created in Minetest.

In Minetest the blocks are: https://wiki.minetest.net/Nodes

They are using the namespaced blocks ids (itemstrings): https://wiki.minetest.net/Itemstrings

How are blocks compatible between MC and MT in our examples? Probably because of the Raspi plugin for MT: https://github.com/arpruss/raspberryjammod-minetest

Yes, it is here: https://github.com/arpruss/raspberryjammod-minetest/blob/master/raspberryjammod/block.lua#L211

So to support the new naming in MC, this translation mapping must be updated.

@acs
Copy link
Contributor Author

acs commented May 11, 2020

After thinking about it and doing some PoCs the best strategy seems to be:

  • Stay with 1.12.2 by default, with blocks id for MC and the mapping in the plugin for MT. This will also work with the Forge version, which enables us to develop locally.
  • In MC >1.13 with Craftkit it has the material legacy layer, so the plugin for it work (tested in 1.15.2). so the future is ok for now.

In this scenario, we can not use the new blocks (materials) after 1.15.2, but it is good enough for McThings. And my impression is that the creative community (for example for schematics) was more active sometime ago, so having support fot those creations (schematics) is the best approach.

And the idea is to continue analyzing the support for Flattening.

So the strategy now is to live in the pre-Flattening era.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant