mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
Adjustments for 1.8.
This commit is contained in:
parent
61f7a0c821
commit
fba871697e
@ -19,6 +19,7 @@ import net.minecraft.entity.player.EntityPlayer
|
|||||||
import net.minecraft.item.EnumDyeColor
|
import net.minecraft.item.EnumDyeColor
|
||||||
import net.minecraft.nbt.CompressedStreamTools
|
import net.minecraft.nbt.CompressedStreamTools
|
||||||
import net.minecraft.util.EnumFacing
|
import net.minecraft.util.EnumFacing
|
||||||
|
import net.minecraft.util.EnumParticleTypes
|
||||||
import net.minecraft.util.Vec3
|
import net.minecraft.util.Vec3
|
||||||
import net.minecraftforge.common.MinecraftForge
|
import net.minecraftforge.common.MinecraftForge
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
|
||||||
@ -240,26 +241,26 @@ object PacketHandler extends CommonPacketHandler {
|
|||||||
val z = p.readInt()
|
val z = p.readInt()
|
||||||
val velocity = p.readDouble()
|
val velocity = p.readDouble()
|
||||||
val direction = p.readDirection()
|
val direction = p.readDirection()
|
||||||
val name = p.readUTF()
|
val particleType = EnumParticleTypes.getParticleFromId(p.readInt())
|
||||||
val count = p.readUnsignedByte()
|
val count = p.readUnsignedByte()
|
||||||
|
|
||||||
for (i <- 0 until count) {
|
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 Some(d) => world.rand.nextFloat - 0.5 + f(d) * 0.5
|
||||||
case _ => world.rand.nextFloat * 2 - 1
|
case _ => world.rand.nextFloat * 2 - 1
|
||||||
}
|
}
|
||||||
val vx = rv(_.offsetX)
|
val vx = rv(_.getFrontOffsetX)
|
||||||
val vy = rv(_.offsetY)
|
val vy = rv(_.getFrontOffsetY)
|
||||||
val vz = rv(_.offsetZ)
|
val vz = rv(_.getFrontOffsetZ)
|
||||||
if (vx * vx + vy * vy + vz * vz < 1) {
|
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 Some(d) => x + 0.5 + v * velocity * 0.5 + f(d) * velocity
|
||||||
case _ => x + 0.5 + v * velocity
|
case _ => x + 0.5 + v * velocity
|
||||||
}
|
}
|
||||||
val px = rp(x, vx, _.offsetX)
|
val px = rp(x, vx, _.getFrontOffsetX)
|
||||||
val py = rp(y, vy, _.offsetY)
|
val py = rp(y, vy, _.getFrontOffsetY)
|
||||||
val pz = rp(z, vz, _.offsetZ)
|
val pz = rp(z, vz, _.getFrontOffsetZ)
|
||||||
world.spawnParticle(name, px, py, pz, vx, vy + velocity * 0.25, vz)
|
world.spawnParticle(particleType, px, py, pz, vx, vy + velocity * 0.25, vz)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case _ => // Invalid packet.
|
case _ => // Invalid packet.
|
||||||
|
@ -323,7 +323,7 @@ object EventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def onChunkUnload(e: ChunkEvent.Unload): Unit = {
|
def onChunkUnload(e: ChunkEvent.Unload): Unit = {
|
||||||
if (!e.world.isRemote) {
|
if (!e.world.isRemote) {
|
||||||
e.getChunk.entityLists.foreach(_.collect {
|
e.getChunk.getEntityLists.foreach(_.collect {
|
||||||
case host: MachineHost => host.machine match {
|
case host: MachineHost => host.machine match {
|
||||||
case machine: Machine => scheduleClose(machine)
|
case machine: Machine => scheduleClose(machine)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import net.minecraft.nbt.CompressedStreamTools
|
|||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraft.util.BlockPos
|
import net.minecraft.util.BlockPos
|
||||||
import net.minecraft.util.EnumFacing
|
import net.minecraft.util.EnumFacing
|
||||||
|
import net.minecraft.util.EnumParticleTypes
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
import net.minecraftforge.common.MinecraftForge
|
import net.minecraftforge.common.MinecraftForge
|
||||||
|
|
||||||
@ -197,16 +198,16 @@ object PacketSender {
|
|||||||
pb.sendToPlayersNearTileEntity(t)
|
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)
|
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.x)
|
||||||
pb.writeInt(position.y)
|
pb.writeInt(position.y)
|
||||||
pb.writeInt(position.z)
|
pb.writeInt(position.z)
|
||||||
pb.writeDouble(velocity)
|
pb.writeDouble(velocity)
|
||||||
pb.writeDirection(direction)
|
pb.writeDirection(direction)
|
||||||
pb.writeUTF(name)
|
pb.writeInt(particleType.getParticleID)
|
||||||
pb.writeByte(count.toByte)
|
pb.writeByte(count.toByte)
|
||||||
|
|
||||||
pb.sendToNearbyPlayers(position.world.get, position.x, position.y, position.z, Some(32.0))
|
pb.sendToNearbyPlayers(position.world.get, position.x, position.y, position.z, Some(32.0))
|
||||||
|
@ -16,6 +16,7 @@ import li.cil.oc.util.ExtendedArguments._
|
|||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraft.util.EnumFacing
|
import net.minecraft.util.EnumFacing
|
||||||
|
import net.minecraft.util.EnumParticleTypes
|
||||||
|
|
||||||
class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with Agent {
|
class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with Agent {
|
||||||
override val node = api.Network.newNode(this, Visibility.Network).
|
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)
|
val (something, what) = blockContent(direction)
|
||||||
if (something) {
|
if (something) {
|
||||||
context.pause(0.4)
|
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)
|
result(Unit, what)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -89,7 +90,7 @@ class Robot(val agent: tileentity.Robot) extends prefab.ManagedEnvironment with
|
|||||||
else {
|
else {
|
||||||
node.changeBuffer(Settings.get.robotMoveCost)
|
node.changeBuffer(Settings.get.robotMoveCost)
|
||||||
context.pause(0.4)
|
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")
|
result(Unit, "impossible move")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import li.cil.oc.api.machine.Callback
|
|||||||
import li.cil.oc.api.machine.Context
|
import li.cil.oc.api.machine.Context
|
||||||
import li.cil.oc.api.network._
|
import li.cil.oc.api.network._
|
||||||
import li.cil.oc.util.BlockPosition
|
import li.cil.oc.util.BlockPosition
|
||||||
|
import li.cil.oc.util.ExtendedWorld._
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
|
|
||||||
import scala.language.implicitConversions
|
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
|
override def world = host.world
|
||||||
|
|
||||||
@ -91,7 +94,7 @@ class WirelessNetworkCard(host: EnvironmentHost) extends NetworkCard(host) with
|
|||||||
|
|
||||||
override def onDisconnect(node: Node) {
|
override def onDisconnect(node: Node) {
|
||||||
super.onDisconnect(node)
|
super.onDisconnect(node)
|
||||||
if (node == this.node || !world.blockExists(x, y, z)) {
|
if (node == this.node || !world.isBlockLoaded(position)) {
|
||||||
api.Network.leaveWirelessNetwork(this)
|
api.Network.leaveWirelessNetwork(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user