本文整理汇总了C#中BlockFace类的典型用法代码示例。如果您正苦于以下问题:C# BlockFace类的具体用法?C# BlockFace怎么用?C# BlockFace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockFace类属于命名空间,在下文中一共展示了BlockFace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
Log.Warn("Player " + player.Username + " should be banned for hacking!");
var block = world.GetBlock(blockCoordinates);
if (block is Tnt)
{
world.SetBlock(new Air() {Coordinates = block.Coordinates});
new PrimedTnt(world)
{
KnownPosition = new PlayerLocation(blockCoordinates.X, blockCoordinates.Y, blockCoordinates.Z),
Fuse = (byte) (new Random().Next(0, 20) + 10)
}.SpawnEntity();
}
else if (block.IsSolid)
{
var affectedBlock = world.GetBlock(GetNewCoordinatesFromFace(blockCoordinates, BlockFace.Up));
if (affectedBlock.Id == 0)
{
var fire = new Fire
{
Coordinates = affectedBlock.Coordinates
};
world.SetBlock(fire);
}
}
}
示例2: 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;
}
}
示例3: 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);
}
示例4: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
if (face == BlockFace.Up) // On top of block
{
// Standing Sign
var sign = new StandingSign();
sign.Coordinates = coor;
// metadata for sign is a value 0-15 that signify the orientation of the sign. Same as PC metadata.
sign.Metadata = (byte) ((int) (Math.Floor((player.KnownPosition.Yaw + 180)*16/360) + 0.5) & 0x0f);
world.SetBlock(sign);
}
else if (face == BlockFace.North) // At the bottom of block
{
// Doesn't work, ignore if that happen.
return;
}
else
{
// Wall sign
var sign = new WallSign();
sign.Coordinates = coor;
sign.Metadata = (byte) face;
world.SetBlock(sign);
}
// Then we create and set the sign block entity that has all the intersting data
var signBlockEntity = new Sign
{
Coordinates = coor
};
world.SetBlockEntity(signBlockEntity);
}
示例5: PlaceBlock
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
if (face == BlockFace.Down) return true;
switch (face)
{
case BlockFace.Up:
Metadata = 5;
break;
case BlockFace.East:
Metadata = 4;
break;
case BlockFace.West:
Metadata = 3;
break;
case BlockFace.North:
Metadata = 2;
break;
case BlockFace.South:
Metadata = 1;
break;
}
world.SetBlock(this);
return true;
}
示例6: Interact
public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face)
{
Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign;
if (signEntity == null) return false;
string world = signEntity.Text1;
if (player.Level.LevelId.Equals(world)) return true;
if (!Worlds.ContainsKey(player.Level.LevelId))
{
Worlds.Add(player.Level.LevelId, player.Level);
}
if (!Worlds.ContainsKey(world))
{
var mobHuntLevel = new MobHuntLevel(world, new FlatlandWorldProvider());
mobHuntLevel.Initialize();
Worlds.Add(world, mobHuntLevel);
}
Level level = Worlds[world];
player.SpawnLevel(level);
level.BroadcastTextMessage(string.Format("{0} teleported to world <{1}>.", player.Username, level.LevelId));
return true;
}
示例7: Place
public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face)
{
var block = (StructBlock)iBlock;
var living = entity as LivingEntity;
if (living == null)
return;
// TODO: Bugged - should depend on the player's Yaw/Pitch
switch (living.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, targetIBlock, face);
}
示例8: PlaceBlock
public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
{
var rawbits = new BitArray(new byte[] { 0x00 });
byte direction = player.GetDirection();
if (face == BlockFace.PositiveY)
{
switch (direction)
{
case 0:
//South
rawbits[1] = true;
rawbits[2] = true;
break;
case 1:
//West
rawbits[0] = true;
rawbits[2] = true;
break;
case 2:
//North
rawbits[1] = true;
rawbits[2] = true;
break;
case 3:
//East
rawbits[0] = true;
rawbits[2] = true;
break;
}
}
else if (face == BlockFace.NegativeY)
{
rawbits[0] = true;
rawbits[1] = true;
rawbits[2] = true;
}
else if (face == BlockFace.PositiveZ)
{
rawbits[0] = true;
rawbits[1] = true;
}
else if (face == BlockFace.NegativeZ)
{
rawbits[2] = true;
}
else if (face == BlockFace.PositiveX)
{
rawbits[0] = true;
}
else if (face == BlockFace.NegativeX)
{
rawbits[1] = true;
}
Metadata = ConvertToByte(rawbits);
world.SetBlock(this);
return true;
}
示例9: PlaceBlock
// 000 001 010 011 100
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
byte direction = player.GetDirection();
byte upper = (byte) ((faceCoords.Y > 0.5 && face != BlockFace.Up) || face == BlockFace.Down ? 0x04 : 0x00);
switch (direction)
{
case 0:
Metadata = (byte) (0 | upper);
break;
case 1:
Metadata = (byte) (2 | upper);
break;
case 2:
Metadata = (byte) (1 | upper);
break;
case 3:
Metadata = (byte) (3 | upper);
break;
}
world.SetBlock(this);
return true;
}
示例10: Place
public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face)
{
StructBlock block = (StructBlock)iBlock;
LivingEntity living = entity as LivingEntity;
if (living == null)
return;
switch (living.FacingDirection(4))
{
case "N":
block.MetaData = (byte)MetaData.Door.Northwest;
break;
case "W":
block.MetaData = (byte)MetaData.Door.Southwest;
break;
case "S":
block.MetaData = (byte)MetaData.Door.Southeast;
break;
case "E":
block.MetaData = (byte)MetaData.Door.Northeast;
break;
default:
return;
}
base.Place(entity, block, targetIBlock, face);
}
示例11: Interact
public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face)
{
Metadata = (byte) (Metadata | (0x8));
world.SetBlock(this);
world.ScheduleBlockTick(this, TickRate);
return true;
}
示例12: PlaceBlock
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
Metadata = (byte) face;
world.SetBlock(this);
return true;
}
示例13: 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);
}
示例14: PlaceBlock
public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
{
var prevblock = world.GetBlock(Coordinates);
if (prevblock.Id == Id && prevblock.Metadata == Metadata)
{
DoubleSlab ds = new DoubleSlab(Metadata) {Coordinates = Coordinates};
world.SetBlock(ds);
}
else if (prevblock.Id == Id && prevblock.Metadata != Metadata)
{
if (player.Gamemode != Gamemode.Creative)
{
player.Inventory.AddItem((short)Id, Metadata, 1);
}
return true;
}
else
{
bool upper = ((mouseLocation.Y >= 8 && face != BlockFace.PositiveY) || face == BlockFace.NegativeY);
BitArray b = new BitArray(new byte[] {Metadata});
b[3] = upper;
Metadata = ConvertToByte(b);
world.SetBlock(this);
}
return true;
}
示例15: UseItem
public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
{
blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
var d = new BlockRedstoneDust {Coordinates = blockCoordinates};
//d.SetPowerLevel(new Random().Next(0,15));
world.SetBlock(d, true, true);
}