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 = { override protected def doCustomInit(tileEntity: tileentity.Microcontroller, player: EntityLivingBase, stack: ItemStack): Unit = {
super.doCustomInit(tileEntity, player, stack) super.doCustomInit(tileEntity, player, stack)
tileEntity.info.load(stack) if (!tileEntity.world.isRemote) {
tileEntity.snooperNode.changeBuffer(tileEntity.info.storedEnergy - tileEntity.snooperNode.localBuffer) 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 = { 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 = { override protected def doCustomInit(tileEntity: tileentity.Raid, player: EntityLivingBase, stack: ItemStack): Unit = {
super.doCustomInit(tileEntity, player, stack) super.doCustomInit(tileEntity, player, stack)
val data = new RaidData(stack) if (!tileEntity.world.isRemote) {
for (i <- 0 until math.min(data.disks.length, tileEntity.getSizeInventory)) { val data = new RaidData(stack)
tileEntity.setInventorySlotContents(i, data.disks(i)) 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) { data.label.foreach(tileEntity.label.setLabel)
tileEntity.tryCreateRaid(data.filesystem.getCompoundTag("node").getString("address")) if (!data.filesystem.hasNoTags) {
tileEntity.filesystem.foreach(_.load(data.filesystem)) 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 = { override def onBlockPlacedBy(world: World, x: Int, y: Int, z: Int, player: EntityLivingBase, stack: ItemStack): Unit = {
super.onBlockPlacedBy(world, x, y, z, player, stack) super.onBlockPlacedBy(world, x, y, z, player, stack)
if (!world.isRemote) { val matcher = tileTag
val matcher = tileTag world.getTileEntity(x, y, z) match {
world.getTileEntity(x, y, z) match { case matcher(tileEntity) => doCustomInit(tileEntity, player, stack)
case matcher(tileEntity) => doCustomInit(tileEntity, player, stack) case _ =>
case _ =>
}
} }
} }

View File

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