Fixed entities falling through frames during movement

Fix crash when registering certain modnames in the configs
This commit is contained in:
MrTJP committed 2015-07-30 12:29:22 -04:00
1 parent a7570f0bf8
commit 8ece61b4eb
8 files changed
+72 -30

No files matched your search

+1 -1
View File
@@ -25,7 +25,7 @@ repositories {
maven {
name "mvnmrtjp"
url "http://projectredwiki.com/maven"
url "http://files.projectredwiki.com/maven"
}
}
+1 -1
View File
@@ -3,5 +3,5 @@ mod.version=0.0.1
mc.version=1.7.10
forge.version=10.13.3.1399-1.7.10
mrtjp.version=1.1.0.26
mrtjp.version=1.1.0.31
ccl.version=1.1.3.136
+4
View File
@@ -1,3 +1,7 @@
v0.0.1.4
- FIX: Entities falling through frames during movement
- FIX: Crash when configs try to register mod names with certain characters
v0.0.1.3
- FIX: Frame render crash when all 6 sides have no crosses
+1 -1
View File
@@ -1,5 +1,5 @@
[{
"repo": "http://projectredwiki.com/maven/mrtjp/MrTJPCore/@MC_VERSION@-@MRTJP_VERSION@/",
"repo": "http://files.projectredwiki.com/maven/mrtjp/MrTJPCore/@MC_VERSION@-@MRTJP_VERSION@/",
"file": "MrTJPCore-@MC_VERSION@-@MRTJP_VERSION@-universal.jar",
"dev": "MrTJPCore-@MC_VERSION@-@MRTJP_VERSION@-dev.jar",
"class": "mrtjp.core.handler.MrTJPCoreMod"
+14 -17
View File
@@ -51,10 +51,11 @@ object TileMovingRow
class TileMovingRow extends InstancedBlockTile
{
var prevProg = 0.0
override def update()
{
if (!MovementManager2.isMoving(world, x, y, z)) world.setBlockToAir(x, y, z)
else pushEntities()
}
override def getBlock = RelocationMod.blockMovingRow
@@ -72,24 +73,20 @@ class TileMovingRow extends InstancedBlockTile
override def getCollisionBounds = getBlockBounds
def pushEntities()
def pushEntities(r:BlockRow, progress:Double)
{
val s = MovementManager2.getEnclosedStructure(world, x, y, z)
if (s != null)
val box = Cuboid6.full.copy.add(new Vector3(r.preMoveBlocks.head))
.add(new Vector3(BlockCoord.sideOffsets(r.moveDir)).multiply(progress)).toAABB
val dp = (if (progress >= 1.0) progress+0.1 else progress)-prevProg
val d = new Vector3(BlockCoord.sideOffsets(r.moveDir))*dp
world.getEntitiesWithinAABBExcludingEntity(null, box) match
{
val r = s.rows.find(_.contains(x, y, z)).get
val box = TileMovingRow.getBoxFor(world, r, s.progress).add(new Vector3(r.pos))
val d = new Vector3(BlockCoord.sideOffsets(r.moveDir))*s.speed
world.getEntitiesWithinAABBExcludingEntity(null, box.toAABB) match
{
case list:JList[_] => for (e <- list.asInstanceOf[JList[Entity]])
{
e.moveEntity(0, d.y max 0, 0)
e.addVelocity(d.x, d.y, d.z)
e.velocityChanged = true
}
case _ =>
}
case list:JList[_] =>
for (e <- list.asInstanceOf[JList[Entity]]) e.moveEntity(d.x, d.y max 0, d.z)
case _ =>
}
prevProg = progress
}
}
@@ -36,6 +36,15 @@ class RelocationProxy_server
API.registerPreferredMover("mod:EnderStorage", "coordpush")
API.registerPreferredMover("mod:ChickenChunks", "coordpush")
API.registerPreferredMover("mod:Translocator", "coordpush")
API.registerPreferredMover("mod:ProjRed|Compatibility", "coordpush")
API.registerPreferredMover("mod:ProjRed|Core", "coordpush")
API.registerPreferredMover("mod:ProjRed|Expansion", "coordpush")
API.registerPreferredMover("mod:ProjRed|Exploration", "coordpush")
API.registerPreferredMover("mod:ProjRed|Fabrication", "coordpush")
API.registerPreferredMover("mod:ProjRed|Illumination", "coordpush")
API.registerPreferredMover("mod:ProjRed|Integration", "coordpush")
API.registerPreferredMover("mod:ProjRed|Transmission", "coordpush")
API.registerPreferredMover("mod:ProjRed|Transportation", "coordpush")
}
def init()
+38 -6
View File
@@ -8,10 +8,12 @@ package mrtjp.relocation
import codechicken.lib.data.{MCDataInput, MCDataOutput}
import codechicken.lib.packet.PacketCustom
import codechicken.lib.vec.BlockCoord
import cpw.mods.fml.relauncher.{Side, SideOnly}
import mrtjp.core.math.MathLib
import mrtjp.core.world.WorldLib
import mrtjp.relocation.api.{IMovementCallback, IMovementDescriptor}
import mrtjp.relocation.handler.{RelocationConfig, RelocationSPH}
import net.minecraft.client.Minecraft
import net.minecraft.init.Blocks
import net.minecraft.world.{ChunkCoordIntPair, World}
import net.minecraftforge.common.DimensionManager
@@ -24,11 +26,22 @@ object MovementManager2
val serverRelocations = MHashMap[Int, WorldStructs]()
val clientRelocations = MHashMap[Int, WorldStructs]()
def relocationMap(client:Boolean) = if (client) clientRelocations else serverRelocations
def relocationMap(isClient:Boolean) = if (isClient) clientRelocations else serverRelocations
def getWorldStructs(w:World) =
relocationMap(w.isRemote).getOrElseUpdate(w.provider.dimensionId, new WorldStructs)
def getWorld(dim:Int, isClient:Boolean) =
if (!isClient) DimensionManager.getWorld(dim)
else getClientWorld(dim)
@SideOnly(Side.CLIENT)
private def getClientWorld(dim:Int):World =
{
val w = Minecraft.getMinecraft.theWorld
if (w.provider.dimensionId == dim) w else null
}
def writeDesc(w:World, chunks:Set[ChunkCoordIntPair], out:MCDataOutput) =
{
var send = false
@@ -135,16 +148,23 @@ object MovementManager2
true
}
def onTick(client:Boolean)
def onTick(isClient:Boolean)
{
val map = relocationMap(client)
map.values.foreach(_.pushAll())
if (!client)
val map = relocationMap(isClient)
for ((dim, ws) <- map) if (ws.nonEmpty)
{
ws.pushAll()
val world = getWorld(dim, isClient)
if (world != null) for (bs <- ws.structs) for (br <- bs.rows)
br.pushEntities(world, bs.progress)
}
if (!isClient)
{
val fin = map.map(pair => (pair._1, pair._2.removeFinished())).filter(_._2.nonEmpty)
for ((dim, b) <- fin)
{
val w = DimensionManager.getWorld(dim)
val w = getWorld(dim, false)
if (w != null) for (s <- b)
{
cycleMove(w, s)
@@ -162,6 +182,7 @@ object MovementManager2
def clientCycleMove(w:World, struct:BlockStruct)
{
getWorldStructs(w).removeStruct(struct)
struct.rows.foreach(_.pushEntities(w, 1.0))
cycleMove(w, struct)
}
@@ -187,6 +208,8 @@ class WorldStructs
def isEmpty = structs.isEmpty
def nonEmpty = !isEmpty
def contains(x:Int, y:Int, z:Int) = structs.exists(_.contains(x, y, z))
def addStruct(b:BlockStruct){ structs += b }
@@ -355,6 +378,15 @@ class BlockRow(val pos:BlockCoord, val moveDir:Int, val size:Int)
else false
}
def pushEntities(w:World, progress:Double)
{
WorldLib.uncheckedGetTileEntity(w, pos.x, pos.y, pos.z) match
{
case te:TileMovingRow => te.pushEntities(this, progress)
case _ =>
}
}
def doMove(w:World)
{
if (pos.y < 0 || pos.y >= 256) return
+4 -4
View File
@@ -22,10 +22,10 @@ import scala.collection.immutable.ListMap
object MovingTileRegistry extends ITileMover
{
val rKeyVal = raw"([\w:]+)\s*->\s*(.+)".r
val rName = raw"(.+)".r
val rNameMetaM = raw"(.+)m(\d+)".r
val rMod = raw"mod:(\w+)".r
val rKeyVal = raw"([^\s]+.+[^\s]+)\s*->\s*([^\s]+.+[^\s]+)".r
val rName = raw"([^\s]+.+[^\s]+)".r
val rNameMetaM = raw"([^\s]+.+[^\s]+)m(\d+)".r
val rMod = raw"mod:([^\s]+.+[^\s]+)".r
var blockMetaMap = Map[(Block, Int), ITileMover]()
var modMap = Map[String, ITileMover]()