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) { def initForWorld(e: WorldEvent.Load) {
worldDisks.clear() worldDisks.clear()
disks.clear() disks.clear()
val path = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + "loot/") if (!e.world.isRemote) {
if (path.exists && path.isDirectory) { val path = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + "loot/")
val listFile = new io.File(path, "loot.properties") if (path.exists && path.isDirectory) {
if (listFile.exists && listFile.isFile) { val listFile = new io.File(path, "loot.properties")
try { if (listFile.exists && listFile.isFile) {
val listStream = new io.FileInputStream(listFile) try {
val list = new java.util.Properties() val listStream = new io.FileInputStream(listFile)
list.load(listStream) val list = new java.util.Properties()
listStream.close() list.load(listStream)
parseLootDisks(list, worldDisks) listStream.close()
} parseLootDisks(list, worldDisks)
catch { }
case t: Throwable => OpenComputers.log.warn("Failed opening loot descriptor file in saves folder.") 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) => case Some(robot) =>
val block = robot.getBlockType val block = robot.getBlockType
block.setBlockBoundsBasedOnState(world, robot.getPos) 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( setBlockBounds(new AxisAlignedBB(
block.getBlockBoundsMinX, block.getBlockBoundsMinY, block.getBlockBoundsMinZ, block.getBlockBoundsMinX, block.getBlockBoundsMinY, block.getBlockBoundsMinZ,
block.getBlockBoundsMaxX, block.getBlockBoundsMaxY, block.getBlockBoundsMaxZ). 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) val bounds = AxisAlignedBB.fromBounds(0.1, 0.1, 0.1, 0.9, 0.9, 0.9)
setBlockBounds(if (robot.isAnimatingMove) { setBlockBounds(if (robot.isAnimatingMove) {
val remaining = robot.animationTicksLeft.toDouble / robot.animationTicksTotal.toDouble 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) bounds.offset(delta.getX * remaining, delta.getY * remaining, delta.getZ * remaining)
} }
else bounds) else bounds)

View File

@ -12,6 +12,7 @@ import li.cil.oc.common.item.HardDiskDrive
import li.cil.oc.server.fs.FileSystem.ItemLabel import li.cil.oc.server.fs.FileSystem.ItemLabel
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound import net.minecraft.nbt.NBTTagCompound
import net.minecraftforge.common.DimensionManager
object DriverFileSystem extends Item { object DriverFileSystem extends Item {
override def worksWith(stack: ItemStack) = isOneOf(stack, override def worksWith(stack: ItemStack) = isOneOf(stack,
@ -38,7 +39,7 @@ object DriverFileSystem extends Item {
case _ => 0 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 // 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, // node's address as the folder name... so we generate the address here,
// if necessary. No one will know, right? Right!? // 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")) (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "lootPath"))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) = 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 lootPath = "loot/" + stack.getTagCompound.getString(Settings.namespace + "lootPath")
val savePath = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + lootPath) val savePath = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + lootPath)
val fs = val fs =