本文整理汇总了C#中Chraft.World.Blocks.StructBlock类的典型用法代码示例。如果您正苦于以下问题:C# StructBlock类的具体用法?C# StructBlock怎么用?C# StructBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StructBlock类属于Chraft.World.Blocks命名空间,在下文中一共展示了StructBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
// Load the blocks surrounding the position (NSEW) not diagonals
BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
int nsewCount = 0;
block.Chunk.ForNSEW(block.Coords, (uc) =>
{
nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
nsewBlockPositions[nsewCount] = uc;
nsewCount++;
});
// Count chests in list
if (nsewBlocks.Where((b) => b == BlockData.Blocks.Chest).Count() > 1)
{
// Cannot place next to two chests
return;
}
for (int i = 0; i < 4; i++)
{
UniversalCoords p = nsewBlockPositions[i];
if (nsewBlocks[i] == BlockData.Blocks.Chest && block.Chunk.IsNSEWTo(p, (byte)BlockData.Blocks.Chest))
{
// Cannot place next to a double chest
return;
}
}
base.Place(entity, block, targetBlock, face);
}
示例2: CanGrow
public bool CanGrow(StructBlock block)
{
// Crops grow from 0x0 to 0x7
if (block.MetaData == 0x07)
return false;
return true;
}
示例3: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
Player player = (entity as Player);
if (player == null)
return;
if (face == BlockFace.Down)
return;
switch (face)
{
case BlockFace.Down: return;
case BlockFace.Up: block.MetaData = (byte)MetaData.Torch.Standing;
break;
case BlockFace.West: block.MetaData = (byte)MetaData.Torch.West;
break;
case BlockFace.East: block.MetaData = (byte)MetaData.Torch.East;
break;
case BlockFace.North: block.MetaData = (byte)MetaData.Torch.North;
break;
case BlockFace.South: block.MetaData = (byte)MetaData.Torch.South;
break;
}
base.Place(entity, block, targetBlock, face);
}
示例4: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
{
Player player = entity as Player;
if (player == null)
return;
// TODO: Bugged - should depend on the player's Yaw/Pitch
switch (player.Client.FacingDirection(4))
{
case "N":
block.MetaData = (byte)MetaData.Stairs.South;
break;
case "E":
block.MetaData = (byte)MetaData.Stairs.West;
break;
case "S":
block.MetaData = (byte)MetaData.Stairs.North;
break;
case "W":
block.MetaData = (byte)MetaData.Stairs.East;
break;
default:
return;
}
base.Place(entity, block, targetBlock, targetSide);
}
示例5: CanBePlacedOn
protected override bool CanBePlacedOn(EntityBase who, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
{
Chunk chunk = GetBlockChunk(block);
if (chunk == null)
return false;
bool isDoubleChestNearby = false;
int chestCount = 0;
chunk.ForNSEW(block.Coords, uc =>
{
byte? nearbyBlockId = block.World.GetBlockId(uc);
if (nearbyBlockId == null)
return;
// Cannot place next to a double chest
if (nearbyBlockId == (byte)BlockData.Blocks.Chest)
{
chestCount++;
if (chunk.IsNSEWTo(uc, (byte)BlockData.Blocks.Chest))
isDoubleChestNearby = true;
}
});
if (isDoubleChestNearby || chestCount > 1)
return false;
return base.CanBePlacedOn(who, block, targetBlock, targetSide);
}
示例6: Grow
public void Grow(StructBlock block)
{
// Too high
/* if (Y > 120)
return;
// Grow a trunk. Replace only the BlockAir
for (int i = Y; i < Y + 5; i++)
{
if (Chunk.World.GetBlockId(X, i, Z) == (byte)BlockData.Blocks.Air)
WorldMgr.GetChunk(X, Z, false, true).ReplaceBlock(this, BlockData.Blocks.Log, BlockMeta);
else
break;
}
// Grow leaves
for (int i = Y + 2; i < Y + 5; i++)
for (int j = X - 2; j <= X + 2; j++)
for (int k = Z - 2; k <= Z + 2; k++)
if (!WorldMgr.ChunkExists(j, k) || !(WorldMgr.GetBlock(j, i, k) is BlockAir))
continue;
else
WorldMgr.GetChunk(j, k, false, true).ReplaceBlock(this, BlockData.Blocks.Leaves, BlockMeta);
for (int i = X - 1; i <= X + 1; i++)
for (int j = Z - 1; j <= Z + 1; j++)
if (!WorldMgr.ChunkExists(i, j) || !(WorldMgr.GetBlock(i, Y + 5, j) is BlockAir))
continue;
else
WorldMgr.GetChunk(i, j, false, true).ReplaceBlock(this, BlockData.Blocks.Leaves, BlockMeta);
foreach (Client c in WorldMgr.Server.GetNearbyPlayers(WorldMgr, X, Y, Z))
c.SendBlockRegion(X - 3, Y, Z - 3, 7, 7, 7);
*/
}
示例7: StartPhysics
protected void StartPhysics(StructBlock block)
{
Remove(block);
FallingSand fsBlock = new FallingSand(block.World, new Location(block.Coords.WorldX + 0.5, block.Coords.WorldY + 0.5, block.Coords.WorldZ + 0.5));
fsBlock.Start();
block.World.PhysicsBlocks.TryAdd(fsBlock.EntityId, fsBlock);
}
示例8: DropItems
protected override void DropItems(EntityBase entity, StructBlock block)
{
LootTable = new List<ItemStack>();
if (block.World.Server.Rand.Next(5) == 0)
LootTable.Add(new ItemStack((short)BlockData.Blocks.Sapling, 1));
base.DropItems(entity, block);
}
示例9: Grow
public void Grow(StructBlock block)
{
if (!CanGrow(block))
return;
for (int i = block.Coords.WorldY; i < block.Coords.WorldY + 4; i++)
{
block.World.SetBlockAndData(block.Coords.WorldX, i, block.Coords.WorldZ, (byte)BlockData.Blocks.Log, block.MetaData);
if (block.World.GetBlockId(block.Coords.WorldX, i + 1, block.Coords.WorldZ) != (byte)BlockData.Blocks.Air)
break;
}
// Grow leaves
for (int i = block.Coords.WorldY + 2; i < block.Coords.WorldY + 5; i++)
for (int j = block.Coords.WorldX - 2; j <= block.Coords.WorldX + 2; j++)
for (int k = block.Coords.WorldZ - 2; k <= block.Coords.WorldZ + 2; k++)
if (!block.World.ChunkExists(j >> 4, k >> 4) || (block.World.GetBlockId(j, i, k) != (byte)BlockData.Blocks.Air))
continue;
else
block.World.SetBlockAndData(j, i, k, (byte)BlockData.Blocks.Leaves,
block.MetaData);
for (int i = block.Coords.WorldX - 1; i <= block.Coords.WorldX + 1; i++)
for (int j = block.Coords.WorldZ - 1; j <= block.Coords.WorldZ + 1; j++)
if (!block.World.ChunkExists(i >> 4, j >> 4) || (block.World.GetBlockId(i, block.Coords.WorldY + 5, j) != (byte)BlockData.Blocks.Air))
continue;
else
block.World.SetBlockAndData(i, block.Coords.WorldY + 5, j, (byte)BlockData.Blocks.Leaves,
block.MetaData);
AbsWorldCoords absCoords = new AbsWorldCoords(block.Coords);
foreach (Net.Client c in block.World.Server.GetNearbyPlayers(block.World, absCoords))
{
c.SendBlockRegion(block.Coords.WorldX - 3, block.Coords.WorldY, block.Coords.WorldZ - 3, 7, 7, 7);
}
}
示例10: StartPhysics
protected void StartPhysics(StructBlock block)
{
Remove(block);
FallingGravel fgBlock = new FallingGravel(block.World, new AbsWorldCoords(block.Coords.WorldX + 0.5, block.Coords.WorldY + 0.5, block.Coords.WorldZ + 0.5));
fgBlock.Start();
block.World.PhysicsBlocks.TryAdd(fgBlock.EntityId, fgBlock);
}
示例11: UpdateWorld
protected override void UpdateWorld(StructBlock block, bool isDestroyed = false)
{
base.UpdateWorld(block, isDestroyed);
if (!isDestroyed && block.Coords.WorldY > 1)
if (block.World.GetBlockId(block.Coords.WorldX, block.Coords.WorldY - 1, block.Coords.WorldZ) == (byte)BlockData.Blocks.Air)
StartPhysics(block);
}
示例12: Place
public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
{
LivingEntity living = (entity as LivingEntity);
if (living == null)
return;
block.MetaData = GetDirection(living, block, targetBlock, face);
base.Place(entity, block, targetBlock, face);
}
示例13: DropItems
protected override void DropItems(EntityBase entity, StructBlock block, List<ItemStack> overridedLoot = null)
{
// SnowBlock requires 9 snowballs to craft and drops 4-6 snowballs upon destruction.
// No tools required.
overridedLoot = new List<ItemStack>();
overridedLoot.Add(new ItemStack((short)BlockData.Items.Snowball, (sbyte)(4 + block.World.Server.Rand.Next(2))));
base.DropItems(entity, block, overridedLoot);
}
示例14: NotifyDestroy
public override void NotifyDestroy(EntityBase entity, StructBlock sourceBlock, StructBlock targetBlock)
{
if ((targetBlock.Coords.WorldY - sourceBlock.Coords.WorldY) == 1 &&
targetBlock.Coords.WorldX == sourceBlock.Coords.WorldX &&
targetBlock.Coords.WorldZ == sourceBlock.Coords.WorldZ)
Destroy(targetBlock);
base.NotifyDestroy(entity, sourceBlock, targetBlock);
}
示例15: DropItems
protected override void DropItems(EntityBase entity, StructBlock block, List<ItemStack> overridedLoot = null)
{
overridedLoot = new List<ItemStack>();
int amount = block.World.Server.Rand.Next(10) - 7;
if (amount > 0)
overridedLoot.Add(new ItemStack((short)BlockData.Blocks.Red_Mushroom, (sbyte)amount));
base.DropItems(entity, block, overridedLoot);
}