Initial portering to 1.9.4.

MCMP integration is kinda derpy still (prints don't render correctly when multiparts).
This commit is contained in:
Florian Nücke 2016-05-20 18:19:29 +02:00
parent 378aa8f09b
commit e5b6ea9bb2
28 changed files with 69 additions and 60 deletions

View File

@ -8,7 +8,7 @@ buildscript {
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
}
}
@ -295,7 +295,7 @@ minecraft {
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
mappings = "snapshot_20160506"
mappings = "${config.minecraft.mappings}"
replace "@VERSION@", project.simpleVersion
}

View File

@ -1,5 +1,6 @@
minecraft.version=1.9
forge.version=12.16.0.1865-1.9
minecraft.version=1.9.4
minecraft.mappings=snapshot_20160518
forge.version=12.17.0.1909-1.9.4
oc.version=1.6.0
oc.subversion=dev
@ -30,7 +31,7 @@ gt.version=5.04.06
ic2.version=2.3.131-ex18
igwmod.version=1.1.3-18
jei.version=2.28.7.174
mcmp.version=1.2.0_61
mcmp.version=1.2.0_70
mekanism.build=5
mekanism.version=7.1.2
mfr.cf=2229/626

View File

@ -144,7 +144,7 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
}
@Override
public void writeToNBT(final NBTTagCompound nbt) {
public NBTTagCompound writeToNBT(final NBTTagCompound nbt) {
super.writeToNBT(nbt);
// See readFromNBT() regarding host check.
if (node != null && node.host() == this) {
@ -152,5 +152,6 @@ public abstract class TileEntityEnvironment extends TileEntity implements Enviro
node.save(nodeNbt);
nbt.setTag("oc:node", nodeNbt);
}
return nbt;
}
}

View File

@ -136,7 +136,7 @@ public abstract class TileEntitySidedEnvironment extends TileEntity implements S
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
int index = 0;
for (Node node : nodes) {
@ -148,5 +148,6 @@ public abstract class TileEntitySidedEnvironment extends TileEntity implements S
}
++index;
}
return nbt;
}
}

View File

@ -53,8 +53,8 @@ public abstract class SimpleEnvironment extends TileEntity implements SimpleComp
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
StaticSimpleEnvironment.writeToNBT(this, nbt);
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
return StaticSimpleEnvironment.writeToNBT(this, nbt);
}
// The following methods are only injected if their real versions do not

View File

