More sidedness -.-

Also, BlockPos.subtract is client side only? Really now?
This commit is contained in:
Florian Nücke 2015-02-20 01:00:47 +01:00
parent dad119cace
commit d84da8e9b5
5 changed files with 25 additions and 17 deletions

View File

@ -53,19 +53,21 @@ object Loot {
def initForWorld(e: WorldEvent.Load) {
worldDisks.clear()
disks.clear()
val path = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + "loot/")
if (path.exists && path.isDirectory) {
val listFile = new io.File(path, "loot.properties")
if (listFile.exists && listFile.isFile) {
try {
val listStream = new io.FileInputStream(listFile)
val list = new java.util.Properties()
list.load(listStream)
listStream.close()
parseLootDisks(list, worldDisks)
}
catch {
case t: Throwable => OpenComputers.log.warn("Failed opening loot descriptor file in saves folder.")
if (!e.world.isRemote) {
val path = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + "loot/")
if (path.exists && path.isDirectory) {
val listFile = new io.File(path, "loot.properties")
if (listFile.exists && listFile.isFile) {
try {
val listStream = new io.FileInputStream(listFile)
val list = new java.util.Properties()
list.load(listStream)
listStream.close()
parseLootDisks(list, worldDisks)
}
catch {
case t: Throwable => OpenComputers.log.warn("Failed opening loot descriptor file in saves folder.")
}
}
}
}

View File

@ -75,7 +75,10 @@ class RobotAfterimage extends SimpleBlock {
case Some(robot) =>
val block = robot.getBlockType
block.setBlockBoundsBasedOnState(world, robot.getPos)
val delta = robot.moveFrom.fold(Vec3i.NULL_VECTOR)(robot.getPos.subtract(_))
val delta = robot.moveFrom.fold(Vec3i.NULL_VECTOR)(vec => {
val blockPos = robot.getPos
new BlockPos(blockPos.getX - vec.getX, blockPos.getY - vec.getY, blockPos.getZ - vec.getZ)
})
setBlockBounds(new AxisAlignedBB(
block.getBlockBoundsMinX, block.getBlockBoundsMinY, block.getBlockBoundsMinZ,
block.getBlockBoundsMaxX, block.getBlockBoundsMaxY, block.getBlockBoundsMaxZ).

View File

@ -171,7 +171,9 @@ class RobotProxy extends RedstoneAware with traits.StateAware {
val bounds = AxisAlignedBB.fromBounds(0.1, 0.1, 0.1, 0.9, 0.9, 0.9)
setBlockBounds(if (robot.isAnimatingMove) {
val remaining = robot.animationTicksLeft.toDouble / robot.animationTicksTotal.toDouble
val delta = robot.moveFrom.get.subtract(robot.getPos)
val blockPos = robot.moveFrom.get
val vec = robot.getPos
val delta = new BlockPos(blockPos.getX - vec.getX, blockPos.getY - vec.getY, blockPos.getZ - vec.getZ)
bounds.offset(delta.getX * remaining, delta.getY * remaining, delta.getZ * remaining)
}
else bounds)

View File

@ -12,6 +12,7 @@ import li.cil.oc.common.item.HardDiskDrive
import li.cil.oc.server.fs.FileSystem.ItemLabel
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.DimensionManager
object DriverFileSystem extends Item {
override def worksWith(stack: ItemStack) = isOneOf(stack,
@ -38,7 +39,7 @@ object DriverFileSystem extends Item {
case _ => 0
}
private def createEnvironment(stack: ItemStack, capacity: Int, host: EnvironmentHost) = if (!host.world.isRemote) {
private def createEnvironment(stack: ItemStack, capacity: Int, host: EnvironmentHost) = if (DimensionManager.getWorld(0) != null) {
// We have a bit of a chicken-egg problem here, because we want to use the
// node's address as the folder name... so we generate the address here,
// if necessary. No one will know, right? Right!?

View File

@ -17,7 +17,7 @@ object DriverLootDisk extends Item {
(stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "lootPath"))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (stack.hasTagCompound && !host.world.isRemote) {
if (stack.hasTagCompound && DimensionManager.getWorld(0) != null) {
val lootPath = "loot/" + stack.getTagCompound.getString(Settings.namespace + "lootPath")
val savePath = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + lootPath)
val fs =