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

Create tile entity topping #20

Merged
merged 3 commits into from
Apr 20, 2017
Merged

Conversation

Pokechu22
Copy link
Collaborator

  • Lists all tile entities
  • Finds the update tile entity packet (all versions >= 13w41a)
  • Lists the numeric ID used in the update tile entity packet
  • Lists the blocks associated with each tile entity (1.9+)

* Finds the update tile entity packet (all versions >= 13w41a)
* Lists all tile entities
* Lists the blocks associated with each tile entity
* Lists the numeric ID used in the update tile entity packet
@TkTech
Copy link
Owner

TkTech commented Oct 30, 2016

PEP8? :)

@Pokechu22
Copy link
Collaborator Author

Done except for some cases where lines are longer than 79 chars, because in those cases I feel like it would be more messy to try and split the line than to keep it as is.

@TkTech
Copy link
Owner

TkTech commented Oct 31, 2016

I'm an annoying stickler when it comes to PEP8, sorry about that. I'm also a stickler for 80 characters because [in python] I find if I'm going over that I've almost always made something more complex than it needs to be. This would be just fine for example (I think, just doing it on the phone :))

           # No reason to rebuild this string on each iteration (string appending 
           # is a historically evil thing in CPython although not so bad these days)
           nbt_tag_type = 'L' + aggregate['classes']['nbtcompound'] + ';'

           for packet in aggregate["packets"]["packet"].itervalues():
                if packet["direction"] != "CLIENTBOUND" or packet["state"] != "PLAY":
                    continue

                packet_cf = ClassFile(StringIO(jar.read(packet["class"])))
                # Check if the packet has the expected fields in the class file
                # for the update tile entity packet
                if (len(packet_cf.fields) >= 3 and
                        # Tile entity type int, at least (maybe also position)
                        len(list(packet_cf.fields.find(type_="I"))) and
                        # New NBT tag
                        len(list(packet_cf.fields.find_one(type_=nbt_tag_type))):
                    # There are other fields, but they vary by version.
                    updatepacket = packet
                    break

This has no problem being two lines:

(
    'Unable to resolve BlockEntity for ItemInstance:',
    'tileentity.blockentitytag'
)

I'm surprised your editor is not yelling at you for the wildcard import, it's evil (yeah I know I've done it places too :() and makes static analysis so much harder (most tools just straight up won't be able to tell you if you have unused variables):

from jawa.constants import *

Always treat print as a function, it's a simple thing that keeps it forward and backwards compatible:

print("Missing tileentity.superclass")

I will try to go through burger and cleanup some of these things when I get a chance, I haven't been reviewing as well as I should have been, sorry.

@Pokechu22
Copy link
Collaborator Author

How about this, though?

print("Trying to mark %s as a block with tile entity %s but that tile entity does not exist!" % (stack[0], stack[1]))

How should I split that onto multiple lines? It seems like it's possible to split it, but I'm not sure how I should be doing that stylistically. Should I be doing this:

print ("Trying to mark %s as a block with "
       "tile entity %s but that tile entity "
       "does not exist!" % (stack[0], stack[1]))

Or this:

print ("Trying to mark %s as a block with "
       "tile entity %s but that tile entity "
       "does not exist!"
       % (stack[0], stack[1]))

Or something else?

Also, with packet.packetbuffer, how do I split that?

@TkTech
Copy link
Owner

TkTech commented Apr 20, 2017

I completely forgot about this PR, my apologies @Pokechu22. Is this still up to date with the current jars?

@Pokechu22
Copy link
Collaborator Author

Yep, still up to date (including listing bed as a tile entity now, which it is).

@TkTech TkTech merged commit 871c88d into TkTech:master Apr 20, 2017
Fabrimat pushed a commit to Fabrimat/Burger that referenced this pull request Oct 16, 2021
Add bitfield extraction.  Closes TkTech#17.
Pokechu22 pushed a commit that referenced this pull request Feb 17, 2022
Add bitfield extraction.  Closes #17.
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

Successfully merging this pull request may close these issues.

2 participants