diff --git a/src/main/resources/assets/opencomputers/textures/entity/drone.png b/src/main/resources/assets/opencomputers/textures/entity/drone.png deleted file mode 100644 index d26229b5c..000000000 Binary files a/src/main/resources/assets/opencomputers/textures/entity/drone.png and /dev/null differ diff --git a/src/main/resources/assets/opencomputers/textures/model/drone.png b/src/main/resources/assets/opencomputers/textures/model/drone.png new file mode 100644 index 000000000..f8074e3cd Binary files /dev/null and b/src/main/resources/assets/opencomputers/textures/model/drone.png differ diff --git a/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala b/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala index cf43b1653..4eb39344e 100644 --- a/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala +++ b/src/main/scala/li/cil/oc/client/renderer/entity/ModelQuadcopter.scala @@ -11,7 +11,7 @@ import net.minecraft.util.Vec3 import org.lwjgl.opengl.GL11 final class ModelQuadcopter extends ModelBase { - val texture = new ResourceLocation(Settings.resourceDomain, "textures/entity/drone.png") + val texture = new ResourceLocation(Settings.resourceDomain, "textures/model/drone.png") val body = new ModelRenderer(this, "body") val wing0 = new ModelRenderer(this, "wing0") @@ -109,6 +109,15 @@ final class ModelQuadcopter extends ModelBase { light3.rotateAngleX = drone.flapAngles(3)(0) light3.rotateAngleZ = drone.flapAngles(3)(1) + // Additive blending for the lights. + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + // Light color. + val lightColor = drone.lightColor + val r = ((lightColor >>> 16) & 0xFF).toByte + val g = ((lightColor >>> 8) & 0xFF).toByte + val b = ((lightColor >>> 0) & 0xFF).toByte + GL11.glColor3ub(r, g, b) + light0.render(scale) light1.render(scale) light2.render(scale) @@ -147,6 +156,9 @@ final class ModelQuadcopter extends ModelBase { light3.rotateAngleX = tilt light3.rotateAngleZ = -tilt + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE) + GL11.glColor3ub(0x66.toByte, 0xDD.toByte, 0x55.toByte) + light0.render(scale) light1.render(scale) light2.render(scale) diff --git a/src/main/scala/li/cil/oc/common/entity/Drone.scala b/src/main/scala/li/cil/oc/common/entity/Drone.scala index cd5fd43fe..dbb372731 100644 --- a/src/main/scala/li/cil/oc/common/entity/Drone.scala +++ b/src/main/scala/li/cil/oc/common/entity/Drone.scala @@ -196,6 +196,8 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern dataWatcher.addObject(10, "") // Inventory size for client. dataWatcher.addObject(11, byte2Byte(0: Byte)) + // Light color. + dataWatcher.addObject(12, int2Integer(0x66DD55)) } def initializeAfterPlacement(stack: ItemStack, player: EntityPlayer, position: Vec3) { @@ -232,6 +234,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern def globalBufferSize = dataWatcher.getWatchableObjectInt(9) def statusText = dataWatcher.getWatchableObjectString(10) def inventorySize = dataWatcher.getWatchableObjectByte(11) & 0xFF + def lightColor = dataWatcher.getWatchableObjectInt(12) def setRunning(value: Boolean) = dataWatcher.updateObject(2, byte2Byte(if (value) 1: Byte else 0: Byte)) // Round target values to low accuracy to avoid floating point errors accumulating. @@ -244,6 +247,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern def globalBufferSize_=(value: Int) = dataWatcher.updateObject(9, int2Integer(value)) def statusText_=(value: String) = dataWatcher.updateObject(10, Option(value).map(_.lines.map(_.take(10)).take(2).mkString("\n")).getOrElse("")) def inventorySize_=(value: Int) = dataWatcher.updateObject(11, byte2Byte(value.toByte)) + def lightColor_=(value: Int) = dataWatcher.updateObject(12, int2Integer(value)) @SideOnly(Side.CLIENT) override def setPositionAndRotation2(x: Double, y: Double, z: Double, yaw: Float, pitch: Float, data: Int) { @@ -436,6 +440,7 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern selectedSlot = nbt.getByte("selectedSlot") & 0xFF selectedTank = nbt.getByte("selectedTank") & 0xFF statusText = nbt.getString("statusText") + lightColor = nbt.getInteger("lightColor") } override def writeEntityToNBT(nbt: NBTTagCompound) { @@ -455,5 +460,6 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern nbt.setByte("selectedSlot", selectedSlot.toByte) nbt.setByte("selectedTank", selectedTank.toByte) nbt.setString("statusText", statusText) + nbt.setInteger("lightColor", lightColor) } } diff --git a/src/main/scala/li/cil/oc/server/component/Drone.scala b/src/main/scala/li/cil/oc/server/component/Drone.scala index ae01c8237..9e4bcdd42 100644 --- a/src/main/scala/li/cil/oc/server/component/Drone.scala +++ b/src/main/scala/li/cil/oc/server/component/Drone.scala @@ -58,6 +58,16 @@ class Drone(val host: entity.Drone) extends prefab.ManagedEnvironment with trait result(host.statusText) } + @Callback(doc = "function():number -- Get the current color of the flap lights as an integer encoded RGB value (0xRRGGBB).") + def getLightColor(context: Context, args: Arguments): Array[AnyRef] = result(host.lightColor) + + @Callback(doc = "function(value:number):number -- Set the color of the flap lights to the specified integer encoded RGB value (0xRRGGBB).") + def setLightColor(context: Context, args: Arguments): Array[AnyRef] = { + host.lightColor = args.checkInteger(0) + context.pause(0.1) + result(host.lightColor) + } + // ----------------------------------------------------------------------- // @Callback(doc = "function(dx:number, dy:number, dz:number) -- Change the target position by the specified offset.")