public override bool PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords) { var container = GetState(); var direction = (BlockStateInt)container.States.First(s => s.Name == "facing_direction"); direction.Value = (int)face; SetState(container); var signBlockEntity = new SignBlockEntity { Coordinates = Coordinates }; world.SetBlockEntity(signBlockEntity); return(false); }
public override bool PlaceBlock(Level world, Player player, BlockCoordinates targetCoordinates, BlockFace face, Vector3 faceCoords) { var container = GetState(); var direction = (BlockStateInt)container.States.First(s => s.Name == "ground_sign_direction"); direction.Value = (byte)((int)(Math.Floor((player.KnownPosition.Yaw + 180) * 16 / 360) + 0.5) & 0x0f); SetState(container); var signBlockEntity = new SignBlockEntity { Coordinates = Coordinates }; world.SetBlockEntity(signBlockEntity); return(false); }
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); }