Closed Kingburrito777 closed 3 months ago
Thank you for reporting this bug.
As far as I know rotations are supposed to have two elements in Minecraft (yaw and pitch). This is what was originally implemented in the constructor. Somewhere along the way, it appears we ended-up considering it as a 3-float tuple instead of a 2-float tuple in almost every place. I don't think that's correct.
Hi @Kingburrito777 , do you want to check-out #51 and confirm it fixes your issue?
Hi @Kingburrito777 , do you want to check-out #51 and confirm it fixes your issue?
I'll do so shortly. I'll be sure to test a few different test cases thanks Liam
title: IndexError in Entity class due to inconsistent handling of 'Rotation' data labels: bug
Description
There's an inconsistency in the
Entity
class in how it handles the 'Rotation' data. The class initializes 'Rotation' with two elements if it's not present, but later attempts to access a third element, causing an IndexError.Code Causing the Issue
In the
Entity
class (litemapy/minecraft.py
):Error Message
Expected Behavior
The
Entity
class should consistently handle 'Rotation' data, either always expecting two elements or always expecting three elements.Actual Behavior
The class initializes 'Rotation' with two elements but later attempts to access a third element, causing an IndexError when the third element doesn't exist.
Possible Solutions
Modify the initialization to always include three elements:
Modify the assignment to
self._rotation
to only use two elements:Use a more flexible approach that works with either two or three elements:
Additional Context
This issue affects the loading of litematic files that contain entity data. It's possible that different versions of the litematic format or Minecraft itself use different numbers of rotation elements for entities.
Steps to Reproduce
LitematicSchematic.load()
method.Environment