Adjustments for 1.8.

This commit is contained in:
Florian Nücke 2015-04-18 13:33:42 +02:00
parent 61f7a0c821
commit fba871697e
5 changed files with 26 additions and 20 deletions

View File

@ -19,6 +19,7 @@ import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.EnumDyeColor
import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.util.EnumFacing
import net.minecraft.util.EnumParticleTypes
import net.minecraft.util.Vec3
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@ -240,26 +241,26 @@ object PacketHandler extends CommonPacketHandler {
val z = p.readInt()
val velocity = p.readDouble()
val direction = p.readDirection()
val name = p.readUTF()
val particleType = EnumParticleTypes.getParticleFromId(p.readInt())
val count = p.readUnsignedByte()
for (i <- 0 until count) {
def rv(f: ForgeDirection => Int) = direction match {
def rv(f: EnumFacing => Int) = direction match {
case Some(d) => world.rand.nextFloat - 0.5 + f(d) * 0.5
case _ => world.rand.nextFloat * 2 - 1
}
val vx = rv(_.offsetX)
val vy = rv(_.offsetY)
val vz = rv(_.offsetZ)
val vx = rv(_.getFrontOffsetX)
val vy = rv(_.getFrontOffsetY)
val vz = rv(_.getFrontOffsetZ)
if (vx * vx + vy * vy + vz * vz < 1) {
def rp(x: Int, v: Double, f: ForgeDirection => Int) = direction match {
def rp(x: Int, v: Double, f: EnumFacing => Int) = direction match {
case Some(d) => x + 0.5 + v * velocity * 0.5 + f(d) * velocity
case _ => x + 0.5 + v * velocity
}
val px = rp(x, vx, _.offsetX)
val py = rp(y, vy, _.offsetY)
val pz = rp(z, vz, _.offsetZ)
world.spawnParticle(name, px, py, pz, vx, vy + velocity * 0.25, vz)
val px = rp(x, vx, _.getFrontOffsetX)
val py = rp(y, vy, _.getFrontOffsetY)
val pz = rp(z, vz, _.getFrontOffsetZ)
world.spawnParticle(particleType, px, py, pz, vx, vy + velocity * 0.25, vz)
}
}
case _ => // Invalid packet.

View File

@ -323,7 +323,7 @@ object EventHandler {
@SubscribeEvent
def onChunkUnload(e: ChunkEvent.Unload): Unit = {
if (!e.world.isRemote) {
e.getChunk.entityLists.foreach(_.collect {
e.getChunk.getEntityLists.foreach(_.collect {
case host: MachineHost => host.machine match {
case machine: Machine => scheduleClose(machine)
}

View File

@ -15,6 +15,7 @@ import net.minecraft.nbt.CompressedStreamTools
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.BlockPos
import net.minecraft.util.EnumFacing
import net.minecraft.util.EnumParticleTypes
import net.minecraft.world.World
import net.minecraftforge.common.MinecraftForge
@ -197,16 +198,16 @@ object PacketSender {
pb.sendToPlayersNearTileEntity(t)
}
def sendParticleEffect(position: BlockPosition, name: String, count: Int, velocity: Double, direction: Option[ForgeDirection] = None): Unit = if (count > 0) {
def sendParticleEffect(position: BlockPosition, particleType: EnumParticleTypes, count: Int, velocity: Double, direction: Option[EnumFacing] = None): Unit = if (count > 0) {
val pb = new SimplePacketBuilder(PacketType.ParticleEffect)
pb.writeInt(position.world.get.provider.dimensionId)
pb.writeInt(position.world.get.provider.getDimensionId)
pb.writeInt(position.x)
pb.writeInt(position.y)
pb.writeInt(position.z)
pb.writeDouble(velocity)
pb.writeDirection(direction)
pb.writeUTF(name)
pb.writeInt(particleType.getParticleID)
pb.writeByte(count.toByte)
pb.sendToNearbyPlayers(position.world.get, position.x, position.y, position.z, Some(32.0))

View File

@ -16,6 +16,7 @@ import li.cil.oc.util.ExtendedArguments._
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.util.EnumFacing
import net.minecraft.util.EnumParticleTypes
class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with Agent {
override val node = api.Network.newNode(this, Visibility.Network).
@ -75,7 +76,7 @@ class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with
val (something, what) = blockContent(direction)
if (something) {
context.pause(0.4)
PacketSender.sendParticleEffect(BlockPosition(agent), "crit", 8, 0.25, Some(direction))
PacketSender.sendParticleEffect(BlockPosition(agent), EnumParticleTypes.CRIT, 8, 0.25, Some(direction))
result(Unit, what)
}
else {
@ -89,7 +90,7 @@ class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with
else {
node.changeBuffer(Settings.get.robotMoveCost)
context.pause(0.4)
PacketSender.sendParticleEffect(BlockPosition(agent), "crit", 8, 0.25, Some(direction))
PacketSender.sendParticleEffect(BlockPosition(agent), EnumParticleTypes.CRIT, 8, 0.25, Some(direction))
result(Unit, "impossible move")
}
}

View File

@ -11,6 +11,7 @@ import li.cil.oc.api.machine.Callback
import li.cil.oc.api.machine.Context
import li.cil.oc.api.network._
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
import net.minecraft.nbt.NBTTagCompound
import scala.language.implicitConversions
@ -25,11 +26,13 @@ class WirelessNetworkCard(host: EnvironmentHost) extends NetworkCard(host) with
// ----------------------------------------------------------------------- //
override def x = BlockPosition(host).x
def position = BlockPosition(host)
override def y = BlockPosition(host).y
override def x = position.x
override def z = BlockPosition(host).z
override def y = position.y
override def z = position.z
override def world = host.world
@ -91,7 +94,7 @@ class WirelessNetworkCard(host: EnvironmentHost) extends NetworkCard(host) with
override def onDisconnect(node: Node) {
super.onDisconnect(node)
if (node == this.node || !world.blockExists(x, y, z)) {
if (node == this.node || !world.isBlockLoaded(position)) {
api.Network.leaveWirelessNetwork(this)
}
}