Also calling doCustomInit on client side.

This commit is contained in:
Florian Nücke 2015-03-23 01:58:35 +01:00
parent 19c9ed70b9
commit 799224e92b
4 changed files with 18 additions and 20 deletions

View File

@ -102,8 +102,10 @@ class Microcontroller(protected implicit val tileTag: ClassTag[tileentity.Microc
override protected def doCustomInit(tileEntity: tileentity.Microcontroller, player: EntityLivingBase, stack: ItemStack): Unit = {
super.doCustomInit(tileEntity, player, stack)
tileEntity.info.load(stack)
tileEntity.snooperNode.changeBuffer(tileEntity.info.storedEnergy - tileEntity.snooperNode.localBuffer)
if (!tileEntity.world.isRemote) {
tileEntity.info.load(stack)
tileEntity.snooperNode.changeBuffer(tileEntity.info.storedEnergy - tileEntity.snooperNode.localBuffer)
}
}
override protected def doCustomDrops(tileEntity: tileentity.Microcontroller, player: EntityPlayer, willHarvest: Boolean): Unit = {

View File

@ -55,14 +55,16 @@ class Raid(protected implicit val tileTag: ClassTag[tileentity.Raid]) extends Si
override protected def doCustomInit(tileEntity: tileentity.Raid, player: EntityLivingBase, stack: ItemStack): Unit = {
super.doCustomInit(tileEntity, player, stack)
val data = new RaidData(stack)
for (i <- 0 until math.min(data.disks.length, tileEntity.getSizeInventory)) {
tileEntity.setInventorySlotContents(i, data.disks(i))
}
data.label.foreach(tileEntity.label.setLabel)
if (!data.filesystem.hasNoTags) {
tileEntity.tryCreateRaid(data.filesystem.getCompoundTag("node").getString("address"))
tileEntity.filesystem.foreach(_.load(data.filesystem))
if (!tileEntity.world.isRemote) {
val data = new RaidData(stack)
for (i <- 0 until math.min(data.disks.length, tileEntity.getSizeInventory)) {
tileEntity.setInventorySlotContents(i, data.disks(i))
}
data.label.foreach(tileEntity.label.setLabel)
if (!data.filesystem.hasNoTags) {
tileEntity.tryCreateRaid(data.filesystem.getCompoundTag("node").getString("address"))
tileEntity.filesystem.foreach(_.load(data.filesystem))
}
}
}

View File

@ -31,12 +31,10 @@ trait CustomDrops[Tile <: TileEntity] extends SimpleBlock {
override def onBlockPlacedBy(world: World, x: Int, y: Int, z: Int, player: EntityLivingBase, stack: ItemStack): Unit = {
super.onBlockPlacedBy(world, x, y, z, player, stack)
if (!world.isRemote) {
val matcher = tileTag
world.getTileEntity(x, y, z) match {
case matcher(tileEntity) => doCustomInit(tileEntity, player, stack)
case _ =>
}
val matcher = tileTag
world.getTileEntity(x, y, z) match {
case matcher(tileEntity) => doCustomInit(tileEntity, player, stack)
case _ =>
}
}

View File

@ -4,10 +4,6 @@ import li.cil.oc.api.Persistable
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
object ItemData {
}
abstract class ItemData extends Persistable {
def load(stack: ItemStack) {
if (stack.hasTagCompound) {