mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-26 23:13:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a36120fc91 | ||
|
|
238b041f12 |
No files matched your search
@@ -305,7 +305,10 @@ class BlockMultipart extends Block(Material.rock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override def getLightValue(world: IBlockAccess, x: Int, y: Int, z: Int): Int =
|
override def getLightValue(world: IBlockAccess, x: Int, y: Int, z: Int): Int =
|
||||||
world.getBlockMetadata(x, y, z)
|
getTile(world, x, y, z) match {
|
||||||
|
case null => 0
|
||||||
|
case tile => tile.getLightValue
|
||||||
|
}
|
||||||
|
|
||||||
override def randomDisplayTick(
|
override def randomDisplayTick(
|
||||||
world: World,
|
world: World,
|
||||||
|
|||||||
@@ -316,6 +316,12 @@ abstract class TMultiPart {
|
|||||||
*/
|
*/
|
||||||
def doesTick = true
|
def doesTick = true
|
||||||
|
|
||||||
|
/** Return whether this part needs to be included in the dynamic render loop
|
||||||
|
* (renderDynamic). Default is false. Override this to true for parts like
|
||||||
|
* lights that need per-frame rendering but no logic updates.
|
||||||
|
*/
|
||||||
|
def shouldRenderDynamic = false
|
||||||
|
|
||||||
/** Called once per world tick. This will be called even if doesTick returns
|
/** Called once per world tick. This will be called even if doesTick returns
|
||||||
* false if another part in the space needs ticks.
|
* false if another part in the space needs ticks.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
|
|
||||||
private var doesTick = false
|
private var doesTick = false
|
||||||
|
|
||||||
private var cachedLightValue: Int = 0
|
|
||||||
|
|
||||||
private[multipart] def from(that: TileMultipart) {
|
private[multipart] def from(that: TileMultipart) {
|
||||||
copyFrom(that)
|
copyFrom(that)
|
||||||
loadFrom(that)
|
loadFrom(that)
|
||||||
@@ -118,6 +116,7 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
|
|
||||||
override def validate() {
|
override def validate() {
|
||||||
super.validate()
|
super.validate()
|
||||||
|
|
||||||
if (worldObj != null && worldObj.isRemote)
|
if (worldObj != null && worldObj.isRemote)
|
||||||
TileCache.add(this)
|
TileCache.add(this)
|
||||||
}
|
}
|
||||||
@@ -170,25 +169,9 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
*/
|
*/
|
||||||
def getWeakChanges = false
|
def getWeakChanges = false
|
||||||
|
|
||||||
def getLightValue: Int = cachedLightValue
|
def getLightValue: Int = {
|
||||||
|
|
||||||
override def shouldRefresh(
|
|
||||||
oldBlock: Block,
|
|
||||||
newBlock: Block,
|
|
||||||
oldMeta: Int,
|
|
||||||
newMeta: Int,
|
|
||||||
world: World,
|
|
||||||
x: Int,
|
|
||||||
y: Int,
|
|
||||||
z: Int
|
|
||||||
): Boolean = {
|
|
||||||
oldBlock != newBlock
|
|
||||||
}
|
|
||||||
|
|
||||||
private def updateLight(): Unit = {
|
|
||||||
if (partList.isEmpty) {
|
if (partList.isEmpty) {
|
||||||
cachedLightValue = 0
|
return 0
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var max = 0
|
var max = 0
|
||||||
@@ -197,23 +180,8 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
val l = it.next().getLightValue
|
val l = it.next().getLightValue
|
||||||
if (l > max) max = l
|
if (l > max) max = l
|
||||||
}
|
}
|
||||||
cachedLightValue = max
|
|
||||||
|
|
||||||
if (
|
max
|
||||||
worldObj != null && worldObj.getBlockMetadata(
|
|
||||||
xCoord,
|
|
||||||
yCoord,
|
|
||||||
zCoord
|
|
||||||
) != cachedLightValue
|
|
||||||
) {
|
|
||||||
worldObj.setBlockMetadataWithNotify(
|
|
||||||
xCoord,
|
|
||||||
yCoord,
|
|
||||||
zCoord,
|
|
||||||
cachedLightValue,
|
|
||||||
3
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def getExplosionResistance(entity: Entity) =
|
def getExplosionResistance(entity: Entity) =
|
||||||
@@ -336,10 +304,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
bindPart(part)
|
bindPart(part)
|
||||||
part.bind(this)
|
part.bind(this)
|
||||||
|
|
||||||
if (part.getLightValue > cachedLightValue) {
|
|
||||||
cachedLightValue = part.getLightValue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doesTick && part.doesTick)
|
if (!doesTick && part.doesTick)
|
||||||
setTicking(true)
|
setTicking(true)
|
||||||
}
|
}
|
||||||
@@ -394,10 +358,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
part.onRemoved()
|
part.onRemoved()
|
||||||
part.tile = null
|
part.tile = null
|
||||||
|
|
||||||
if (removedLightValue == cachedLightValue && removedLightValue > 0) {
|
|
||||||
updateLight()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partList.isEmpty) {
|
if (partList.isEmpty) {
|
||||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord)
|
worldObj.setBlockToAir(xCoord, yCoord, zCoord)
|
||||||
} else {
|
} else {
|
||||||
@@ -420,8 +380,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
clearParts()
|
clearParts()
|
||||||
parts.foreach(p => addPart_do(p))
|
parts.foreach(p => addPart_do(p))
|
||||||
|
|
||||||
updateLight()
|
|
||||||
|
|
||||||
if (worldObj != null) {
|
if (worldObj != null) {
|
||||||
if (worldObj.isRemote)
|
if (worldObj.isRemote)
|
||||||
operate(_.onWorldJoin())
|
operate(_.onWorldJoin())
|
||||||
@@ -434,7 +392,6 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
*/
|
*/
|
||||||
def clearParts() {
|
def clearParts() {
|
||||||
partList = Seq()
|
partList = Seq()
|
||||||
cachedLightValue = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the description of this tile, and all parts composing it, to packet
|
/** Writes the description of this tile, and all parts composing it, to packet
|
||||||
@@ -523,7 +480,8 @@ trait TileMultipartClient extends TileMultipart {
|
|||||||
|
|
||||||
def updateRenderCache() {
|
def updateRenderCache() {
|
||||||
if (partList != null) {
|
if (partList != null) {
|
||||||
val (dynamic, static) = partList.partition(_.doesTick)
|
val (dynamic, static) =
|
||||||
|
partList.partition(p => p.doesTick || p.shouldRenderDynamic)
|
||||||
val sArr = static.toArray
|
val sArr = static.toArray
|
||||||
val dArr = dynamic.toArray
|
val dArr = dynamic.toArray
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user