mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 19:56:17 -04:00
Saving robot UUID.
This commit is contained in:
parent
632080cb92
commit
c5845ead53
@ -165,13 +165,14 @@ class RobotProxy(val parent: SpecialDelegator) extends RedstoneAware with Specia
|
||||
super.addedByEntity(world, x, y, z, entity, stack)
|
||||
if (!world.isRemote) ((entity, world.getTileEntity(x, y, z)) match {
|
||||
case (player: robot.Player, proxy: tileentity.RobotProxy) =>
|
||||
Some((proxy.robot, player.robot.owner))
|
||||
Some((proxy.robot, player.robot.owner, player.robot.ownerUuid))
|
||||
case (player: EntityPlayer, proxy: tileentity.RobotProxy) =>
|
||||
Some((proxy.robot, player.getCommandSenderName))
|
||||
Some((proxy.robot, player.getCommandSenderName, Option(player.getGameProfile.getId)))
|
||||
case _ => None
|
||||
}) match {
|
||||
case Some((robot, owner)) =>
|
||||
case Some((robot, owner, uuid)) =>
|
||||
robot.owner = owner
|
||||
robot.ownerUuid = uuid
|
||||
robot.info.load(stack)
|
||||
robot.bot.node.changeBuffer(robot.info.robotEnergy - robot.bot.node.localBuffer)
|
||||
robot.updateInventorySize()
|
||||
@ -189,7 +190,7 @@ class RobotProxy(val parent: SpecialDelegator) extends RedstoneAware with Specia
|
||||
robot.saveComponents()
|
||||
parent.internalDropBlockAsItem(world, x, y, z, robot.info.createItemStack())
|
||||
}
|
||||
if (Blocks.blockSpecial.subBlock(world, robot.moveFromX, robot.moveFromY, robot.moveFromZ).exists(_ == Blocks.robotAfterimage)) {
|
||||
if (Blocks.blockSpecial.subBlock(world, robot.moveFromX, robot.moveFromY, robot.moveFromZ).contains(Blocks.robotAfterimage)) {
|
||||
world.setBlock(robot.moveFromX, robot.moveFromY, robot.moveFromZ, net.minecraft.init.Blocks.air, 0, 1)
|
||||
}
|
||||
case _ =>
|
||||
|
@ -1,5 +1,7 @@
|
||||
package li.cil.oc.common.tileentity
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import li.cil.oc._
|
||||
import li.cil.oc.api.Driver
|
||||
@ -93,6 +95,8 @@ class Robot extends traits.Computer with traits.PowerInformation with api.machin
|
||||
|
||||
var owner = "OpenComputers"
|
||||
|
||||
var ownerUuid: Option[UUID] = None
|
||||
|
||||
var animationTicksLeft = 0
|
||||
|
||||
var animationTicksTotal = 0
|
||||
@ -326,6 +330,9 @@ class Robot extends traits.Computer with traits.PowerInformation with api.machin
|
||||
if (nbt.hasKey(Settings.namespace + "owner")) {
|
||||
owner = nbt.getString(Settings.namespace + "owner")
|
||||
}
|
||||
if (nbt.hasKey(Settings.namespace + "ownerUuid")) {
|
||||
ownerUuid = Option(UUID.fromString(nbt.getString(Settings.namespace + "ownerUuid")))
|
||||
}
|
||||
if (inventorySize > 0) {
|
||||
selectedSlot = nbt.getInteger(Settings.namespace + "selectedSlot") max inventorySlots.min min inventorySlots.max
|
||||
}
|
||||
@ -348,6 +355,7 @@ class Robot extends traits.Computer with traits.PowerInformation with api.machin
|
||||
// which is a bit ugly, and may be refactored some day, but it works.
|
||||
nbt.setNewCompoundTag(Settings.namespace + "robot", bot.save)
|
||||
nbt.setString(Settings.namespace + "owner", owner)
|
||||
ownerUuid.foreach(uuid => nbt.setString(Settings.namespace + "ownerUuid", uuid.toString))
|
||||
nbt.setInteger(Settings.namespace + "selectedSlot", selectedSlot)
|
||||
if (isAnimatingMove || isAnimatingSwing || isAnimatingTurn) {
|
||||
nbt.setInteger(Settings.namespace + "animationTicksTotal", animationTicksTotal)
|
||||
|
@ -33,10 +33,7 @@ import scala.reflect._
|
||||
|
||||
object Player {
|
||||
def profileFor(robot: tileentity.Robot) = {
|
||||
val uuid = Option(MinecraftServer.getServer.getConfigurationManager.func_152612_a(robot.owner)) match {
|
||||
case Some(player) => player.getGameProfile.getId
|
||||
case _ => UUID.randomUUID()
|
||||
}
|
||||
val uuid = robot.ownerUuid.getOrElse(UUID.randomUUID())
|
||||
val randomId = (robot.world.rand.nextInt(0xFFFFFF) + 1).toString
|
||||
val name = Settings.get.nameFormat.
|
||||
replace("$player$", robot.owner).
|
||||
|
Loading…
x
Reference in New Issue
Block a user