本文整理汇总了C#中IWorld.SetBlockID方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.SetBlockID方法的具体用法?C# IWorld.SetBlockID怎么用?C# IWorld.SetBlockID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorld
的用法示例。
在下文中一共展示了IWorld.SetBlockID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
var bottom = coordinates + MathHelper.BlockFaceToCoordinates(face);
var top = bottom + Coordinates3D.Up;
if (world.GetBlockID(top) != 0 || world.GetBlockID(bottom) != 0)
return;
DoorFlags direction;
switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
{
case Direction.North:
direction = DoorFlags.Northwest;
break;
case Direction.South:
direction = DoorFlags.Southeast;
break;
case Direction.East:
direction = DoorFlags.Northeast;
break;
default: // Direction.West:
direction = DoorFlags.Southwest;
break;
}
user.Server.BlockUpdatesEnabled = false;
world.SetBlockID(bottom, BlockID);
world.SetMetadata(bottom, (byte)direction);
world.SetBlockID(top, BlockID);
world.SetMetadata(top, (byte)(direction | DoorFlags.Upper));
user.Server.BlockUpdatesEnabled = true;
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
示例2: BlockUpdate
public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
{
bool upper = ((DoorItem.DoorFlags)descriptor.Metadata & DoorItem.DoorFlags.Upper) == DoorItem.DoorFlags.Upper;
var other = upper ? Coordinates3D.Down : Coordinates3D.Up;
if (world.GetBlockID(descriptor.Coordinates + other) != ID)
world.SetBlockID(descriptor.Coordinates, 0);
}
示例3: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
if (world.GetBlockID(coordinates) == AirBlock.BlockID)
{
world.SetBlockID(coordinates, FireBlock.BlockID);
}
}
示例4: BlockUpdate
public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
{
if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) != FarmlandBlock.BlockID)
{
GenerateDropEntity(descriptor, world, server);
world.SetBlockID(descriptor.Coordinates, 0);
}
}
示例5: BlockRightClicked
public override bool BlockRightClicked(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
if (descriptor.Metadata == 5)
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
else
world.SetMetadata(descriptor.Coordinates, (byte)(descriptor.Metadata + 1));
return false;
}
示例6: BlockUpdate
public override void BlockUpdate(BlockDescriptor descriptor, BlockDescriptor source, IMultiplayerServer server, IWorld world)
{
if (world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down) == AirBlock.BlockID)
{
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
server.GetEntityManagerForWorld(world).SpawnEntity(new FallingGravelEntity(descriptor.Coordinates));
}
}
示例7: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
if (world.GetBlockID(coordinates) == FarmlandBlock.BlockID)
{
world.SetBlockID(coordinates + MathHelper.BlockFaceToCoordinates(face), CropsBlock.BlockID);
world.BlockRepository.GetBlockProvider(CropsBlock.BlockID).BlockPlaced(
new BlockDescriptor { Coordinates = coordinates }, face, world, user);
}
}
示例8: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
if (item.ID == ItemID) // Empty bucket
{
var block = world.GetBlockID(coordinates);
if (block == WaterBlock.BlockID || block == StationaryWaterBlock.BlockID)
{
var meta = world.GetMetadata(coordinates);
if (meta == 0) // Is source block?
{
user.Inventory[user.SelectedSlot] = new ItemStack(WaterBucketItem.ItemID);
world.SetBlockID(coordinates, 0);
}
}
else if (block == LavaBlock.BlockID || block == StationaryLavaBlock.BlockID)
{
var meta = world.GetMetadata(coordinates);
if (meta == 0) // Is source block?
{
user.Inventory[user.SelectedSlot] = new ItemStack(LavaBucketItem.ItemID);
world.SetBlockID(coordinates, 0);
}
}
}
else
{
var provider = user.Server.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates));
if (!provider.Opaque)
{
if (RelevantBlockType != null)
{
var blockType = RelevantBlockType.Value;
user.Server.BlockUpdatesEnabled = false;
world.SetBlockID(coordinates, blockType);
world.SetMetadata(coordinates, 0); // Source block
user.Server.BlockUpdatesEnabled = true;
var liquidProvider = world.BlockRepository.GetBlockProvider(blockType);
liquidProvider.BlockPlaced(new BlockDescriptor { Coordinates = coordinates }, face, world, user);
}
user.Inventory[user.SelectedSlot] = new ItemStack(BucketItem.ItemID);
}
}
}
示例9: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
var id = world.GetBlockID(coordinates);
if (id == DirtBlock.BlockID || id == GrassBlock.BlockID)
{
world.SetBlockID(coordinates, FarmlandBlock.BlockID);
user.Server.BlockRepository.GetBlockProvider(FarmlandBlock.BlockID).BlockPlaced(
new BlockDescriptor { Coordinates = coordinates }, face, world, user);
}
}
示例10: ScheduledUpdate
private void ScheduledUpdate(IWorld world, Coordinates3D coords)
{
if (world.IsValidPosition(coords + Coordinates3D.Up))
{
var id = world.GetBlockID(coords + Coordinates3D.Up);
var provider = world.BlockRepository.GetBlockProvider(id);
if (provider.Opaque)
world.SetBlockID(coords, DirtBlock.BlockID);
}
}
示例11: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
var old = world.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates));
if (old.Hardness == 0)
{
world.SetBlockID(coordinates, CakeBlock.BlockID);
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
示例12: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
IBlockProvider supportingBlock = world.BlockRepository.GetBlockProvider(world.GetBlockID(coordinates + Coordinates3D.Down));
if (supportingBlock.Opaque)
{
world.SetBlockID(coordinates, RedstoneDustBlock.BlockID);
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
示例13: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
if (SugarcaneBlock.ValidPlacement(new BlockDescriptor { Coordinates = coordinates }, world))
{
world.SetBlockID(coordinates, SugarcaneBlock.BlockID);
item.Count--;
user.Inventory[user.SelectedSlot] = item;
user.Server.BlockRepository.GetBlockProvider(SugarcaneBlock.BlockID).BlockPlaced(
new BlockDescriptor { Coordinates = coordinates }, face, world, user);
}
}
示例14: BlockPlaced
public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
{
if (ValidCactusPosition(descriptor, user.Server.BlockRepository, world))
base.BlockPlaced(descriptor, face, world, user);
else
{
world.SetBlockID(descriptor.Coordinates, AirBlock.BlockID);
var manager = user.Server.GetEntityManagerForWorld(world);
manager.SpawnEntity(
new ItemEntity(descriptor.Coordinates + Coordinates3D.Up,
new ItemStack(CactusBlock.BlockID, (sbyte)1)));
// user.Inventory.PickUpStack() wasn't working?
}
}
示例15: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
if (world.GetBlockID(coordinates) == AirBlock.BlockID)
{
world.SetBlockID(coordinates, FireBlock.BlockID);
world.BlockRepository.GetBlockProvider(FireBlock.BlockID)
.BlockPlaced(world.GetBlockData(coordinates), face, world, user);
var slot = user.SelectedItem;
slot.Metadata += 1;
if (slot.Metadata >= Uses)
slot.Count = 0; // Destroy item
user.Inventory[user.SelectedSlot] = slot;
}
}