diff --git a/codechicken/multipart/TileMultipart.scala b/codechicken/multipart/TileMultipart.scala index 055b6fa..ae784da 100644 --- a/codechicken/multipart/TileMultipart.scala +++ b/codechicken/multipart/TileMultipart.scala @@ -38,6 +38,7 @@ import net.minecraft.entity.item.EntityItem import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.Entity import scala.collection.JavaConversions._ +import java.util.Collection class TileMultipart extends TileEntity { @@ -77,7 +78,7 @@ class TileMultipart extends TileEntity def jPartList():List[TMultiPart] = partList - override def canUpdate() = doesTick//TODO: part merging true + override def canUpdate() = doesTick override def updateEntity() { @@ -113,7 +114,22 @@ class TileMultipart extends TileEntity partList.foreach(_.onWorldSeparate()) } + /** + * Called by parts when they have changed in some form that affects the world. + * Notifies neighbor blocks, parts that share this host and recalculates lighting + */ def notifyPartChange(part:TMultiPart) + { + internalPartChange(part) + + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID) + worldObj.updateAllLightTypes(xCoord, yCoord, zCoord) + } + + /** + * Notifies parts sharing this host of a change + */ + def internalPartChange(part:TMultiPart) { TileMultipart.startOperation(this) partList.foreach{ p => @@ -121,9 +137,19 @@ class TileMultipart extends TileEntity p.onPartChanged(part) } TileMultipart.finishOperation(this) - - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID) - worldObj.updateAllLightTypes(xCoord, yCoord, zCoord) + } + + /** + * Notifies all parts not in the passed collection of a change from all the parts in the collection + */ + def multiPartChange(parts:Collection[TMultiPart]) + { + TileMultipart.startOperation(this) + partList.foreach{ p => + if(!parts.contains(p)) + parts.foreach(p.onPartChanged(_)) + } + TileMultipart.finishOperation(this) } def onNeighborBlockChange(world:World, x:Int, y:Int, z:Int, id:Int) diff --git a/codechicken/multipart/minecraft/ButtonPart.java b/codechicken/multipart/minecraft/ButtonPart.java index 2ec0eb7..ce45a83 100644 --- a/codechicken/multipart/minecraft/ButtonPart.java +++ b/codechicken/multipart/minecraft/ButtonPart.java @@ -3,7 +3,7 @@ package codechicken.multipart.minecraft; import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.Cuboid6; import codechicken.lib.vec.Vector3; -import codechicken.multipart.IRedstonePart; +import codechicken.multipart.IFaceRedstonePart; import codechicken.multipart.TickScheduler; import net.minecraft.block.Block; import net.minecraft.block.BlockButton; @@ -15,7 +15,7 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; -public class ButtonPart extends McSidedMetaPart implements IRedstonePart +public class ButtonPart extends McSidedMetaPart implements IFaceRedstonePart { public static BlockButton stoneButton = (BlockButton) Block.stoneButton; public static BlockButton woodenButton = (BlockButton) Block.woodenButton; @@ -181,4 +181,9 @@ public class ButtonPart extends McSidedMetaPart implements IRedstonePart { return 0x10; } + + @Override + public int getFace() { + return metaSideMap[meta&7]; + } } diff --git a/codechicken/multipart/minecraft/LeverPart.java b/codechicken/multipart/minecraft/LeverPart.java index e99c812..438c2c6 100644 --- a/codechicken/multipart/minecraft/LeverPart.java +++ b/codechicken/multipart/minecraft/LeverPart.java @@ -11,9 +11,9 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.Cuboid6; -import codechicken.multipart.IRedstonePart; +import codechicken.multipart.IFaceRedstonePart; -public class LeverPart extends McSidedMetaPart implements IRedstonePart +public class LeverPart extends McSidedMetaPart implements IFaceRedstonePart { public static BlockLever lever = (BlockLever) Block.lever; public static int[] metaSideMap = new int[]{1, 4, 5, 2, 3, 0, 0, 1}; @@ -149,4 +149,9 @@ public class LeverPart extends McSidedMetaPart implements IRedstonePart { return 0x10; } + + @Override + public int getFace() { + return metaSideMap[meta&7]; + } } diff --git a/codechicken/multipart/minecraft/RedstoneTorchPart.java b/codechicken/multipart/minecraft/RedstoneTorchPart.java index e565451..00e1919 100644 --- a/codechicken/multipart/minecraft/RedstoneTorchPart.java +++ b/codechicken/multipart/minecraft/RedstoneTorchPart.java @@ -10,11 +10,12 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeDirection; import codechicken.lib.vec.BlockCoord; import codechicken.lib.vec.Cuboid6; +import codechicken.multipart.IFaceRedstonePart; import codechicken.multipart.IRandomUpdateTick; -import codechicken.multipart.IRedstonePart; import codechicken.multipart.RedstoneInteractions; +import codechicken.multipart.TFacePart; -public class RedstoneTorchPart extends TorchPart implements IRedstonePart, IRandomUpdateTick +public class RedstoneTorchPart extends TorchPart implements IFaceRedstonePart, IRandomUpdateTick { public static BlockRedstoneTorch torchActive = (BlockRedstoneTorch) Block.torchRedstoneActive; public static BlockRedstoneTorch torchIdle = (BlockRedstoneTorch) Block.torchRedstoneIdle; @@ -231,4 +232,9 @@ public class RedstoneTorchPart extends TorchPart implements IRedstonePart, IRand { return true; } + + @Override + public int getFace() { + return metaSideMap[meta*7]; + } } diff --git a/dependancies.info b/dependancies.info index 5dab9d3..e6583e4 100644 --- a/dependancies.info +++ b/dependancies.info @@ -3,5 +3,5 @@ "file": "CodeChickenLib-universal-@MCVERSION@-@VERSION@.jar", "dev": "CodeChickenLib-dev-@MCVERSION@-@VERSION@.jar", "class": "codechicken.lib.asm.ASMHelper", - "version": "1.0.0.21" + "version": "1.0.0.22" } \ No newline at end of file