public static BlockEntity GetBlockEntityById(string blockEntityId) { BlockEntity blockEntity = null; if (blockEntityId == "Sign") { blockEntity = new Sign(); } else if (blockEntityId == "Chest") { blockEntity = new ChestBlockEntity(); } else if (blockEntityId == "EnchantTable") { blockEntity = new EnchantingTableBlockEntity(); } else if (blockEntityId == "Furnace") { blockEntity = new FurnaceBlockEntity(); } else if (blockEntityId == "Skull") { blockEntity = new SkullBlockEntity(); } return(blockEntity); }
public static BlockEntity GetBlockEntityById(string blockEntityId) { BlockEntity blockEntity = null; if (blockEntityId == "Sign") blockEntity = new Sign(); else if (blockEntityId == "Chest") blockEntity = new ChestBlockEntity(); else if (blockEntityId == "EnchantTable") blockEntity = new EnchantingTableBlockEntity(); else if (blockEntityId == "Furnace") blockEntity = new FurnaceBlockEntity(); else if (blockEntityId == "Skull") blockEntity = new SkullBlockEntity(); return blockEntity; }
public static BlockEntity GetBlockEntityById(string blockEntityId) { BlockEntity blockEntity = null; if (blockEntityId == "Sign") { blockEntity = new Sign(); } else if (blockEntityId == "Chest") { blockEntity = new ChestBlockEntity(); } else if (blockEntityId == "EnchantTable") { blockEntity = new EnchantingTableBlockEntity(); } else if (blockEntityId == "Furnace") { blockEntity = new FurnaceBlockEntity(); } else if (blockEntityId == "Skull") { blockEntity = new SkullBlockEntity(); } else if (blockEntityId == "ItemFrame") { blockEntity = new ItemFrameBlockEntity(); } else if (blockEntityId == "Bed") { blockEntity = new BedBlockEntity(); } else if (blockEntityId == "Banner") { blockEntity = new BannerBlockEntity(); } else if (blockEntityId == "FlowerPot") { blockEntity = new FlowerPotBlockEntity(); } else if (blockEntityId == "Beacon") { blockEntity = new BeaconBlockEntity(); } else if (blockEntityId == "MobSpawner") { blockEntity = new MobSpawnerBlockEntity(); } return(blockEntity); }
public override void PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { var coor = GetNewCoordinatesFromFace(blockCoordinates, face); if (face == BlockFace.Up) // On top of block { var skull = (Skull)BlockFactory.GetBlockById(144); skull.Coordinates = coor; skull.FacingDirection = 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 { var skull = (Skull)BlockFactory.GetBlockById(144); skull.Coordinates = coor; skull.FacingDirection = (int)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); if (player.GameMode == GameMode.Survival) { var itemInHand = player.Inventory.GetItemInHand(); itemInHand.Count--; player.Inventory.SetInventorySlot(player.Inventory.InHandSlot, itemInHand); } }
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); }
public static BlockEntity GetBlockEntityById(string blockEntityId) { BlockEntity blockEntity = CustomBlockEntityFactory?.GetBlockEntityById(blockEntityId); if (blockEntity != null) { return(blockEntity); } if (blockEntityId == "Sign") { blockEntity = new SignBlockEntity(); } else if (blockEntityId == "Chest") { blockEntity = new ChestBlockEntity(); } else if (blockEntityId == "EnchantTable") { blockEntity = new EnchantingTableBlockEntity(); } else if (blockEntityId == "Furnace") { blockEntity = new FurnaceBlockEntity(); } else if (blockEntityId == "BlastFurnace") { blockEntity = new BlastFurnaceBlockEntity(); } else if (blockEntityId == "Skull") { blockEntity = new SkullBlockEntity(); } else if (blockEntityId == "ItemFrame") { blockEntity = new ItemFrameBlockEntity(); } else if (blockEntityId == "Bed") { blockEntity = new BedBlockEntity(); } else if (blockEntityId == "Banner") { blockEntity = new BannerBlockEntity(); } else if (blockEntityId == "FlowerPot") { blockEntity = new FlowerPotBlockEntity(); } else if (blockEntityId == "Beacon") { blockEntity = new BeaconBlockEntity(); } else if (blockEntityId == "MobSpawner") { blockEntity = new MobSpawnerBlockEntity(); } else if (blockEntityId == "ChalkboardBlock") { blockEntity = new ChalkboardBlockEntity(); } else if (blockEntityId == "ShulkerBox") { blockEntity = new ShulkerBoxBlockEntity(); } else if (blockEntityId == "StructureBlock") { blockEntity = new StructureBlockBlockEntity(); } return(blockEntity); }