diff --git a/src/main/scala/li/cil/oc/client/renderer/block/SmartBlockModelBase.scala b/src/main/scala/li/cil/oc/client/renderer/block/SmartBlockModelBase.scala index 88479d1899..22837557cb 100644 --- a/src/main/scala/li/cil/oc/client/renderer/block/SmartBlockModelBase.scala +++ b/src/main/scala/li/cil/oc/client/renderer/block/SmartBlockModelBase.scala @@ -201,11 +201,14 @@ trait SmartBlockModelBase extends IBakedModel { private def shade(value: Int, brightness: Float) = (brightness * value).toInt max 0 min 255 protected def getFaceBrightness(face: EnumFacing): Float = { - face match { + /*face match { case EnumFacing.DOWN => 0.5f case EnumFacing.UP => 1.0f case EnumFacing.NORTH | EnumFacing.SOUTH => 0.8f case EnumFacing.WEST | EnumFacing.EAST => 0.6f - } + }*/ + + //minecraft already applies tint based on quad's facing, so there is no need to apply it second time + 1.0f } } diff --git a/src/main/scala/li/cil/oc/common/item/data/PrintData.scala b/src/main/scala/li/cil/oc/common/item/data/PrintData.scala index 3f1ac731ea..b05e4754c9 100644 --- a/src/main/scala/li/cil/oc/common/item/data/PrintData.scala +++ b/src/main/scala/li/cil/oc/common/item/data/PrintData.scala @@ -6,10 +6,11 @@ import li.cil.oc.Constants import li.cil.oc.Settings import li.cil.oc.api import li.cil.oc.common.IMC +import li.cil.oc.common.item.data.PrintData.Shape import li.cil.oc.util.ExtendedAABB._ import li.cil.oc.util.ExtendedNBT._ import net.minecraft.item.ItemStack -import net.minecraft.nbt.NBTTagCompound +import net.minecraft.nbt.{NBTBase, NBTTagCompound, NBTTagList} import net.minecraft.util.math.AxisAlignedBB import net.minecraftforge.common.util.Constants.NBT @@ -97,13 +98,35 @@ class PrintData extends ItemData(Constants.BlockName.Print) { nbt.setBoolean(IsButtonModeTag, isButtonMode) nbt.setInteger(RedstoneLevelTag, redstoneLevel) nbt.setBoolean(PressurePlateTag, pressurePlate) - nbt.setNewTagList(StateOffTag, stateOff.map(PrintData.shapeToNBT)) - nbt.setNewTagList(StateOnTag, stateOn.map(PrintData.shapeToNBT)) + setNewShapeSet(nbt, StateOffTag, stateOff) + setNewShapeSet(nbt, StateOnTag, stateOn) nbt.setBoolean(IsBeaconBaseTag, isBeaconBase) nbt.setByte(LightLevelTag, lightLevel.toByte) nbt.setBoolean(NoclipOffTag, noclipOff) nbt.setBoolean(NoclipOnTag, noclipOn) } + + // Shapes are stored in a set and sets do not have an order, that means NBT shape lists may be in any order. + // Because NBT list comparison considers order of tags in a list, and prints may have arbitrarily ordered list of shapes, + // the comparison fails and minecraft considers two identical prints different. + // One possible solution is to sort the shapes before serializing them to NBT + private def setNewShapeSet(nbt: NBTTagCompound, name: String, values: Iterable[Shape]) = { + val seq = values.toSeq.sortWith(compareShape); + nbt.setNewTagList(name, seq.map(PrintData.shapeToNBT)) + } + + private def compareShape(a: Shape, b: Shape): Boolean = { + import scala.math.Ordering.Implicits._ + if (a.bounds.minX != b.bounds.minX) return a.bounds.minX > b.bounds.minX; + if (a.bounds.minY != b.bounds.minY) return a.bounds.minY > b.bounds.minY; + if (a.bounds.minZ != b.bounds.minZ) return a.bounds.minZ > b.bounds.minZ; + if (a.bounds.maxX != b.bounds.maxX) return a.bounds.maxX > b.bounds.maxX; + if (a.bounds.maxY != b.bounds.maxY) return a.bounds.maxY > b.bounds.maxY; + if (a.bounds.maxZ != b.bounds.maxZ) return a.bounds.maxZ > b.bounds.maxZ; + if (a.tint != b.tint) return a.tint > b.tint; + if (a.texture != b.texture) return a.texture > b.texture; + false + } } object PrintData {