mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'master' of github.com:MightyPirates/OpenComputers
This commit is contained in:
commit
7fded0afea
@ -1,6 +1,6 @@
|
||||
minecraft.version=1.6.4
|
||||
forge.version=9.11.1.964
|
||||
oc.version=1.2.2
|
||||
oc.version=1.2.3
|
||||
ccl.version=1.0.0.62
|
||||
fmp.version=1.0.0.250
|
||||
maven.url=file:///var/www/users/fnuecke/maven.cil.li
|
@ -37,5 +37,5 @@
|
||||
@cpw.mods.fml.common.API(
|
||||
owner = "OpenComputers|Core",
|
||||
provides = "OpenComputersAPI",
|
||||
apiVersion = "1.4.4")
|
||||
apiVersion = "1.4.5")
|
||||
package li.cil.oc.api;
|
@ -164,7 +164,6 @@ local function handleCommand(prefix, command, args, message)
|
||||
sock:write("NOTICE " .. name(prefix) .. " :\001VERSION Minecraft/OpenComputers Lua 5.2\001\r\n")
|
||||
sock:flush()
|
||||
elseif string.find(message, "\001PING") then
|
||||
print("NOTICE " .. name(prefix) .. " :" .. message .. "\001\r\n")
|
||||
sock:write("NOTICE " .. name(prefix) .. " :" .. message .. "\001\r\n")
|
||||
sock:flush()
|
||||
end
|
||||
|
30
src/main/resources/assets/opencomputers/robot.names
Normal file
30
src/main/resources/assets/opencomputers/robot.names
Normal file
@ -0,0 +1,30 @@
|
||||
# This a list of names that robots are randomly named after, unless
|
||||
# explicitly named using an anvil.
|
||||
# If your name is on this list and you'd rather it not be, or you'd like a
|
||||
# different alias, sorry! Please make a pull request with the changed list.
|
||||
asie
|
||||
crafteverywhere
|
||||
LordFokas
|
||||
Michiyo
|
||||
mymagadsl
|
||||
PixelToast
|
||||
Pyrolusite
|
||||
SpiritedDusty
|
||||
Vexatos
|
||||
Wobbo
|
||||
YuRaNnNzZZ
|
||||
|
||||
# Names of more or less famous robots, as a bit of filler material. Feel free
|
||||
# to add more via pull requests. Let's hope this won't get us sued...
|
||||
Atlas
|
||||
Bender
|
||||
C-3PO
|
||||
Clank
|
||||
Claptrap
|
||||
Dog
|
||||
GLaDOS
|
||||
KITT
|
||||
Marvin
|
||||
P-Body
|
||||
R2-D2
|
||||
Wheatley
|
@ -54,6 +54,9 @@ opencomputers {
|
||||
# attached to it). For valid key names, please see the following list:
|
||||
# https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/input/Keyboard.java#L73
|
||||
pasteShortcut: [LSHIFT, INSERT]
|
||||
|
||||
# Render robots' names as a label above them when near them
|
||||
robotLabels: true
|
||||
}
|
||||
|
||||
# Computer related settings, concerns server performance and security.
|
||||
|
@ -25,6 +25,7 @@ class Settings(config: Config) {
|
||||
val textLinearFiltering = config.getBoolean("client.textLinearFiltering")
|
||||
val textAntiAlias = config.getBoolean("client.textAntiAlias")
|
||||
val pasteShortcut = config.getStringList("client.pasteShortcut").toSet
|
||||
val robotLabels = config.getBoolean("client.robotLabels")
|
||||
val rTreeDebugRenderer = false // *Not* to be configurable via config file.
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
@ -78,6 +78,7 @@ object MonospaceFontRenderer {
|
||||
GL11.glTranslatef(x, y, 0)
|
||||
GL11.glScalef(0.5f, 0.5f, 1)
|
||||
GL11.glDepthMask(false)
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D)
|
||||
|
||||
// Background first. We try to merge adjacent backgrounds of the same
|
||||
// color to reduce the number of quads we have to draw.
|
||||
|
@ -1,11 +1,12 @@
|
||||
package li.cil.oc.client.renderer.tileentity
|
||||
|
||||
import com.google.common.base.Strings
|
||||
import java.util.logging.Level
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.client.TexturePreloader
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.util.RenderState
|
||||
import net.minecraft.client.renderer.entity.RenderManager
|
||||
import li.cil.oc.{Settings, OpenComputers}
|
||||
import net.minecraft.client.renderer.entity.{RendererLivingEntity, RenderManager}
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.client.renderer.{Tessellator, GLAllocation}
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
@ -175,6 +176,48 @@ object RobotRenderer extends TileEntitySpecialRenderer {
|
||||
GL11.glPushMatrix()
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
|
||||
val name = robot.name
|
||||
if (Settings.get.robotLabels && !Strings.isNullOrEmpty(name) && x * x + y * y + z * z < RendererLivingEntity.NAME_TAG_RANGE) {
|
||||
GL11.glPushMatrix()
|
||||
|
||||
// This is pretty much copy-pasta from the entity's label renderer.
|
||||
val t = Tessellator.instance
|
||||
val f = getFontRenderer
|
||||
val scale = 1.6f / 60f
|
||||
val width = f.getStringWidth(name)
|
||||
val halfWidth = width / 2
|
||||
|
||||
GL11.glTranslated(0, 0.7, 0)
|
||||
GL11.glNormal3f(0, 1, 0)
|
||||
|
||||
GL11.glRotatef(-tileEntityRenderer.playerYaw, 0, 1, 0)
|
||||
GL11.glRotatef(tileEntityRenderer.playerPitch, 1, 0, 0)
|
||||
GL11.glScalef(-scale, -scale, scale)
|
||||
|
||||
RenderState.makeItBlend()
|
||||
GL11.glDisable(GL11.GL_LIGHTING)
|
||||
GL11.glDepthMask(false)
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D)
|
||||
|
||||
t.startDrawingQuads()
|
||||
t.setColorRGBA_F(0, 0, 0, 0.25f)
|
||||
t.addVertex(-halfWidth - 1, -1, 0)
|
||||
t.addVertex(-halfWidth - 1, 8, 0)
|
||||
t.addVertex(halfWidth + 1, 8, 0)
|
||||
t.addVertex(halfWidth + 1, -1, 0)
|
||||
t.draw
|
||||
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D) // For the font.
|
||||
f.drawString(name, -halfWidth, 0, 0xFFFFFFFF)
|
||||
|
||||
GL11.glDepthMask(true)
|
||||
GL11.glEnable(GL11.GL_LIGHTING)
|
||||
GL11.glDisable(GL11.GL_BLEND)
|
||||
GL11.glColor4f(1, 1, 1, 1)
|
||||
|
||||
GL11.glPopMatrix()
|
||||
}
|
||||
|
||||
// If the move started while we were rendering and we have a reference to
|
||||
// the *old* proxy the robot would be rendered at the wrong position, so we
|
||||
// correct for the offset.
|
||||
|
@ -9,7 +9,7 @@ import li.cil.oc.server.component.robot
|
||||
import li.cil.oc.server.driver.Registry
|
||||
import li.cil.oc.server.{PacketSender => ServerPacketSender, driver, component}
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.{Blocks, Settings, api, common}
|
||||
import li.cil.oc._
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.inventory.ISidedInventory
|
||||
@ -17,6 +17,9 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.ChatMessageComponent
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
import scala.io.Source
|
||||
import scala.Some
|
||||
import java.util.logging.Level
|
||||
|
||||
// Implementation note: this tile entity is never directly added to the world.
|
||||
// It is always wrapped by a `RobotProxy` tile entity, which forwards any
|
||||
@ -26,6 +29,7 @@ import net.minecraftforge.common.ForgeDirection
|
||||
// old proxy, which will be cleaned up by Minecraft like any other tile entity.
|
||||
class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory with Buffer with PowerInformation with api.machine.Robot {
|
||||
def this() = this(false)
|
||||
|
||||
if (isServer) {
|
||||
computer.setCostPerTick(Settings.get.robotCost)
|
||||
}
|
||||
@ -41,6 +45,16 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
|
||||
override def player() = player(facing, facing)
|
||||
|
||||
def name: String = {
|
||||
if (tag != null && tag.hasKey("display")) {
|
||||
val display = tag.getCompoundTag("display")
|
||||
if (display != null && display.hasKey("Name")) {
|
||||
return display.getString("Name")
|
||||
}
|
||||
}
|
||||
null
|
||||
}
|
||||
|
||||
override def saveUpgrade() = this.synchronized {
|
||||
components(3) match {
|
||||
case Some(environment) =>
|
||||
@ -75,6 +89,8 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
|
||||
var owner = "OpenComputers"
|
||||
|
||||
var tag: NBTTagCompound = _
|
||||
|
||||
var xp = 0.0
|
||||
|
||||
def xpForNextLevel = xpForLevel(level + 1)
|
||||
@ -196,24 +212,30 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
|
||||
def createItemStack() = {
|
||||
val stack = Blocks.robotProxy.createItemStack()
|
||||
if (globalBuffer > 1 || xp > 0) {
|
||||
stack.setTagCompound(new NBTTagCompound("tag"))
|
||||
}
|
||||
val tag = if (this.tag != null) this.tag.copy.asInstanceOf[NBTTagCompound] else new NBTTagCompound("tag")
|
||||
stack.setTagCompound(tag)
|
||||
if (xp > 0) {
|
||||
stack.getTagCompound.setDouble(Settings.namespace + "xp", xp)
|
||||
tag.setDouble(Settings.namespace + "xp", xp)
|
||||
}
|
||||
if (globalBuffer > 1) {
|
||||
stack.getTagCompound.setInteger(Settings.namespace + "storedEnergy", globalBuffer.toInt)
|
||||
tag.setInteger(Settings.namespace + "storedEnergy", globalBuffer.toInt)
|
||||
}
|
||||
stack
|
||||
}
|
||||
|
||||
def parseItemStack(stack: ItemStack) {
|
||||
if (stack.hasTagCompound) {
|
||||
xp = stack.getTagCompound.getDouble(Settings.namespace + "xp")
|
||||
tag = stack.getTagCompound.copy.asInstanceOf[NBTTagCompound]
|
||||
xp = tag.getDouble(Settings.namespace + "xp")
|
||||
updateXpInfo()
|
||||
bot.node.changeBuffer(stack.getTagCompound.getInteger(Settings.namespace + "storedEnergy"))
|
||||
}
|
||||
else {
|
||||
tag = new NBTTagCompound("tag")
|
||||
}
|
||||
if (name == null) {
|
||||
tag.setNewCompoundTag("display", tag => tag.setString("Name", Robot.randomName))
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
@ -330,6 +352,9 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
if (nbt.hasKey(Settings.namespace + "owner")) {
|
||||
owner = nbt.getString(Settings.namespace + "owner")
|
||||
}
|
||||
if (nbt.hasKey(Settings.namespace + "tag")) {
|
||||
tag = nbt.getCompoundTag(Settings.namespace + "tag")
|
||||
}
|
||||
xp = nbt.getDouble(Settings.namespace + "xp") max 0
|
||||
updateXpInfo()
|
||||
selectedSlot = nbt.getInteger(Settings.namespace + "selectedSlot") max actualSlot(0) min (getSizeInventory - 1)
|
||||
@ -353,6 +378,9 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
nbt.setNewCompoundTag(Settings.namespace + "keyboard", keyboard.save)
|
||||
nbt.setNewCompoundTag(Settings.namespace + "robot", bot.save)
|
||||
nbt.setString(Settings.namespace + "owner", owner)
|
||||
if (tag != null) {
|
||||
nbt.setCompoundTag(Settings.namespace + "tag", tag)
|
||||
}
|
||||
nbt.setDouble(Settings.namespace + "xp", xp)
|
||||
nbt.setInteger(Settings.namespace + "selectedSlot", selectedSlot)
|
||||
if (isAnimatingMove || isAnimatingSwing || isAnimatingTurn) {
|
||||
@ -369,6 +397,9 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def readFromNBTForClient(nbt: NBTTagCompound) {
|
||||
super.readFromNBTForClient(nbt)
|
||||
if (nbt.hasKey(Settings.namespace + "tag")) {
|
||||
tag = nbt.getCompoundTag(Settings.namespace + "tag")
|
||||
}
|
||||
selectedSlot = nbt.getInteger("selectedSlot")
|
||||
if (nbt.hasKey("equipped")) {
|
||||
equippedItem = Option(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("equipped")))
|
||||
@ -391,6 +422,9 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
|
||||
override def writeToNBTForClient(nbt: NBTTagCompound) = this.synchronized {
|
||||
super.writeToNBTForClient(nbt)
|
||||
if (tag != null) {
|
||||
nbt.setCompoundTag(Settings.namespace + "tag", tag)
|
||||
}
|
||||
nbt.setInteger("selectedSlot", selectedSlot)
|
||||
if (getStackInSlot(0) != null) {
|
||||
nbt.setNewCompoundTag("equipped", getStackInSlot(0).writeToNBT)
|
||||
@ -564,3 +598,18 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
||||
case _ => (actualSlot(0) until getSizeInventory).toArray
|
||||
}
|
||||
}
|
||||
|
||||
object Robot {
|
||||
val names = try {
|
||||
Source.fromInputStream(getClass.getResourceAsStream(
|
||||
"/assets/" + Settings.resourceDomain + "/robot.names"))("UTF-8").
|
||||
getLines().map(_.trim).filter(!_.startsWith("#")).filter(_ != "").toArray
|
||||
}
|
||||
catch {
|
||||
case t: Throwable =>
|
||||
OpenComputers.log.log(Level.WARNING, "Failed loading robot name list.", t)
|
||||
Array.empty
|
||||
}
|
||||
|
||||
def randomName = names((math.random * names.length).toInt)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user