mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
extra validation for pitch and yaw of rotatable blocks
This commit is contained in:
parent
568bd7b873
commit
53e96153f0
@ -165,9 +165,8 @@ trait Rotatable extends RotationAware with Persistable {
|
||||
override def load(nbt: NBTTagCompound) = {
|
||||
super.load(nbt)
|
||||
_pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
|
||||
if (_pitch == ForgeDirection.UNKNOWN) _pitch = ForgeDirection.NORTH
|
||||
_yaw = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "yaw"))
|
||||
if (_yaw == ForgeDirection.UNKNOWN) _yaw = ForgeDirection.SOUTH
|
||||
validatePitchAndYaw()
|
||||
updateTranslation()
|
||||
}
|
||||
|
||||
@ -182,6 +181,7 @@ trait Rotatable extends RotationAware with Persistable {
|
||||
super.readFromNBTForClient(nbt)
|
||||
_pitch = ForgeDirection.getOrientation(nbt.getInteger("pitch"))
|
||||
_yaw = ForgeDirection.getOrientation(nbt.getInteger("yaw"))
|
||||
validatePitchAndYaw()
|
||||
updateTranslation()
|
||||
}
|
||||
|
||||
@ -191,6 +191,15 @@ trait Rotatable extends RotationAware with Persistable {
|
||||
nbt.setInteger("yaw", _yaw.ordinal)
|
||||
}
|
||||
|
||||
private def validatePitchAndYaw() {
|
||||
if (!Set(ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH).contains(_pitch)) {
|
||||
_pitch = ForgeDirection.NORTH
|
||||
}
|
||||
if (!Set(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.EAST, ForgeDirection.WEST).contains(_yaw)) {
|
||||
_yaw = ForgeDirection.SOUTH
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
/** Updates cached translation array and sends notification to clients. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user