Modified partChange event to take a parameter of the part that was changed and only send the event to other parts.

Update CCL dep
This commit is contained in:
Chicken Bones committed 2013-08-12 13:35:12 +10:00
1 parent 2291c3dd09
commit 37a3d89382
14 files changed
+65 -24

No files matched your search

@@ -154,7 +154,7 @@ abstract class Microblock(var shape:Byte = 0, var material:Int = 0) extends TCub
override def read(packet:MCDataInput)
{
readDesc(packet)
tile.notifyPartChange()
tile.notifyPartChange(this)
tile.markRender()
}
+1 -1
View File
@@ -179,7 +179,7 @@ class PostMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends PostMicro
renderCuboid(pos, olm, mat, renderBounds2, 0)
}
override def onPartChanged()
override def onPartChanged(part:TMultiPart)
{
if(tile.worldObj.isRemote)
recalcBounds()
+3 -2
View File
@@ -20,6 +20,7 @@ import Rotation._
import Vector3._
import codechicken.lib.raytracer.IndexedCuboid6
import org.lwjgl.opengl.GL11
import codechicken.multipart.TMultiPart
object HollowPlacement extends PlacementProperties
{
@@ -83,9 +84,9 @@ class HollowMicroblockClient(shape$:Byte = 0, material$:Int = 0) extends HollowM
def this(size:Int, shape:Int, material:Int) = this((size<<4|shape).toByte, material)
override def onPartChanged()
override def onPartChanged(part:TMultiPart)
{
super.onPartChanged()
super.onPartChanged(part)
renderMask = renderMask&0xFF | getHollowSize<<8
}
@@ -38,7 +38,7 @@ class ExpandingPlacement($pos:BlockCoord, $part:Microblock, opart:Microblock) ex
def place(world:World, player:EntityPlayer, item:ItemStack)
{
opart.shape = part.shape
opart.tile.notifyPartChange()
opart.tile.notifyPartChange(opart)
opart.sendDescUpdate()
}
+14 -5
View File
@@ -166,16 +166,25 @@ trait JMicroShrinkRender
trait TMicroOcclusionClient extends TMicroOcclusion with JMicroShrinkRender
{
import MicroOcclusion._
var renderBounds:Cuboid6 = _
var renderMask:Int = _
override def onPartChanged()
override def onPartChanged(part:TMultiPart)
{
super.onPartChanged(part)
recalcBounds()
}
override def onAdded()
{
super.onAdded()
recalcBounds()
}
def recalcBounds()
{
super.onPartChanged()
renderBounds = getBounds.copy
renderMask = recalcBounds(this, renderBounds)
renderMask = MicroOcclusion.recalcBounds(this, renderBounds)
}
override def getPriorityClass = 0
@@ -136,10 +136,14 @@ object RedstoneInteractions
def vanillaConnectionMask(block:Block, world:IBlockAccess, x:Int, y:Int, z:Int, side:Int, power:Boolean):Int =
{
if(block == Block.torchRedstoneActive || block == Block.torchRedstoneIdle || block == Block.lever || block == Block.stoneButton || block == Block.woodenButton)
return 0x1F
if(side == 0)//vanilla doesn't handle side 0
{
if(power)
return 0x1F
return 0
}
@@ -64,11 +64,12 @@ object MultipartGenerator
{
if(loaded._2)//perform client conversion
{
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block.blockID, 0, 1)
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block.blockID, 0, 0)
world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile)
PacketCustom.sendToChunk(new Packet53BlockChange(pos.x, pos.y, pos.z, world), world, pos.x>>4, pos.z>>4)
ntile.partList(0).onConverted()
ntile.writeAddPart(ntile.partList(0))
world.notifyBlocksOfNeighborChange(pos.x, pos.y, pos.z, MultipartProxy.block.blockID)
}
val tileTraits = tileTraitMap(tile.getClass)
@@ -82,9 +83,10 @@ object MultipartGenerator
}
else
{
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block.blockID)
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block.blockID, 0, 0)
ntile = factory.generateTile(partTraits, world.isRemote)
world.setBlockTileEntity(pos.x, pos.y, pos.z, ntile)
world.notifyBlocksOfNeighborChange(pos.x, pos.y, pos.z, MultipartProxy.block.blockID)
}
ntile.addPart_impl(part)
return ntile
+4 -1
View File
@@ -72,7 +72,10 @@ abstract class TMultiPart
def save(tag:NBTTagCompound){}
def load(tag:NBTTagCompound){}
def onPartChanged(){}
/**
* The part parameter may be null if several things have changed.
*/
def onPartChanged(part:TMultiPart){}
def onNeighborChanged(){}
def onAdded() = onWorldJoin()
def onRemoved() = onWorldSeparate()
+9 -6
View File
@@ -113,10 +113,13 @@ class TileMultipart extends TileEntity
partList.foreach(_.onWorldSeparate())
}
def notifyPartChange()
def notifyPartChange(part:TMultiPart)
{
TileMultipart.startOperation(this)
partList.foreach(_.onPartChanged())
partList.foreach{ p =>
if(part != p)
p.onPartChanged(part)
}
TileMultipart.finishOperation(this)
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID)
@@ -185,7 +188,7 @@ class TileMultipart extends TileEntity
def getWriteStream(part:TMultiPart):MCDataOutput = getWriteStream.writeByte(partList.indexOf(part))
private[multipart] def getWriteStream = MultipartSPH.getTileStream(worldObj, new BlockCoord(this))
private def getWriteStream = MultipartSPH.getTileStream(worldObj, new BlockCoord(this))
private[multipart] def addPart_impl(part:TMultiPart)
{
@@ -195,7 +198,7 @@ class TileMultipart extends TileEntity
addPart_do(part)
part.onAdded()
partAdded(part)
notifyPartChange()
notifyPartChange(part)
markDirty()
markRender()
}
@@ -241,7 +244,7 @@ class TileMultipart extends TileEntity
val i = remPart_do(part)
if(!isInvalid())
{
notifyPartChange()
notifyPartChange(part)
markDirty()
markRender()
}
@@ -291,7 +294,7 @@ class TileMultipart extends TileEntity
clearParts()
parts.foreach(p => addPart_do(p))
if(worldObj != null)
notifyPartChange()
notifyPartChange(null)
}
def clearParts()
@@ -134,7 +134,7 @@ public class ButtonPart extends McSidedMetaPart implements IRedstonePart
TickScheduler.scheduleTick(this, delay());
sendDescUpdate();
tile().notifyPartChange();
tile().notifyPartChange(this);
tile().notifyNeighborChange(metaSideMap[meta&7]);
tile().markDirty();
}
@@ -97,7 +97,7 @@ public class LeverPart extends McSidedMetaPart implements IRedstonePart
world.playSoundEffect(x() + 0.5, y() + 0.5, z() + 0.5, "random.click", 0.3F, !active() ? 0.6F : 0.5F);
meta ^= 8;
sendDescUpdate();
tile().notifyPartChange();
tile().notifyPartChange(this);
tile().notifyNeighborChange(metaSideMap[meta&7]);
tile().markDirty();
return true;
@@ -4,9 +4,10 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeDirection;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.TFacePart;
import codechicken.multipart.TileMultipart;
public abstract class McSidedMetaPart extends McMetaPart
public abstract class McSidedMetaPart extends McMetaPart implements TFacePart
{
public McSidedMetaPart()
{
@@ -47,4 +48,22 @@ public abstract class McSidedMetaPart extends McMetaPart
tile().remPart(this);
TileMultipart.dropItem(new ItemStack(getBlock()), world(), Vector3.fromTileEntityCenter(getTile()));
}
@Override
public int getSlotMask()
{
return 1<<sideForMeta(meta);
}
@Override
public boolean solid(int side)
{
return false;
}
@Override
public int redstoneConductionMap()
{
return 0;
}
}
@@ -195,7 +195,7 @@ public class RedstoneTorchPart extends TorchPart implements IRedstonePart, IRand
meta ^= 0x10;
sendDescUpdate();
tile().markDirty();
tile().notifyPartChange();
tile().notifyPartChange(this);
tile().notifyNeighborChange(1);
}
+1 -1
View File
@@ -3,5 +3,5 @@
"file": "CodeChickenLib-universal-@MCVERSION@-@[email protected]",
"dev": "CodeChickenLib-dev-@MCVERSION@-@[email protected]",
"class": "codechicken.lib.asm.ASMHelper",
"version": "1.0.0.19"
"version": "1.0.0.20"
}