@ -78,7 +78,7 @@ public final class StaticSimpleEnvironment {
}
}
public static void writeToNBT(final SimpleComponentImpl self, NBTTagCompound nbt) {
public static NBTTagCompound writeToNBT(final SimpleComponentImpl self, NBTTagCompound nbt) {
self.writeToNBT_OpenComputers(nbt);
final Node node = node(self);
if (node != null) {
@ -86,5 +86,6 @@ public final class StaticSimpleEnvironment {
node.save(nodeNbt);
nbt.setTag("oc:node", nodeNbt);
}
return nbt;
}
}

View File

@ -11,11 +11,9 @@ import li.cil.oc.api
import li.cil.oc.api.fs.FileSystem
import li.cil.oc.common.init.Items
import li.cil.oc.util.Color
import net.minecraft.inventory.IInventory
import net.minecraft.item.EnumDyeColor
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.WeightedRandomChestContent
import net.minecraftforge.common.DimensionManager
import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.Loader

View File

@ -12,7 +12,7 @@ import li.cil.oc.api.network.EnvironmentHost
import li.cil.oc.util.BlockPosition
import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.world.ChunkCoordIntPair
import net.minecraft.util.math.ChunkPos
import net.minecraft.world.World
import net.minecraftforge.common.DimensionManager
import net.minecraftforge.event.world.ChunkDataEvent
@ -42,7 +42,7 @@ object SaveHandler {
// which takes a lot of time and is completely unnecessary in those cases.
var savingForClients = false
val saveData = mutable.Map.empty[Int, mutable.Map[ChunkCoordIntPair, mutable.Map[String, Array[Byte]]]]
val saveData = mutable.Map.empty[Int, mutable.Map[ChunkPos, mutable.Map[String, Array[Byte]]]]
def savePath = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath)
@ -71,7 +71,7 @@ object SaveHandler {
def scheduleSave(position: BlockPosition, nbt: NBTTagCompound, name: String, data: Array[Byte]) {
val world = position.world.get
val dimension = world.provider.getDimension
val chunk = new ChunkCoordIntPair(position.x >> 4, position.z >> 4)
val chunk = new ChunkPos(position.x >> 4, position.z >> 4)
// We have to save the dimension and chunk coordinates, because they are
// not available on load / may have changed if the computer was moved.
@ -111,12 +111,12 @@ object SaveHandler {
// Same goes for the chunk. This also works around issues with computers
// being moved (e.g. Redstone in Motion).
val dimension = nbt.getInteger("dimension")
val chunk = new ChunkCoordIntPair(nbt.getInteger("chunkX"), nbt.getInteger("chunkZ"))
val chunk = new ChunkPos(nbt.getInteger("chunkX"), nbt.getInteger("chunkZ"))
load(dimension, chunk, name)
}
def scheduleSave(dimension: Int, chunk: ChunkCoordIntPair, name: String, data: Array[Byte]) = saveData.synchronized {
def scheduleSave(dimension: Int, chunk: ChunkPos, name: String, data: Array[Byte]) = saveData.synchronized {
if (chunk == null) throw new IllegalArgumentException("chunk is null")
else {
// Make sure we get rid of old versions (e.g. left over by other mods
@ -129,7 +129,7 @@ object SaveHandler {
}
}
def load(dimension: Int, chunk: ChunkCoordIntPair, name: String): Array[Byte] = {
def load(dimension: Int, chunk: ChunkPos, name: String): Array[Byte] = {
if (chunk == null) throw new IllegalArgumentException("chunk is null")
// Use data from 'cache' if possible. This avoids weird things happening
// when writeToNBT+readFromNBT is called by other mods (i.e. this is not

View File

@ -20,9 +20,9 @@ object ObfNames {
final val Class_EntityLiving = Array("net/minecraft/entity/EntityLiving", "sb")
final val Class_RenderLiving = Array("net/minecraft/client/renderer/entity/RenderLiving", "bsg")
final val Class_TileEntity = Array("net/minecraft/tileentity/TileEntity", "apv")
final val Field_leashNBTTag = Array("leashNBTTag", "field_110170_bx", "bE")
final val Field_leashedToEntity = Array("leashedToEntity", "field_110168_bw", "bD")
final val Method_recreateLeash = Array("recreateLeash", "func_110165_bF", "cT")
final val Field_leashNBTTag = Array("leashNBTTag", "field_110170_bx", "bF")
final val Field_leashedToEntity = Array("leashedToEntity", "field_110168_bw", "bE")
final val Method_recreateLeash = Array("recreateLeash", "func_110165_bF", "cU")
final val Method_recreateLeashDesc = Array("()V")
final val Method_renderLeash = Array("renderLeash", "func_110827_b", "b")
final val Method_renderLeashDesc = Array("(Lps;DDDFF)V", "(Lnet/minecraft/entity/EntityLiving;DDDFF)V")

View File

@ -16,7 +16,7 @@ class Adapter extends SimpleBlock with traits.GUI {
// ----------------------------------------------------------------------- //
override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) =
override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, neighborBlock: Block): Unit =
world.getTileEntity(pos) match {
case adapter: tileentity.Adapter => adapter.neighborChanged()
case _ => // Ignore.

View File

@ -65,9 +65,9 @@ class Cable(protected implicit val tileTag: ClassTag[tileentity.Cable]) extends
// ----------------------------------------------------------------------- //
override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) {
override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, neighborBlock: Block) {
world.notifyBlockUpdate(pos, state, state, 3)
super.onNeighborBlockChange(world, pos, state, neighborBlock)
super.neighborChanged(state, world, pos, neighborBlock)
}
override protected def doCustomInit(tileEntity: tileentity.Cable, player: EntityLivingBase, stack: ItemStack): Unit = {

View File

@ -35,7 +35,7 @@ class Capacitor extends SimpleBlock {
override def tickRate(world: World) = 1
override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) =
override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, neighborBlock: Block): Unit =
world.getTileEntity(pos) match {
case capacitor: tileentity.Capacitor => capacitor.recomputeCapacity()
case _ =>

View File

@ -52,11 +52,11 @@ class Charger extends RedstoneAware with traits.PowerAcceptor with traits.StateA
}
else super.localOnBlockActivated(world, pos, player, hand, heldItem, side, hitX, hitY, hitZ)
override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) {
override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, neighborBlock: Block): Unit = {
world.getTileEntity(pos) match {
case charger: tileentity.Charger => charger.onNeighborChanged()
case _ =>
}
super.onNeighborBlockChange(world, pos, state, neighborBlock)
super.neighborChanged(state, world, pos, neighborBlock)
}
}

View File

@ -92,7 +92,7 @@ class Keyboard extends SimpleBlock(Material.ROCK) {
})
}
override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) =
override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, neighborBlock: Block): Unit =
world.getTileEntity(pos) match {
case keyboard: tileentity.Keyboard =>
if (!canPlaceBlockOnSide(world, pos, keyboard.facing)) {

View File

@ -36,7 +36,7 @@ abstract class RedstoneAware extends SimpleBlock /* with IRedNetOmniNode TODO MF
// ----------------------------------------------------------------------- //
override def onNeighborBlockChange(world: World, pos: BlockPos, state: IBlockState, neighborBlock: Block) {
override def neighborChanged(state: IBlockState, world: World, pos: BlockPos, neighborBlock: Block): Unit = {
/* TODO MFR
if (Mods.MineFactoryReloaded.isAvailable) {
val position = BlockPosition(x, y, z)

View File

@ -6,7 +6,7 @@ import li.cil.oc.OpenComputers
import li.cil.oc.api.event.RobotMoveEvent
import li.cil.oc.server.component.UpgradeChunkloader
import li.cil.oc.util.BlockPosition
import net.minecraft.world.ChunkCoordIntPair
import net.minecraft.util.math.ChunkPos
import net.minecraft.world.World
import net.minecraftforge.common.ForgeChunkManager
import net.minecraftforge.common.ForgeChunkManager.LoadingCallback
@ -30,7 +30,7 @@ object ChunkloaderUpgradeHandler extends LoadingCallback {
val z = data.getInteger("z")
OpenComputers.log.info(s"Restoring chunk loader ticket for upgrade at chunk ($x, $z) with address $address.")
ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(x, z))
ForgeChunkManager.forceChunk(ticket, new ChunkPos(x, z))
}
}
}
@ -68,12 +68,12 @@ object ChunkloaderUpgradeHandler extends LoadingCallback {
def updateLoadedChunk(loader: UpgradeChunkloader) {
val blockPos = BlockPosition(loader.host)
val centerChunk = new ChunkCoordIntPair(blockPos.x >> 4, blockPos.z >> 4)
val robotChunks = (for (x <- -1 to 1; z <- -1 to 1) yield new ChunkCoordIntPair(centerChunk.chunkXPos + x, centerChunk.chunkZPos + z)).toSet
val centerChunk = new ChunkPos(blockPos.x >> 4, blockPos.z >> 4)
val robotChunks = (for (x <- -1 to 1; z <- -1 to 1) yield new ChunkPos(centerChunk.chunkXPos + x, centerChunk.chunkZPos + z)).toSet
loader.ticket.foreach(ticket => {
ticket.getChunkList.collect {
case chunk: ChunkCoordIntPair if !robotChunks.contains(chunk) => ForgeChunkManager.unforceChunk(ticket, chunk)
case chunk: ChunkPos if !robotChunks.contains(chunk) => ForgeChunkManager.unforceChunk(ticket, chunk)
}
for (chunk <- robotChunks) {

View File

@ -37,7 +37,7 @@ class Wrench extends traits.SimpleItem with api.internal.Wrench {
override def onItemUseFirst(stack: ItemStack, player: EntityPlayer, world: World, pos: BlockPos, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float, hand: EnumHand): EnumActionResult = {
if (world.isBlockLoaded(pos) && world.isBlockModifiable(player, pos)) world.getBlockState(pos).getBlock match {
case block: Block if block.rotateBlock(world, pos, side) =>
block.onNeighborBlockChange(world, pos, world.getBlockState(pos), Blocks.AIR)
block.neighborChanged(world.getBlockState(pos), world, pos, Blocks.AIR)
player.swingArm(hand)
if (!world.isRemote) EnumActionResult.SUCCESS else EnumActionResult.PASS
case _ =>

View File

@ -8,7 +8,7 @@ import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.MCVersion
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin.TransformerExclusions
@TransformerExclusions(Array("li.cil.oc.common.asm"))
@MCVersion("1.9")
@MCVersion("1.9.4")
class TransformerLoader extends IFMLLoadingPlugin {
val instance = this

View File

@ -170,7 +170,7 @@ class ControllerImpl(val player: EntityPlayer) extends Controller with WirelessE
activeBehaviorsDirty = true
player match {
case playerMP: EntityPlayerMP if playerMP.playerNetServerHandler != null =>
case playerMP: EntityPlayerMP if playerMP.connection != null =>
player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("blindness"), 100))
player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("poison"), 150))
player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("slowness"), 200))

View File

@ -239,7 +239,7 @@ class Robot extends traits.Computer with traits.PowerInformation with traits.Rot
if (FluidRegistry.lookupFluidForBlock(block) == null &&
!block.isInstanceOf[BlockFluidBase] &&
!block.isInstanceOf[BlockLiquid]) {
world.playAuxSFX(2001, newPosition, Block.getIdFromBlock(block) + (metadata << 12))
world.playEvent(2001, newPosition, Block.getIdFromBlock(block) + (metadata << 12))
}
else {
val sx = newPosition.getX + 0.5

View File

@ -89,16 +89,22 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity with ITickable {
if (isServer) {
readFromNBTForServer(nbt)
}
}
override def writeToNBT(nbt: NBTTagCompound): Unit = {
if (isServer) {
writeToNBTForServer(nbt)
else if (world != null) {
readFromNBTForClient(nbt)
}
}
override def getDescriptionPacket = {
val nbt = new NBTTagCompound()
override def writeToNBT(nbt: NBTTagCompound): NBTTagCompound = {
if (isServer) {
writeToNBTForServer(nbt)
}
nbt
}
override def getUpdatePacket: SPacketUpdateTileEntity = new SPacketUpdateTileEntity(getPos, getBlockMetadata, getUpdateTag)
override def getUpdateTag: NBTTagCompound = {
val nbt = super.getUpdateTag
// See comment on savingForClients variable.
SaveHandler.savingForClients = true
@ -106,10 +112,11 @@ trait TileEntity extends net.minecraft.tileentity.TileEntity with ITickable {
try writeToNBTForClient(nbt) catch {
case e: Throwable => OpenComputers.log.warn("There was a problem writing a TileEntity description packet. Please report this if you see it!", e)
}
if (nbt.hasNoTags) null else new SPacketUpdateTileEntity(getPos, -1, nbt)
} finally {
SaveHandler.savingForClients = false
}
nbt
}
override def onDataPacket(manager: NetworkManager, packet: SPacketUpdateTileEntity) {

View File

@ -242,9 +242,10 @@ class PartCable extends Multipart with ISlottedPart with INormallyOccludingPart
// ----------------------------------------------------------------------- //
override def writeToNBT(tag: NBTTagCompound): Unit = {
override def writeToNBT(tag: NBTTagCompound): NBTTagCompound = {
super.writeToNBT(tag)
wrapped.writeToNBT(tag)
tag
}
override def readFromNBT(tag: NBTTagCompound): Unit = {

View File

@ -171,9 +171,10 @@ class PartPrint extends Multipart with INormallyOccludingPart with IRedstonePart
// ----------------------------------------------------------------------- //
override def writeToNBT(tag: NBTTagCompound): Unit = {
override def writeToNBT(tag: NBTTagCompound): NBTTagCompound = {
super.writeToNBT(tag)
wrapped.writeToNBT(tag)
tag
}
override def readFromNBT(tag: NBTTagCompound): Unit = {

View File

@ -43,7 +43,7 @@ object DriverRecordPlayer extends DriverSidedTileEntity {
def play(context: Context, args: Arguments): Array[AnyRef] = {
val record = tileEntity.getRecord
if (record != null && record.getItem.isInstanceOf[ItemRecord]) {
tileEntity.getWorld.playAuxSFXAtEntity(null, 1005, tileEntity.getPos, Item.getIdFromItem(record.getItem))
tileEntity.getWorld.playEvent(null, 1005, tileEntity.getPos, Item.getIdFromItem(record.getItem))
result(true)
}
else null
@ -51,7 +51,7 @@ object DriverRecordPlayer extends DriverSidedTileEntity {
@Callback(doc = "function() -- Stop playing the record currently in the jukebox.")
def stop(context: Context, args: Arguments): Array[AnyRef] = {
tileEntity.getWorld.playAuxSFX(1005, tileEntity.getPos, 0)
tileEntity.getWorld.playEvent(1005, tileEntity.getPos, 0)
tileEntity.getWorld.playRecord(tileEntity.getPos, null)
null
}

View File

@ -19,9 +19,8 @@ import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.IMerchant
import net.minecraft.entity.item.EntityItem
import net.minecraft.entity.passive.EntityHorse
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.EntityPlayer.EnumStatus
import net.minecraft.entity.player.EntityPlayer.SleepResult
import net.minecraft.init.Blocks
import net.minecraft.init.Items
import net.minecraft.inventory.IInventory
@ -90,7 +89,7 @@ object Player {
}
class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanceOf[WorldServer], Player.profileFor(agent)) {
playerNetServerHandler = new NetHandlerPlayServer(mcServer, FakeNetworkManager, this)
connection= new NetHandlerPlayServer(mcServer, FakeNetworkManager, this)
capabilities.allowFlying = true
capabilities.disableDamage = true
@ -341,7 +340,7 @@ class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanc
return 0
}
val strength = getBreakSpeed(state, pos)
val strength = getDigSpeed(state, pos)
val breakTime =
if (cobwebOverride) Settings.get.swingDelay
else hardness * 1.5 / strength
@ -379,7 +378,7 @@ class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanc
world.sendBlockBreakProgress(-1, pos, -1)
world.playAuxSFXAtEntity(this, 2001, pos, Block.getIdFromBlock(block) + (metadata << 12))
world.playEvent(this, 2001, pos, Block.getIdFromBlock(block) + (metadata << 12))
if (stack != null) {
stack.onBlockDestroyed(world, state, pos, this)
@ -555,7 +554,7 @@ class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanc
override def startRiding(entityIn: Entity, force: Boolean): Boolean = false
override def trySleep(bedLocation: BlockPos) = EnumStatus.OTHER_PROBLEM
override def trySleep(bedLocation: BlockPos) = SleepResult.OTHER_PROBLEM
override def addChatMessage(message: ITextComponent) {}

View File

@ -433,7 +433,7 @@ object DebugCard {
checkEnabled()
val blockPos = new BlockPos(args.checkInteger(0), args.checkInteger(1), args.checkInteger(2))
world.getTileEntity(blockPos) match {
case tileEntity: TileEntity => result(toNbt(tileEntity.writeToNBT _).toTypedMap)
case tileEntity: TileEntity => result(toNbt((nbt) => tileEntity.writeToNBT(nbt): Unit).toTypedMap)
case _ => null
}
}

View File

@ -53,7 +53,6 @@ abstract class UpgradeTractorBeam extends prefab.ManagedEnvironment {
@Callback(doc = """function():boolean -- Tries to pick up a random item in the robots' vicinity.""")
def suck(context: Context, args: Arguments): Array[AnyRef] = {
val items = world.getEntitiesWithinAABB(classOf[EntityItem], position.bounds.expand(pickupRadius, pickupRadius, pickupRadius))
.map(_.asInstanceOf[EntityItem])
.filter(item => item.isEntityAlive && !item.cannotPickup)
if (items.nonEmpty) {
val item = items(world.rand.nextInt(items.size))
@ -62,7 +61,7 @@ abstract class UpgradeTractorBeam extends prefab.ManagedEnvironment {
collectItem(item)
if (stack.stackSize < size || item.isDead) {
context.pause(Settings.get.suckDelay)
world.playAuxSFX(2003, new BlockPos(math.floor(item.posX).toInt, math.floor(item.posY).toInt, math.floor(item.posZ).toInt), 0)
world.playEvent(2003, new BlockPos(math.floor(item.posX).toInt, math.floor(item.posY).toInt, math.floor(item.posZ).toInt), 0)
return result(true)
}
}

View File

@ -67,7 +67,7 @@ object ExtendedWorld {
def notifyBlocksOfNeighborChange(position: BlockPosition, block: Block, side: EnumFacing) = world.notifyNeighborsOfStateExcept(position.toBlockPos, block, side)
def playAuxSFX(id: Int, position: BlockPosition, data: Int) = world.playAuxSFX(id, position.toBlockPos, data)
def playAuxSFX(id: Int, position: BlockPosition, data: Int) = world.playEvent(id, position.toBlockPos, data)
def setBlock(position: BlockPosition, block: Block) = world.setBlockState(position.toBlockPos, block.getDefaultState)