本文整理汇总了C#中IWorld.GetBlockData方法的典型用法代码示例。如果您正苦于以下问题:C# IWorld.GetBlockData方法的具体用法?C# IWorld.GetBlockData怎么用?C# IWorld.GetBlockData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorld
的用法示例。
在下文中一共展示了IWorld.GetBlockData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
var descriptor = world.GetBlockData(coordinates);
LadderDirection direction;
switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
{
case Direction.North:
direction = LadderDirection.North;
break;
case Direction.South:
direction = LadderDirection.South;
break;
case Direction.East:
direction = LadderDirection.East;
break;
default:
direction = LadderDirection.West;
break;
}
descriptor.Metadata = (byte)direction;
if (IsSupported(descriptor, user.Server, world))
{
world.SetBlockID(descriptor.Coordinates, BlockID);
world.SetMetadata(descriptor.Coordinates, (byte)direction);
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
示例2: 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;
}
}
示例3: FlowOutward
private void FlowOutward(IWorld world, LiquidFlow target, IMultiplayerServer server)
{
// For each block we can flow into, generate an item entity if appropriate
var provider = world.BlockRepository.GetBlockProvider(world.GetBlockID(target.TargetBlock));
provider.GenerateDropEntity(new BlockDescriptor { Coordinates = target.TargetBlock, ID = provider.ID }, world, server, ItemStack.EmptyStack);
// And overwrite the block with a new fluid block.
world.SetBlockID(target.TargetBlock, FlowingID);
world.SetMetadata(target.TargetBlock, target.Level);
var chunk = world.FindChunk(target.TargetBlock);
server.Scheduler.ScheduleEvent("fluid", chunk,
TimeSpan.FromSeconds(SecondsBetweenUpdates),
s => AutomataUpdate(s, world, target.TargetBlock));
if (FlowingID == LavaBlock.BlockID)
{
(BlockRepository.GetBlockProvider(FireBlock.BlockID) as FireBlock).ScheduleUpdate(
server, world, world.GetBlockData(target.TargetBlock));
}
}
示例4: ItemUsedOnBlock
public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
var old = world.GetBlockData(coordinates);
byte[] overwritable =
{
AirBlock.BlockID,
WaterBlock.BlockID,
StationaryWaterBlock.BlockID,
LavaBlock.BlockID,
StationaryLavaBlock.BlockID
};
if (overwritable.Any(b => b == old.ID))
{
var data = world.GetBlockData(coordinates);
data.ID = ID;
data.Metadata = (byte)item.Metadata;
BlockPlaced(data, face, world, user);
if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
world.SetBlockData(coordinates, old);
else
{
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
}
示例5: ItemUsedOnBlock
public virtual void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
var old = world.GetBlockData(coordinates);
byte[] overwritable =
{
AirBlock.BlockID,
WaterBlock.BlockID,
StationaryWaterBlock.BlockID,
LavaBlock.BlockID,
StationaryLavaBlock.BlockID
};
if (overwritable.Any(b => b == old.ID))
{
// Test for entities
var em = user.Server.GetEntityManagerForWorld(world);
var entities = em.EntitiesInRange(coordinates, 2);
var box = new BoundingBox(coordinates, coordinates + Vector3.One);
foreach (var entity in entities)
{
var aabb = entity as IAABBEntity;
if (aabb != null && !(entity is ItemEntity))
{
if (aabb.BoundingBox.Intersects(box) && false) // TODO: Figure out
return;
}
var player = entity as PlayerEntity; // Players do not implement IAABBEntity
if (player != null)
{
if (new BoundingBox(player.Position, player.Position + player.Size)
.Intersects(box) && false)
return;
}
}
// Place block
world.SetBlockID(coordinates, ID);
world.SetMetadata(coordinates, (byte)item.Metadata);
BlockPlaced(world.GetBlockData(coordinates), face, world, user);
if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
world.SetBlockData(coordinates, old);
else
{
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
}
示例6: ItemUsedOnBlock
public virtual void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
{
var old = world.GetBlockData(coordinates);
if (!Overwritable.Any(b => b == old.ID))
{
coordinates += MathHelper.BlockFaceToCoordinates(face);
old = world.GetBlockData(coordinates);
if (!Overwritable.Any(b => b == old.ID))
return;
}
// Test for entities
if (BoundingBox.HasValue)
{
var em = user.Server.GetEntityManagerForWorld(world);
var entities = em.EntitiesInRange(coordinates, 3);
var box = new BoundingBox(BoundingBox.Value.Min + (Vector3)coordinates,
BoundingBox.Value.Max + (Vector3)coordinates);
foreach (var entity in entities)
{
var aabb = entity as IAABBEntity;
if (aabb != null && !(entity is ItemEntity))
{
if (aabb.BoundingBox.Intersects(box))
return;
}
var player = entity as PlayerEntity; // Players do not implement IAABBEntity
if (player != null)
{
if (new BoundingBox(player.Position, player.Position + player.Size)
.Intersects(box))
return;
}
}
}
// Place block
world.SetBlockID(coordinates, ID);
world.SetMetadata(coordinates, (byte)item.Metadata);
BlockPlaced(world.GetBlockData(coordinates), face, world, user);
if (!IsSupported(world.GetBlockData(coordinates), user.Server, world))
world.SetBlockData(coordinates, old);
else
{
item.Count--;
user.Inventory[user.SelectedSlot] = item;
}
}
示例7: DoSpread
public void DoSpread(IMultiplayerServer server, IWorld world, BlockDescriptor descriptor)
{
foreach (var coord in SpreadableBlocks)
{
var check = descriptor.Coordinates + coord;
if (world.GetBlockID(check) == AirBlock.BlockID)
{
// Check if this is adjacent to a flammable block
foreach (var adj in AdjacentBlocks)
{
var provider = BlockRepository.GetBlockProvider(
world.GetBlockID(check + adj));
if (provider.Flammable)
{
if (provider.Hardness == 0)
check = check + adj;
// Spread to this block
world.SetBlockID(check, FireBlock.BlockID);
ScheduleUpdate(server, world, world.GetBlockData(check));
break;
}
}
}
}
}