本文整理汇总了C#中MiNET.Worlds.Level.SetBlockEntity方法的典型用法代码示例。如果您正苦于以下问题:C# Level.SetBlockEntity方法的具体用法?C# Level.SetBlockEntity怎么用?C# Level.SetBlockEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MiNET.Worlds.Level
的用法示例。
在下文中一共展示了Level.SetBlockEntity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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
{
Block skull = new Block(144);
skull.Coordinates = coor;
skull.Metadata = 1; // Skull on floor, rotation in block entity
world.SetBlock(skull);
}
else if (face == BlockFace.Down) // At the bottom of block
{
// Doesn't work, ignore if that happen.
return;
}
else
{
Block skull = new Block(144);
skull.Coordinates = coor;
skull.Metadata = (byte) face; // Skull on floor, rotation in block entity
world.SetBlock(skull);
}
// Then we create and set the sign block entity that has all the intersting data
var skullBlockEntity = new SkullBlockEntity
{
Coordinates = coor,
Rotation = (byte)((int)(Math.Floor(((player.KnownPosition.Yaw)) * 16 / 360) + 0.5) & 0x0f),
SkullType = (byte) Metadata
};
world.SetBlockEntity(skullBlockEntity);
}
示例3: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
if (player.GameMode != GameMode.Creative)
{
Item itemStackInHand = player.Inventory.GetItemInHand();
itemStackInHand.Count--;
if (itemStackInHand.Count <= 0)
{
// set empty
player.Inventory.Slots[player.Inventory.Slots.IndexOf(itemStackInHand)] = new ItemAir();
}
}
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
Chest chest = new Chest
{
Coordinates = coor,
};
if (!chest.CanPlace(world, face)) return;
chest.PlaceBlock(world, player, coor, face, faceCoords);
// Then we create and set the sign block entity that has all the intersting data
ChestBlockEntity chestBlockEntity = new ChestBlockEntity
{
Coordinates = coor
};
world.SetBlockEntity(chestBlockEntity);
}
示例4: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
if (player.GameMode != GameMode.Creative)
{
ItemStack itemStackInHand = player.Inventory.GetItemInHand();
itemStackInHand.Count--;
if (itemStackInHand.Count <= 0)
{
// set empty
player.Inventory.Slots[player.Inventory.Slots.IndexOf(itemStackInHand)] = new ItemStack();
}
}
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
EnchantingTable table = new EnchantingTable
{
Coordinates = coor,
Metadata = (byte) Metadata
};
if (!table.CanPlace(world, face)) return;
table.PlaceBlock(world, player, coor, face, faceCoords);
// Then we create and set the sign block entity that has all the intersting data
EnchantingTableBlockEntity tableBlockEntity = new EnchantingTableBlockEntity
{
Coordinates = coor
};
world.SetBlockEntity(tableBlockEntity);
}
示例5: Interact
public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
Item itemInHande = player.Inventory.GetItemInHand();
ItemFrameBlockEntity blockEntity = world.GetBlockEntity(blockCoordinates) as ItemFrameBlockEntity;
if (blockEntity != null)
{
blockEntity.SetItem(itemInHande);
world.SetBlockEntity(blockEntity);
}
return true;
}
示例6: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
Furnace furnace = new Furnace
{
Coordinates = coor,
};
if (!furnace.CanPlace(world, face)) return;
furnace.PlaceBlock(world, player, coor, face, faceCoords);
// Then we create and set the sign block entity that has all the intersting data
FurnaceBlockEntity furnaceBlockEntity = new FurnaceBlockEntity
{
Coordinates = coor
};
world.SetBlockEntity(furnaceBlockEntity);
}
示例7: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
Chest chest = new Chest
{
Coordinates = coor,
Metadata = (byte) Metadata
};
if (!chest.CanPlace(world, face)) return;
chest.PlaceBlock(world, player, coor, face, faceCoords);
// Then we create and set the sign block entity that has all the intersting data
ChestBlockEntity chestBlockEntity = new ChestBlockEntity
{
Coordinates = coor
};
world.SetBlockEntity(chestBlockEntity);
}
示例8: UseItem
public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
{
Log.Warn("Using custom item frame");
var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
ItemFrameBlockEntity itemFrameBlockEntity = new ItemFrameBlockEntity
{
Coordinates = coor
};
CustomItemFrame itemFrame = new CustomItemFrame(_frames, itemFrameBlockEntity, world, _frameTicker)
{
Coordinates = coor,
};
if (!itemFrame.CanPlace(world, face)) return;
itemFrame.PlaceBlock(world, player, coor, face, faceCoords);
// Then we create and set the sign block entity that has all the intersting data
world.SetBlockEntity(itemFrameBlockEntity);
}