Added greater control over partChanged events

Made vanilla rs parts instances of IFaceRedstonePart
update CCL
This commit is contained in:
Chicken Bones committed 2013-08-22 01:08:29 +10:00
1 parent 4a810abe3f
commit 2e60e3f54f
5 files changed
+53 -11

No files matched your search

+30 -4
View File
@@ -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)
@@ -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];
}
}
@@ -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];
}
}
@@ -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];
}
}
+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.21"
"version": "1.0.0.22"
}